| | |
| | | package cn.huge.module.ctuser.controller; |
| | | package cn.huge.module.ctuser.controller.web; |
| | | |
| | | import cn.huge.base.common.dto.SelectTermDTO; |
| | | import cn.huge.base.common.utils.ObjectUtils; |
| | | import cn.huge.base.common.utils.ReturnFailUtils; |
| | | import cn.huge.base.common.utils.ReturnSucUtils; |
| | | import cn.huge.module.ctuser.domain.po.CtUser; |
| | | import cn.huge.module.ctuser.service.CtUserService; |
| | | import cn.huge.base.common.utils.SelectTermUtils; |
| | | import cn.huge.base.config.CurrentUser; |
| | | import cn.huge.module.ctrole.domain.po.CtRole; |
| | | import cn.huge.module.ctrole.service.CtRoleService; |
| | | import cn.huge.module.ctuser.domain.po.*; |
| | | import cn.huge.module.ctuser.dto.CtUserSaveDTO; |
| | | import cn.huge.module.ctuser.service.*; |
| | | import cn.huge.module.cust.constant.RoleBaseEnum; |
| | | import cn.huge.module.cust.constant.UserBaseConsts; |
| | | import cn.huge.module.cust.dto.CtUserDTO; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.google.common.collect.Maps; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * @title: 客户用户表接口api |
| | | * @description: 客户用户表接口api |
| | | * @title: 客户用户表接口api-web端 |
| | | * @description: 客户用户表接口api-web端 |
| | | * @company: hugeinfo |
| | | * @author: liyj |
| | | * @time: 2024-08-19 20:04:19 |
| | |
| | | |
| | | @Autowired |
| | | private CtUserService service; |
| | | |
| | | @Autowired |
| | | private CtUnitService ctUnitService; |
| | | |
| | | @Autowired |
| | | private CtRoleService ctRoleService; |
| | | |
| | | @Autowired |
| | | private CtDeptService ctDeptService; |
| | | |
| | | @Autowired |
| | | private CtUseroleService ctUseroleService; |
| | | |
| | | @Autowired |
| | | private CtAccountService ctAccountService; |
| | | |
| | | @Autowired |
| | | private CtUsepostService ctUsepostService; |
| | | |
| | | /** |
| | | * 获取请求URL参数 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 条件查询多个 |
| | | * @url {ctx}/api/web/ctUser/listQuery |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/listQuery") |
| | | public Object listQuery() { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | return ReturnSucUtils.getRepInfo(service.listTerms(terms)); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 条件分页查询 |
| | | * @url {ctx}/api/web/ctUser/pageQuery |
| | | * @param page 页码 |
| | | * @param size 每页数量 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/pageQuery") |
| | | public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | Sort sort = Sort.by(Sort.Direction.DESC, "create_time"); |
| | | PageRequest pageRequest = PageRequest.of(page-1, size, sort); |
| | | Page<CtUser> ctUserPage = service.pageQuery(pageRequest, terms); |
| | | return ReturnSucUtils.getRepInfo( "处理成功", ctUserPage); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据编号查询单个 |
| | | * @url {ctx}/api/web/ctUser/getById |
| | | * @param id 主键编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/getById") |
| | | public Object getById(@RequestParam(value = "id") String id) { |
| | | try { |
| | | return ReturnSucUtils.getRepInfo(service.getById(id)); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据主键单个 |
| | | * @url {ctx}/api/web/ctUser/deleteById |
| | | * @param ids 主键编号 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/deleteById") |
| | | public Object deleteById(@RequestParam(value = "id") String id) { |
| | | try { |
| | | service.removeById(id); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增或更新对象 |
| | | * @url {ctx}/api/web/ctUser/saveCtUser |
| | | * @param ctUser 实体对象 |
| | | * @return Object |
| | | */ |
| | | * web端-人员信息管理-新增/新用户信息 |
| | | * @url {ctx}/api/v1/ctUser/saveCtUser |
| | | * @param userId |
| | | * @return Object |
| | | * @throws Exception |
| | | */ |
| | | @PostMapping("/saveCtUser") |
| | | public Object saveCtUser(@RequestBody CtUser ctUser) { |
| | | public Object saveCtUser(@RequestBody CtUserSaveDTO ctUserSaveDTO, @CurrentUser String userId) { |
| | | try { |
| | | service.saveCtUser(ctUser); |
| | | // 保存更新用户信息 |
| | | service.webSaveCtUser(ctUserSaveDTO, userId); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取人员信息列表查询条件 |
| | | * @url {ctx}/api/v1/ctUser/listSelectTerm |
| | | * @return userId 登录用户标识称 |
| | | * @return Object |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/listSelectTerm") |
| | | public Object listSelectTerm(@CurrentUser String userId) { |
| | | try { |
| | | Map<String, Object> result = service.webListSelectTerm(userId); |
| | | return ReturnSucUtils.getRepInfo(result); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * web端-人员信息管理-人员列表 |
| | | * @url {ctx}/api/v1/ctUser/pageQuery |
| | | * @param page 页码 |
| | | * @param size 每页数量 |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/pageQuery") |
| | | public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, |
| | | @CurrentUser String userId) { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | Map<String, Object> result = service.webPageQuery(page, size, terms, userId); |
| | | return ReturnSucUtils.getRepInfo(result); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | } |