| | |
| | | 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.CtUserInfoDTO; |
| | | 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.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | 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.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.PageRequest; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | 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 |
| | |
| | | if (StringUtils.isNotBlank(dispStatus)){ |
| | | terms.put("dispStatus", dispStatus); |
| | | } |
| | | // 删除状态,0:已删除(默认),1:未删除 |
| | | // 删除状态,0:未删除,1:已删除 |
| | | String deleteStatus = request.getParameter("deleteStatus"); |
| | | if (StringUtils.isNotBlank(deleteStatus)){ |
| | | terms.put("deleteStatus", deleteStatus); |
| | |
| | | terms.put("updateStart", updateStart); |
| | | terms.put("updateEnd", updateEnd); |
| | | } |
| | | // 平台账号 |
| | | String acc = request.getParameter("acc"); |
| | | if (StringUtils.isNotBlank(acc)){ |
| | | terms.put("acc", acc); |
| | | } |
| | | // 角色编码 |
| | | String roleCode = request.getParameter("roleCode"); |
| | | if (StringUtils.isNotBlank(roleCode)){ |
| | | terms.put("roleCode", roleCode); |
| | | } |
| | | |
| | | return terms; |
| | | } |
| | | |
| | | /** |
| | | * web端-人员信息管理-新增/新用户信息 |
| | | * @url {ctx}/api/v1/ctUser/saveCtUser |
| | | * @url {ctx}/api/web/ctUser/saveCtUser |
| | | * @param userId |
| | | * @return Object |
| | | * @throws Exception |
| | | */ |
| | | @PostMapping("/saveCtUser") |
| | | public Object saveCtUser(@RequestBody CtUser ctUser, @CurrentUser String userId) { |
| | | public Object saveCtUser(@RequestBody CtUserSaveDTO ctUserSaveDTO, @CurrentUser String userId) { |
| | | try { |
| | | // 保存更新用户信息 |
| | | service.webSaveCtUser(ctUser, userId); |
| | | service.webSaveCtUser(ctUserSaveDTO, userId); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | |
| | | |
| | | /** |
| | | * 获取人员信息列表查询条件 |
| | | * @url {ctx}/api/v1/ctUser/listSelectTerm |
| | | * @url {ctx}/api/web/ctUser/listSelectTerm |
| | | * @return userId 登录用户标识称 |
| | | * @return Object |
| | | * @throws Exception |
| | |
| | | @GetMapping("/listSelectTerm") |
| | | public Object listSelectTerm(@CurrentUser String userId) { |
| | | try { |
| | | Map<String, Object> result = Maps.newHashMap(); |
| | | // 获取当前登录用户 |
| | | CtUser loginUser = service.getById(userId); |
| | | // 组织条件 |
| | | QueryWrapper<CtUnit> ctUnitQueryWrapper = new QueryWrapper<>(); |
| | | ctUnitQueryWrapper.eq("cust_id", loginUser.getCustId()); |
| | | List<CtUnit> ctUnits = ctUnitService.list(ctUnitQueryWrapper); |
| | | List<SelectTermDTO> unitSelectTerms = new ArrayList<>(); |
| | | for (CtUnit ctUnit: ctUnits) { |
| | | SelectTermDTO unitSelectTerm = new SelectTermDTO(); |
| | | unitSelectTerm.setValue(ctUnit.getId()); |
| | | unitSelectTerm.setLabel(ctUnit.getUnitName()); |
| | | unitSelectTerm.setParentId(ctUnit.getParentId()); |
| | | unitSelectTerms.add(unitSelectTerm); |
| | | |
| | | // 部门条件 |
| | | QueryWrapper<CtDept> ctDeptQueryWrapper = new QueryWrapper<>(); |
| | | ctDeptQueryWrapper.eq("unit_id", ctUnit.getId()); |
| | | List<CtDept> ctDepts = ctDeptService.list(ctDeptQueryWrapper); |
| | | if (CollectionUtils.isNotEmpty(ctDepts)) { |
| | | List<SelectTermDTO> deptSelectTerms = new ArrayList<>(); |
| | | for (CtDept ctDept : ctDepts) { |
| | | SelectTermDTO deptSelectTerm = new SelectTermDTO(); |
| | | deptSelectTerm.setValue(ctDept.getId()); |
| | | deptSelectTerm.setLabel(ctDept.getName()); |
| | | deptSelectTerm.setParentId(ctDept.getParentId()); |
| | | deptSelectTerms.add(deptSelectTerm); |
| | | } |
| | | List<SelectTermDTO> depts = SelectTermUtils.createTreeByRoot(deptSelectTerms); |
| | | unitSelectTerm.setChainList(depts); |
| | | } |
| | | } |
| | | result.put("units", SelectTermUtils.createTreeByFirst(unitSelectTerms, loginUser.getUnitId())); |
| | | |
| | | // 角色条件 |
| | | QueryWrapper<CtRole> ctRoleQueryWrapper = new QueryWrapper<>(); |
| | | ctRoleQueryWrapper.eq("unit_id", loginUser.getUnitId()); |
| | | //判断是否为村居(村居不应该有调委会管理员角色) |
| | | QueryWrapper<CtUnit> ctUnitQueryWrapper1 = new QueryWrapper<>(); |
| | | ctUnitQueryWrapper1.eq("id", loginUser.getUnitId()).eq("cust_id", loginUser.getCustId()) |
| | | .select("unit_type"); |
| | | CtUnit ctUnit = ctUnitService.getOne(ctUnitQueryWrapper1); |
| | | if(UserBaseConsts.UNIT_TYPE_4.equals(ctUnit.getUnitType())){ |
| | | ctRoleQueryWrapper.ne("role_code", RoleBaseEnum.ROLE_9.getIndex()); |
| | | } |
| | | List<CtRole> ctRoleList = ctRoleService.list(ctRoleQueryWrapper); |
| | | List<SelectTermDTO> roleSelectTerms = new ArrayList<>(); |
| | | for (CtRole ctRole: ctRoleList){ |
| | | SelectTermDTO selectTerm = new SelectTermDTO(); |
| | | selectTerm.setValue(ctRole.getRoleCode()); |
| | | selectTerm.setLabel(ctRole.getName()); |
| | | roleSelectTerms.add(selectTerm); |
| | | } |
| | | result.put("roles", roleSelectTerms); |
| | | return ReturnSucUtils.getRepInfo( "查询成功", result); |
| | | Map<String, Object> result = service.webListSelectTerm(userId); |
| | | return ReturnSucUtils.getRepInfo(result); |
| | | } catch (Exception e) { |
| | | log.error("Controller接口[CtUserController.listSelectTerm]请求异常:"+e, e); |
| | | return ReturnFailUtils.getRepInfo("查询失败", null); |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 条件分页查询人员信息 |
| | | * @url {ctx}/api/v1/ctUser/pageQuery |
| | | * web端-人员信息管理-人员列表 |
| | | * @url {ctx}/api/web/ctUser/pageQuery |
| | | * @param page 页码 |
| | | * @param size 每页数量 |
| | | * @return Object |
| | |
| | | public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size, |
| | | @CurrentUser String userId) { |
| | | try { |
| | | // 获取当前登录用户 |
| | | CtUserDTO loginUser = service.clientGetUserAll(userId); |
| | | Map<String, Object> result = Maps.newHashMap(); |
| | | Map<String, Object> terms = getParameter(); |
| | | if (RoleBaseEnum.checkAdminPower(loginUser)){ |
| | | terms.put("custId", loginUser.getCustId()); |
| | | }else if (RoleBaseEnum.checkCourtOrUnitPower(loginUser.getRoleCodes())){ |
| | | terms.put("custId", loginUser.getCustId()); |
| | | String unitId = (String) terms.get("unitId"); |
| | | if (StringUtils.isEmpty(unitId)){ |
| | | terms.put("unitId", loginUser.getUnitId()); |
| | | } |
| | | }else { |
| | | terms.put("custId", loginUser.getCustId()); |
| | | terms.put("id", loginUser.getId()); |
| | | } |
| | | Sort sort = Sort.by(Sort.Direction.DESC, "t1.create_time"); |
| | | PageRequest pageRequest = PageRequest.of(page-1, size, sort); |
| | | Page<CtUser> ctUserPage = service.pageUserAndRole(pageRequest, terms); |
| | | QueryWrapper<CtAccount> accountQueryWrapper = new QueryWrapper<>(); |
| | | QueryWrapper<CtUserole> ctUseroleQueryWrapper = new QueryWrapper<>(); |
| | | QueryWrapper<CtUsepost> ctUsepostQueryWrapper = new QueryWrapper<>(); |
| | | for (CtUser ctUser: ctUserPage){ |
| | | accountQueryWrapper.clear(); |
| | | // 密码 |
| | | accountQueryWrapper.eq("acc_type", UserBaseConsts.ACC_TYPE_1); |
| | | accountQueryWrapper.eq("user_id", ctUser.getId()); |
| | | CtAccount ctAccount = ctAccountService.getOne(accountQueryWrapper); |
| | | if (ObjectUtils.isNotEmpty(ctAccount)){ |
| | | ctUser.setAcc(ctAccount.getAcc()); |
| | | ctUser.setCipher(ctAccount.getCipherOpen()); |
| | | } |
| | | // 角色 |
| | | ctUseroleQueryWrapper.clear(); |
| | | ctUseroleQueryWrapper.eq("user_id", ctUser.getId()); |
| | | List<CtUserole> ctUseroleList = ctUseroleService.list(ctUseroleQueryWrapper); |
| | | if (ObjectUtils.isNotEmpty(ctUseroleList)){ |
| | | for (CtUserole ctUserole: ctUseroleList){ |
| | | ctUserole.setRoleId(ctUserole.getRoleCode()); |
| | | } |
| | | ctUser.setCtUseroleList(ctUseroleList); |
| | | } |
| | | // 岗位 |
| | | ctUsepostQueryWrapper.clear(); |
| | | ctUsepostQueryWrapper.eq("user_id", ctUser.getId()); |
| | | List<CtUsepost> ctUsepostList = ctUsepostService.list(ctUsepostQueryWrapper); |
| | | if (ObjectUtils.isNotEmpty(ctUsepostList)) { |
| | | ctUser.setCtUsepostList(ctUsepostList); |
| | | } |
| | | } |
| | | result.put("ctUserPage", ctUserPage); |
| | | terms = Maps.newHashMap(); |
| | | // 生效名额 |
| | | terms.put("status", UserBaseConsts.USER_STATUS_1); |
| | | terms.put("custId", loginUser.getCustId()); |
| | | if (RoleBaseEnum.checkAdminPower(loginUser)){ |
| | | terms.put("custId", loginUser.getCustId()); |
| | | }else if (RoleBaseEnum.checkCourtOrUnitPower(loginUser.getRoleCodes())){ |
| | | terms.put("custId", loginUser.getCustId()); |
| | | String unitId = (String) terms.get("unitId"); |
| | | if (StringUtils.isEmpty(unitId)){ |
| | | terms.put("unitId", loginUser.getUnitId()); |
| | | } |
| | | }else { |
| | | terms.put("custId", loginUser.getCustId()); |
| | | terms.put("id", loginUser.getId()); |
| | | } |
| | | long countZzStatus = service.countTerms(terms); |
| | | result.put("countZzStatus", countZzStatus); |
| | | return ReturnSucUtils.getRepInfo( "处理成功", result); |
| | | Map<String, Object> result = service.webPageQuery(page, size, terms, userId); |
| | | return ReturnSucUtils.getRepInfo(result); |
| | | } catch (Exception e) { |
| | | log.error("Controller接口[CtUserController.pageQuery]请求异常:"+e, e); |
| | | return ReturnFailUtils.getRepInfo(e.getMessage(), null); |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新人员状态信息 |
| | | * @url {ctx}/api/web/ctUser/updateCtUserStatus |
| | | * @param id 编号 status :用户状态,1:在职(默认),2:停用,99:离职 |
| | | * @return Object |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/updateCtUserStatus") |
| | | public Object updateCtUserStatus(@RequestParam(value = "status") String status, @RequestParam(value = "id") String id) { |
| | | try { |
| | | // 修改状态 |
| | | UpdateWrapper<CtUser> ctUserUpdateWrapper = new UpdateWrapper(); |
| | | ctUserUpdateWrapper.eq("id", id); |
| | | ctUserUpdateWrapper.set("status", status).set("update_time", new Date()); |
| | | service.update(ctUserUpdateWrapper); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据主键单个/批量删除 |
| | | * @url {ctx}/api/web/ctUser/removeByIds |
| | | * @return Object |
| | | * @throws Exception |
| | | */ |
| | | @PostMapping("/removeByIds") |
| | | public Object removeByIds(@RequestBody List<String> data) { |
| | | try { |
| | | service.removeListId(data); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | log.error("Controller接口[CtUserController.removeByIds]请求异常:"+e, e); |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 选择人员 |
| | | * @url {ctx}/api/web/ctUser/userChoose |
| | | * @return Object |
| | | */ |
| | | @GetMapping("/userChoose") |
| | | public Object userChoose(@CurrentUser String userId) { |
| | | try { |
| | | String roleCode = request.getParameter("roleCode"); |
| | | List<SelectTermDTO> unitSelectTerms = service.userChoose(userId, roleCode); |
| | | return ReturnSucUtils.getRepInfo(unitSelectTerms); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 共通组件-根据人员编号查询单个人员信息及角色信息 |
| | | * @url {ctx}/api/web/ctUser/getByIdRole |
| | | * @param id 主键编号 |
| | | * @return Object |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/getByIdRole") |
| | | public Object getByIdRole(@RequestParam(value = "id") String id) { |
| | | try { |
| | | CtUserInfoDTO ctUserInfoDTO = new CtUserInfoDTO(); |
| | | CtUser ctUser = service.getById(id); |
| | | if (ObjectUtils.isNotEmpty(ctUser)) { |
| | | BeanUtils.copyProperties(ctUser, ctUserInfoDTO); |
| | | CtAccount ctAccount = ctAccountService.getByUserIdAndType(id, UserBaseConsts.ACC_TYPE_1); |
| | | ctUserInfoDTO.setLoginTime(ctAccount.getLoginTime()); |
| | | ctUserInfoDTO.setAcc(ctAccount.getAcc()); |
| | | List<String> roleNameList = ctUseroleService.listRoleName(id); |
| | | if (CollectionUtils.isNotEmpty(roleNameList)) { |
| | | String userRoles = roleNameList.stream().map(String::valueOf).collect(Collectors.joining("、")); |
| | | ctUserInfoDTO.setUserRoles(userRoles); |
| | | } |
| | | } |
| | | return ReturnSucUtils.getRepInfo(ctUserInfoDTO); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | } |