diff --git a/epmet-admin/epmet-admin-server/src/test/java/io/renren/service/DynamicDataSourceTest.java b/epmet-admin/epmet-admin-server/src/test/java/io/renren/service/DynamicDataSourceTest.java index 823c7bb233..22069ffd12 100644 --- a/epmet-admin/epmet-admin-server/src/test/java/io/renren/service/DynamicDataSourceTest.java +++ b/epmet-admin/epmet-admin-server/src/test/java/io/renren/service/DynamicDataSourceTest.java @@ -1,48 +1,48 @@ -/** - * Copyright 2018 人人开源 https://www.renren.io - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.epmet.service; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * 多数据源测试 - * - * @author Mark sunlightcs@gmail.com - * @since 1.0.0 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class DynamicDataSourceTest { - @Autowired - private DynamicDataSourceTestService dynamicDataSourceTestService; - - @Test - public void test(){ - Long id = 1067246875800000001L; - dynamicDataSourceTestService.selectById(id); - dynamicDataSourceTestService.updateUser(id); - dynamicDataSourceTestService.updateUserBySlave1(id); - dynamicDataSourceTestService.updateUserBySlave2(id); - } - - -} +///** +// * Copyright 2018 人人开源 https://www.renren.io +// *

+// * This program is free software: you can redistribute it and/or modify +// * it under the terms of the GNU General Public License as published by +// * the Free Software Foundation, either version 3 of the License, or +// * (at your option) any later version. +// *

+// * This program is distributed in the hope that it will be useful, +// * but WITHOUT ANY WARRANTY; without even the implied warranty of +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// * GNU General Public License for more details. +// *

+// * You should have received a copy of the GNU General Public License +// * along with this program. If not, see . +// */ +// +//package com.epmet.service; +// +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +///** +// * 多数据源测试 +// * +// * @author Mark sunlightcs@gmail.com +// * @since 1.0.0 +// */ +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class DynamicDataSourceTest { +// @Autowired +// private com.epmet.service.DynamicDataSourceTestService dynamicDataSourceTestService; +// +// @Test +// public void test(){ +// Long id = 1067246875800000001L; +// dynamicDataSourceTestService.selectById(id); +// dynamicDataSourceTestService.updateUser(id); +// dynamicDataSourceTestService.updateUserBySlave1(id); +// dynamicDataSourceTestService.updateUserBySlave2(id); +// } +// +// +//} diff --git a/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 527db417ef..27c596f0de 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -3,10 +3,12 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.StaffOrgFormDTO; +import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.feign.fallback.GovOrgFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import java.util.List; @@ -27,4 +29,12 @@ public interface GovOrgFeignClient { **/ @PostMapping(value = "/gov/org/customeragency/getStaffOrgList",consumes = MediaType.APPLICATION_JSON_VALUE) Result> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO); + + /** + * 查询人员部门列表 + * @param staffId + * @return + */ + @PostMapping("/gov/org/department/staff/{staffId}/departmentlist") + Result> getDepartmentListByStaffId(@PathVariable("staffId") String staffId); } diff --git a/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java b/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java index a1ccd0bdf0..0e42e2436f 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java +++ b/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.StaffOrgFormDTO; +import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.feign.GovOrgFeignClient; import org.springframework.stereotype.Component; @@ -22,5 +23,10 @@ public class GovOrgFeignClientFallback implements GovOrgFeignClient { public Result> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffOrgList", staffOrgFormDTO); } + + @Override + public Result> getDepartmentListByStaffId(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getDepartmentListByStaffId", staffId); + } } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 35ce90b25c..6b5fc2914d 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -3,6 +3,7 @@ package com.epmet.service.impl; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; @@ -12,6 +13,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.form.*; +import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.dto.result.StaffLatestAgencyResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -27,11 +29,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; /** * @Description 政府端登录服务 @@ -166,6 +167,22 @@ public class GovLoginServiceImpl implements GovLoginService { govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); govTokenDto.setAgencyId(staffLatestAgency.getAgencyId()); govTokenDto.setCustomerId(staffLatestAgency.getCustomerId()); + + try { + Result> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffLatestAgency.getStaffId()); + if (deptListResult.success()) { + if (!CollectionUtils.isEmpty(deptListResult.getData())) { + Set deptIdLists = deptListResult.getData().stream().map(dept -> dept.getDepartmentId()).collect(Collectors.toSet()); + govTokenDto.setDeptIdList(deptIdLists); + } + } else { + logger.error("登录:查询部门列表,远程调用返回错误:{}", deptListResult.getMsg()); + } + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + logger.error("登录:查询部门列表异常:{}", errorStackTrace); + } + cpUserDetailRedis.set(govTokenDto, expire); logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); } diff --git a/epmet-auth/src/test/java/com/epmet/TokenGenTest.java b/epmet-auth/src/test/java/com/epmet/TokenGenTest.java index 3368e2d1cf..60f7654b22 100644 --- a/epmet-auth/src/test/java/com/epmet/TokenGenTest.java +++ b/epmet-auth/src/test/java/com/epmet/TokenGenTest.java @@ -11,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; @RunWith(SpringRunner.class) @@ -43,6 +45,7 @@ public class TokenGenTest { govTokenDto.setUpdateTime(System.currentTimeMillis()); govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(tokenStr).getTime()); govTokenDto.setAgencyId("1"); + govTokenDto.setDeptIdList(new HashSet<>(Arrays.asList("1","2","3"))); govTokenDto.setCustomerId("f76def116c9c2dc0269cc17867af122c"); cpUserDetailRedis.set(govTokenDto, expire); } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java index 13910a6f3a..382e268146 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java @@ -9,13 +9,12 @@ package com.epmet.commons.mybatis.aspect; import com.epmet.commons.mybatis.annotation.DataFilter; +import com.epmet.commons.mybatis.constant.AccessSettingConstant; import com.epmet.commons.mybatis.constant.OpeScopeConstant; -import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; -import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; -import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; -import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.dto.form.*; import com.epmet.commons.mybatis.entity.DataScope; import com.epmet.commons.mybatis.feign.GovAccessFeignClient; +import com.epmet.commons.mybatis.feign.GovOrgFeignClient; import com.epmet.commons.tools.aspect.AccessOpeAspect; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; @@ -46,12 +45,20 @@ public class DataFilterAspect { private static final Logger log = LoggerFactory.getLogger(DataFilterAspect.class); + /** + * 线程变量,记录是否已经添加了至少一个过滤条件 + */ + private static final ThreadLocal hasConditions = new ThreadLocal(); + @Autowired private LoginUserUtil loginUserUtil; @Autowired private GovAccessFeignClient govAccessFeignClient; + @Autowired + private GovOrgFeignClient govOrgFeignClient; + public static final String orgIdPathSpliter = ":"; @Before("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)") @@ -94,22 +101,20 @@ public class DataFilterAspect { // 校验操作权限 validateOpePermission(permCacheResultDTO.getPermissions(), requirePermission); + hasConditions.set(false); + // 生成过滤sql + String sqlFilterSegment = getSqlFilterSegment(userId, permCacheResultDTO.getRoleIdList(), requirePermission, + permCacheResultDTO.getOrgIdPath(), permCacheResultDTO.getGridId(), tableAlias, permCacheResultDTO.getDeptIdList()); + + // 填充到Service方法列表中的DataScope对象中 Object[] methodArgs = point.getArgs(); for (Object methodArg : methodArgs) { if (methodArg instanceof DataScope) { - ((DataScope) methodArg).setSqlFilter(getSqlFilterSegment( - userId, - permCacheResultDTO.getRoleIdList(), - requirePermission, - permCacheResultDTO.getOrgIdPath(), - permCacheResultDTO.getGridId(), - tableAlias)); + ((DataScope) methodArg).setSqlFilter(sqlFilterSegment); return; } } - - //throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR); } /** @@ -128,89 +133,149 @@ public class DataFilterAspect { * * @return */ - private String getSqlFilterSegment(String userId,Set roleIds, String reqiurePermission, String orgIdPath, String gridId, String tableAlias) { - // 根据角色列表查询操作范围列表 - Set scopeDTOS = new HashSet<>(); - roleIds.forEach(roleId -> { - OperationScopeFormDTO osformDto = new OperationScopeFormDTO(); - osformDto.setRoleId(roleId); - osformDto.setOperationKey(reqiurePermission); - Result> result = govAccessFeignClient.getOperationScopesByRoleId(osformDto); - if (result.success()) { - scopeDTOS.addAll(result.getData()); - } - }); + private String getSqlFilterSegment(String userId, Set roleIds, String reqiurePermission, String orgIdPath, + String gridId, String tableAlias, Set deptIds) { - // 过滤范围 - HashSet scopes = filteScopes(scopeDTOS); - if (CollectionUtils.isEmpty(scopes)) { - // 没有范围限制 - return ""; - } StringBuilder sb = new StringBuilder(); + Map accessSettings = listRoleAccessSettings(roleIds); + // 1.生成sql:组织范围过滤 - genOrgScopeSql(sb, orgIdPath, scopes, tableAlias); + genOrgScopeSql(sb, orgIdPath, roleIds, reqiurePermission, tableAlias); // 2.生成sql:我发起的 - genIStartedSql(sb, userId, tableAlias); + String iCreated = accessSettings.get(AccessSettingConstant.I_CREATED_KEY); + if (StringUtils.isNotBlank(iCreated) && AccessSettingConstant.I_CREATED_YES.equals(iCreated)) { + genICreatedSql(sb, userId, tableAlias); + } // 3.生成sql:本网格的 - genInGrid(sb, gridId, tableAlias); + String inGrid = accessSettings.get(AccessSettingConstant.IN_GRID_KEY); + if (StringUtils.isNotBlank(inGrid) && AccessSettingConstant.IN_GRID_YES.equals(inGrid)) { + genInGrid(sb, gridId, tableAlias); + } + + // 4.生成sql:根据部门列表 + String inDept = accessSettings.get(AccessSettingConstant.IN_DEPARTMENT_KEY); + if (StringUtils.isNotBlank(inDept) && AccessSettingConstant.IN_DEPARTMENT_YES.equals(inDept)) { + genDepartmentFilterSql(sb, deptIds); + } - //sb.append(")"); - System.out.println("生成的过滤sql:" + sb.toString()); return sb.toString(); } + /** + * 列出角色对应的权限设置项 + * @param roleIds + * @return + */ + private Map listRoleAccessSettings(Set roleIds) { + Map settings = new HashMap<>(); + roleIds.forEach(roleId -> { + settings.putAll(listRoleAccessSettings(roleId)); + }); + return settings; + } + + private Map listRoleAccessSettings(String roleId) { + Result> result = govAccessFeignClient.listAccessSettings(roleId); + if (result.success()) { + return result.getData(); + } else { + log.error("角色[{}]查询权限配置AccessSettings失败:{}", roleId, result.getMsg()); + } + return new HashMap<>(); + } + /** + * 生成部门过滤sql + * + * @param sb + */ + private void genDepartmentFilterSql(StringBuilder sb, Set deptIdList) { + //Result> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId); + if (CollectionUtils.isEmpty(deptIdList)) { + return; + } + deptIdList.forEach(deptId -> { + sb.append(hasConditions.get() ? " OR " : "").append(" DEPARTMENT_ID = '").append(deptId).append("' "); + }); + hasConditions.set(true); + } + /** * 网格sql + * * @param sb * @param gridId * @param tableAlias */ private void genInGrid(StringBuilder sb, String gridId, String tableAlias) { if (StringUtils.isBlank(tableAlias)) { - sb.append(" OR GRID_ID ='").append(gridId).append("'"); + sb.append(hasConditions.get() ? " OR " : "").append(" GRID_ID ='").append(gridId).append("' "); } else { - sb.append(" OR ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("'"); + sb.append(hasConditions.get() ? " OR " : "").append(tableAlias).append(".GRID_ID ='").append(gridId).append("' "); } + hasConditions.set(true); } /** * sql:我发起的 + * * @param userId */ - private void genIStartedSql(StringBuilder sb, String userId, String tableAlias) { + private void genICreatedSql(StringBuilder sb, String userId, String tableAlias) { if (StringUtils.isBlank(tableAlias)) { - sb.append(" OR CREATED_BY ='").append(userId).append("'"); + sb.append(hasConditions.get() ? " OR " : " ").append(" CREATED_BY ='").append(userId).append("'"); } else { - sb.append(" OR ").append(tableAlias).append(".CREATED_BY ='").append(userId).append("'"); + sb.append(hasConditions.get() ? " OR " : " ").append(tableAlias).append(".CREATED_BY ='").append(userId).append("'"); } + hasConditions.set(true); } /** * 计算组织范围过滤sql,整体入口 + * * @param sb * @param orgIdPath - * @param scopes */ - public void genOrgScopeSql(StringBuilder sb, String orgIdPath, HashSet scopes, String tableAlias) { + public void genOrgScopeSql(StringBuilder sb, String orgIdPath, Set roleIds, String reqiurePermission, String tableAlias) { + + // 根据角色列表查询操作范围列表 + Set scopeDTOS = new HashSet<>(); + roleIds.forEach(roleId -> { + OperationScopeFormDTO osformDto = new OperationScopeFormDTO(); + osformDto.setRoleId(roleId); + osformDto.setOperationKey(reqiurePermission); + Result> result = govAccessFeignClient.getOperationScopesByRoleId(osformDto); + if (result.success()) { + scopeDTOS.addAll(result.getData()); + } + }); + + // 过滤范围 + HashSet scopes = filteScopes(scopeDTOS); + if (CollectionUtils.isEmpty(scopes)) { + // 没有范围限制 + return; + } + // 取出父组织ID path 和当前组织ID String pOrgPath = orgIdPath.substring(0, orgIdPath.lastIndexOf(orgIdPathSpliter)); String currOrgPath = orgIdPath.substring(orgIdPath.lastIndexOf(orgIdPathSpliter) + 1); genOrgScopeSql(sb, scopes, currOrgPath, pOrgPath, tableAlias); sb.replace(sb.lastIndexOf("OR"), sb.lastIndexOf("OR") + 3, ""); + hasConditions.set(true); } /** * 计算组织范围过滤sql + * * @param scopes * @param currOrg * @param pOrgPath * @return */ - private void genOrgScopeSql(StringBuilder sb,HashSet scopes, String currOrg, String pOrgPath, String tableAlias) { + private void genOrgScopeSql(StringBuilder sb, HashSet scopes, String currOrg, String pOrgPath, String tableAlias) { for (String scope : scopes) { switch (scope) { case OpeScopeConstant.ORG_CURR: @@ -261,6 +326,9 @@ public class DataFilterAspect { for (OperationScopeDTO scope : scopeDTOS) { String scopeIndex = scope.getScopeIndex(); + if (StringUtils.isBlank(scopeIndex)) { + continue; + } String[] currArr = scopeIndex.split("_"); if ("0".equals(currArr[1])) { // 为0,说明没有包含关系,直接放入 diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/constant/AccessSettingConstant.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/constant/AccessSettingConstant.java new file mode 100644 index 0000000000..4ccb9a8b41 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/constant/AccessSettingConstant.java @@ -0,0 +1,15 @@ +package com.epmet.commons.mybatis.constant; + +public class AccessSettingConstant { + public static final String I_CREATED_KEY = "I_CREATED"; + public static final String I_CREATED_YES = "YES"; + + public static final String I_PART_KEY = "I_PART"; + public static final String I_PART_YES = "YES"; + + public static final String IN_GRID_KEY = "IN_GRID"; + public static final String IN_GRID_YES = "YES"; + + public static final String IN_DEPARTMENT_KEY = "IN_DEPARTMENT"; + public static final String IN_DEPARTMENT_YES = "YES"; +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/DepartmentListResultDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/DepartmentListResultDTO.java new file mode 100644 index 0000000000..1bf20bae66 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/DepartmentListResultDTO.java @@ -0,0 +1,49 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.commons.mybatis.dto.form; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 组织首页-获取机关下部门列表-部门详情数据 + * + * @author sun + */ +@Data +public class DepartmentListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + private String departmentId; + + /** + * 部门名称 + */ + private String departmentName; + + /** + * 部门下总人数 + */ + private Integer totalUser; +} \ No newline at end of file diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/RoleAccessSettingResultDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/RoleAccessSettingResultDTO.java new file mode 100644 index 0000000000..f4099cfaa1 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/RoleAccessSettingResultDTO.java @@ -0,0 +1,13 @@ +package com.epmet.commons.mybatis.dto.form; + +import lombok.Data; + +@Data +public class RoleAccessSettingResultDTO { + + private String settingKey; + private String id; + private String settingName; + private String roleId; + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java index 7775756b38..ec090d7aee 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java @@ -17,6 +17,11 @@ public class StaffPermCacheResultDTO { */ private Set roleIdList; + /** + * 部门id列表 + */ + private Set deptIdList; + /** * 机构Id */ diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java index 50b20890e7..354df4950f 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java @@ -1,23 +1,23 @@ package com.epmet.commons.mybatis.feign; -import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; -import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; -import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; -import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.dto.form.*; import com.epmet.commons.mybatis.feign.fallback.GovAccessFeignClientFallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; +import java.util.Map; import java.util.Set; /** * @Description * @Author sun */ +//, url = "localhost:8099" @FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class) public interface GovAccessFeignClient { @@ -36,4 +36,11 @@ public interface GovAccessFeignClient { @PostMapping("/gov/access/access/operationscopes") Result> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO); + /** + * 查询角色的权限相关配置 + * @param roleId + * @return + */ + @PostMapping("/gov/access/access/role/{roleId}/accesssettings") + Result> listAccessSettings(@PathVariable("roleId") String roleId); } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovOrgFeignClient.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovOrgFeignClient.java new file mode 100644 index 0000000000..67226cdd0e --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovOrgFeignClient.java @@ -0,0 +1,30 @@ +package com.epmet.commons.mybatis.feign; + +import com.epmet.commons.mybatis.dto.form.*; +import com.epmet.commons.mybatis.feign.fallback.GovAccessFeignClientFallback; +import com.epmet.commons.mybatis.feign.fallback.GovOrgFeignClientFallback; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; +import java.util.Set; + +/** + * @Description + * @Author sun + */ +//, url = "localhost:8092" +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallback.class) +public interface GovOrgFeignClient { + + /** + * 查询人员部门列表 + * @param staffId + * @return + */ + @PostMapping("/gov/org/department/staff/{staffId}/departmentlist") + Result> getDepartmentListByStaffId(@PathVariable("staffId") String staffId); +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java index 6dfa1b89cc..ae74de9483 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java @@ -1,15 +1,14 @@ package com.epmet.commons.mybatis.feign.fallback; -import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; -import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; -import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; -import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.dto.form.*; import com.epmet.commons.mybatis.feign.GovAccessFeignClient; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -30,4 +29,9 @@ public class GovAccessFeignClientFallback implements GovAccessFeignClient { public Result> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO) { return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getOperationScopesByRoleId", operationScopeFormDTO); } + + @Override + public Result> listAccessSettings(String roleId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listAccessSettings", roleId); + } } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovOrgFeignClientFallback.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovOrgFeignClientFallback.java new file mode 100644 index 0000000000..cce3d60309 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovOrgFeignClientFallback.java @@ -0,0 +1,27 @@ +package com.epmet.commons.mybatis.feign.fallback; + +import com.epmet.commons.mybatis.dto.form.*; +import com.epmet.commons.mybatis.feign.GovAccessFeignClient; +import com.epmet.commons.mybatis.feign.GovOrgFeignClient; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Set; + +/** + * 调用政府端权限 + * @Author wxz + * @Description + * @Date 2020/4/24 11:17 + **/ +@Component +public class GovOrgFeignClientFallback implements GovOrgFeignClient { + + @Override + public Result> getDepartmentListByStaffId(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getDepartmentListByStaffId", staffId); + } +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java index d26f7525a1..e211c01e4e 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java @@ -80,6 +80,9 @@ public class DataFilterInterceptor extends AbstractSqlParserHandler implements I String orderBy = "ORDER BY"; String groupBy = "GROUP BY"; String sqlFilter = scope.getSqlFilter(); + if (StringUtils.isBlank(sqlFilter)) { + return invocation.proceed(); + } if (originalSql.indexOf("WHERE") == 0) { // 不包含where,需要手动拼接上 sqlFilter = " WHERE ".concat(sqlFilter); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 6598010561..0b6c64d6ef 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -215,6 +215,15 @@ public class RedisKeys { * @return */ public static String getRoleOpeScopesKey(String roleId, String opeKey) { - return rootPrefix.concat("gov:access:role:opescopes:").concat(roleId).concat(opeKey); + return rootPrefix.concat("gov:access:role:opescopes:").concat(roleId).concat(":").concat(opeKey); + } + + /** + * 角色ID对应的权限配置 + * @param roleId + * @return + */ + public static String getRoleAccessSettingKey(String roleId) { + return rootPrefix.concat("gov:access:role:accesssettings:").concat(roleId); } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java index 49d6cb15a3..de94567fb6 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java @@ -62,7 +62,7 @@ public class GovTokenDto extends BaseTokenDto implements Serializable { /** * 部门id列表 */ - private List deptIdList; + private Set deptIdList; /** * 功能权限列表,实际上是gov_staff => staff_role => role_operation查询到的operationKey diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java index 191314af0a..a35af017c9 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java @@ -51,4 +51,9 @@ public class StaffPermCacheFormDTO { */ private Set roleIdList; + /** + * 当前所在网格id + */ + private String gridId; + } diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleAccessSettingResultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleAccessSettingResultDTO.java new file mode 100644 index 0000000000..7330f3b425 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleAccessSettingResultDTO.java @@ -0,0 +1,14 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class RoleAccessSettingResultDTO { + + private String settingKey; + private String id; + private String settingName; + private String settingValue; + private String roleId; + +} diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java index ce24cf9501..d19ed3ff27 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java @@ -18,6 +18,11 @@ public class StaffPermCacheResultDTO { */ private Set roleIdList; + /** + * 部门id列表 + */ + private Set deptIdList; + /** * 组织ID */ diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java index e34df14a06..2f9bdcb567 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.OperationScopeDTO; import com.epmet.dto.form.OperationScopeFormDTO; import com.epmet.dto.form.StaffPermCacheFormDTO; +import com.epmet.dto.result.RoleAccessSettingResultDTO; import com.epmet.dto.result.RoleOpeScopeResultDTO; import com.epmet.dto.result.StaffPermCacheResultDTO; import com.epmet.entity.OperationScopeEntity; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -32,7 +34,7 @@ public class AccessController { private AccessService accessService; /** - * 更新工作人员权限缓存 + * 更新工作人员权限缓存(前端查询权限时候gov-mine会调用此处) * @param staffPermCacheFormDTO * @return */ @@ -45,12 +47,13 @@ public class AccessController { Set permissions = staffPermCacheFormDTO.getPermissions(); Set roleIdList = staffPermCacheFormDTO.getRoleIdList(); String orgId = staffPermCacheFormDTO.getOrgIdPath(); - accessService.updatePermissionCache(staffId, app, client, permissions, roleIdList, orgId); + String gridId = staffPermCacheFormDTO.getGridId(); + accessService.updatePermissionCache(staffId, app, client, permissions, roleIdList, orgId, gridId); return new Result(); } /** - * 查询用户当前权限列表(DataFilterAspect中用到) + * 从缓存中查询用户当前权限列表(DataFilterAspect中用到) * @return */ @PostMapping("getcurrpermissions") @@ -64,6 +67,7 @@ public class AccessController { resultDTO.setRoleIdList(govTokenDto.getRoleIdList()); resultDTO.setOrgIdPath(govTokenDto.getOrgIdPath()); resultDTO.setGridId(govTokenDto.getGridId()); + resultDTO.setDeptIdList(govTokenDto.getDeptIdList()); } return new Result().ok(resultDTO); } @@ -78,4 +82,15 @@ public class AccessController { Set scopes = accessService.listOperationScopesByRoleId(operationScopeFormDTO.getRoleId(), operationScopeFormDTO.getOperationKey()); return new Result>().ok(scopes); } + + /** + * 查询角色的权限相关配置 + * @param roleId + * @return + */ + @PostMapping("/role/{roleId}/accesssettings") + public Result> listAccessSettings(@PathVariable("roleId") String roleId) { + Map settings = accessService.listAccessSettings(roleId); + return new Result>().ok(settings); + } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleAccessSettingDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleAccessSettingDao.java new file mode 100644 index 0000000000..42acf285e0 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleAccessSettingDao.java @@ -0,0 +1,37 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.RoleAccessSettingResultDTO; +import com.epmet.entity.RoleAccessSettingEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 权限配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-26 + */ +@Mapper +public interface RoleAccessSettingDao extends BaseDao { + + List listRoleAccessSettingsByRoleId(String roleId); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleAccessSettingEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleAccessSettingEntity.java new file mode 100644 index 0000000000..bbb8d650bf --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleAccessSettingEntity.java @@ -0,0 +1,65 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 权限配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-26 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("role_access_setting") +public class RoleAccessSettingEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 配置KEY + */ + private String settingKey; + + /** + * 配置name + */ + private String settingName; + /** + * 配置值 + */ + private String settingValue; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作简介 + */ + private String brief; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleAccessSettingRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleAccessSettingRedis.java new file mode 100644 index 0000000000..02efbb9850 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleAccessSettingRedis.java @@ -0,0 +1,37 @@ +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.result.RoleAccessSettingResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; + +@Component +public class RoleAccessSettingRedis { + + @Autowired + private RedisUtils redisUtils; + + public void set(Map settings, String roleId) { + String roleAccessSettingKey = RedisKeys.getRoleAccessSettingKey(roleId); + redisUtils.hMSet(roleAccessSettingKey, settings); + } + + public Map get(String roleId) { + String roleAccessSettingKey = RedisKeys.getRoleAccessSettingKey(roleId); + Map s = redisUtils.hGetAll(roleAccessSettingKey); + Map settings = new HashMap<>(); + s.forEach((s1, o) -> { + if (o != null) { + settings.put(s1, String.valueOf(o)); + } + }); + return settings; + } + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java index df16e1e9df..dcda2ebe7e 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java @@ -1,10 +1,12 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.dto.result.RoleAccessSettingResultDTO; import com.epmet.dto.result.RoleOpeScopeResultDTO; import com.epmet.entity.OperationScopeEntity; import java.util.List; +import java.util.Map; import java.util.Set; public interface AccessService { @@ -13,7 +15,7 @@ public interface AccessService { * @param staffId * @param permissions */ - void updatePermissionCache(String staffId, String app, String client, Set permissions, Set roleIdList, String orgIdPath); + void updatePermissionCache(String staffId, String app, String client, Set permissions, Set roleIdList, String orgIdPath, String gridId); /** * 查询用户当前权限列表 @@ -28,4 +30,11 @@ public interface AccessService { * @return */ Set listOperationScopesByRoleId(String roleId, String operationKey); + + /** + * 查询角色的权限相关配置 + * @param roleId + * @return + */ + Map listAccessSettings(String roleId); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index 34e458ec6a..0249885536 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -4,7 +4,10 @@ import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.dao.OperationScopeDao; +import com.epmet.dao.RoleAccessSettingDao; +import com.epmet.dto.result.RoleAccessSettingResultDTO; import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.redis.RoleAccessSettingRedis; import com.epmet.redis.RoleOpeScopeRedis; import com.epmet.service.AccessService; import org.slf4j.Logger; @@ -13,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.Set; +import java.util.*; @Service public class AccessServiceImpl implements AccessService { @@ -26,16 +29,24 @@ public class AccessServiceImpl implements AccessService { @Autowired private OperationScopeDao operationScopeDao; + @Autowired + private RoleAccessSettingDao roleAccessSettingDao; + @Autowired private RoleOpeScopeRedis roleOpeScopeRedis; + @Autowired + private RoleAccessSettingRedis roleAccessSettingRedis; + + /** * 更新权限缓存 * @param staffId * @param permissions */ @Override - public void updatePermissionCache(String staffId, String app, String client, Set permissions, Set roleIdList, String orgIdPath) { + public void updatePermissionCache(String staffId, String app, String client, Set permissions, Set roleIdList, + String orgIdPath, String gridId) { GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); if (govTokenDto == null) { logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId); @@ -45,6 +56,7 @@ public class AccessServiceImpl implements AccessService { govTokenDto.setPermissions(permissions); govTokenDto.setRoleIdList(roleIdList); govTokenDto.setOrgIdPath(orgIdPath); + govTokenDto.setGridId(gridId); // 将新的TokenDto更新到redis中 long expire = cpUserDetailRedis.getExpire(app, client, staffId); @@ -77,4 +89,26 @@ public class AccessServiceImpl implements AccessService { } return scopes; } + + /** + * 查询角色的权限相关配置 + * @param roleId + * @return + */ + @Override + public Map listAccessSettings(String roleId) { + Map settings = roleAccessSettingRedis.get(roleId); + //if (CollectionUtils.isEmpty(settings)) { + // // 数据库查出来,放入redis一份。此处为权限过滤器用到,存在缓存穿透,所以不采用这种方式。 + // // 改用为:变动setting的时候手动更新缓存的方式 + // List settingsDB = roleAccessSettingDao.listRoleAccessSettingsByRoleId(roleId); + // if (!CollectionUtils.isEmpty(settingsDB)) { + // roleAccessSettingRedis.set(settingsDB, roleId); + // } + //} + if (settings == null) { + settings = new HashMap<>(); + } + return settings; + } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql b/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql index 93d8c2a148..62e72134a0 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql @@ -5,6 +5,8 @@ -- SET NAMES utf8mb4; -- #SET FOREIGN_KEY_CHECKS = 0; +CREATE DATABASE `epmet_gov_access` DEFAULT CHARACTER SET utf8mb4; + -- DROP TABLE IF EXISTS `permission_scope`; CREATE TABLE `operation_scope` ( `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'id', @@ -73,4 +75,22 @@ CREATE TABLE `role_scope` ( PRIMARY KEY (`ID`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色能操作哪些范围' ROW_FORMAT = Dynamic; +-- 2020.04.26 wxz -- + +CREATE TABLE `role_access_setting` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `SETTING_KEY` varchar(30) NOT NULL COMMENT '配置KEY', + `SETTING_NAME` varchar(30) NOT NULL COMMENT '配置name', + `SETTING_VALUE` varchar(30) NOT NULL COMMENT '配置值', + `ROLE_ID` varchar(64) DEFAULT NULL COMMENT '角色ID', + `BRIEF` varchar(255) DEFAULT NULL COMMENT '操作简介', + `DEL_FLAG` tinyint(1) DEFAULT NULL, + `REVISION` int(10) DEFAULT NULL, + `CREATED_BY` varchar(64) DEFAULT NULL, + `CREATED_TIME` datetime DEFAULT NULL, + `UPDATED_BY` varchar(64) DEFAULT NULL, + `UPDATED_TIME` datetime DEFAULT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限配置' + -- SET FOREIGN_KEY_CHECKS = 1; diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleAccessSettingDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleAccessSettingDao.xml new file mode 100644 index 0000000000..cc31938799 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleAccessSettingDao.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/test/java/com/epmet/test/govaccess/AccessSettingTest.java b/epmet-module/gov-access/gov-access-server/src/test/java/com/epmet/test/govaccess/AccessSettingTest.java new file mode 100644 index 0000000000..6ac8bf1547 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/test/java/com/epmet/test/govaccess/AccessSettingTest.java @@ -0,0 +1,38 @@ +package com.epmet.test.govaccess; + +import com.epmet.dao.RoleAccessSettingDao; +import com.epmet.dto.result.RoleAccessSettingResultDTO; +import com.epmet.redis.RoleAccessSettingRedis; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class AccessSettingTest { + + @Autowired + private RoleAccessSettingDao roleAccessSettingDao; + + @Autowired + private RoleAccessSettingRedis roleAccessSettingRedis; + + @Test + public void addAccessSettings2Redis() { + List settings = roleAccessSettingDao.listRoleAccessSettingsByRoleId("1"); + HashMap objectObjectHashMap = new HashMap<>(); + settings.forEach(s -> { + objectObjectHashMap.put(s.getSettingKey(), s.getSettingValue()); + }); + roleAccessSettingRedis.set(objectObjectHashMap, "1"); + Map map = roleAccessSettingRedis.get("1"); + System.out.println(map); + } + +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java index 7cde40d997..67ace77271 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java @@ -96,4 +96,5 @@ public class StaffAgencyController { return staffAgencyService.getLatestGrid(latestGridFormDTO); } + } \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 287da51fec..87a64b8fae 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -18,11 +18,14 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; +import java.util.List; + /** * @Description * @Author sun */ +//, url = "localhost:8087" @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallback.class) public interface EpmetUserFeignClient { /** diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 8c03d28764..45f0647c4b 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -19,6 +19,7 @@ import java.util.List; * @Description * @Author sun */ +//, url = "localhost:8092" @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) public interface GovOrgFeignClient { diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java index d76e2e2f34..13340d53e1 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -38,27 +38,25 @@ public class AccessServiceImpl implements AccessService { @Autowired private GovOrgFeignClient govOrgFeignClient; - @Autowired - private CpUserDetailRedis cpUserDetailRedis; - - @Override - public Set listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId) { + public List queryGovStaffRoles(String staffId, String orgId) { List roleDTOS = new ArrayList<>(); - // 查询机关单位权限 StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); formDTO.setStaffId(staffId); - formDTO.setOrgId(agencyId); - Result> agencyResult = userFeignClient.getRolesOfStaff(formDTO); - if (!CollectionUtils.isEmpty(agencyResult.getData())) { - roleDTOS.addAll(agencyResult.getData()); - } - // 查询网格权限 - formDTO.setStaffId(staffId); - formDTO.setOrgId(gridId); + formDTO.setOrgId(orgId); Result> gridResult = userFeignClient.getRolesOfStaff(formDTO); if (!CollectionUtils.isEmpty(gridResult.getData())) { roleDTOS.addAll(gridResult.getData()); } + return roleDTOS; + } + + @Override + public Set listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId) { + List roleDTOS = new ArrayList<>(); + // 查询机关单位中的角色 + roleDTOS.addAll(queryGovStaffRoles(staffId, agencyId)); + // 查询网格中的角色 + roleDTOS.addAll(queryGovStaffRoles(staffId, gridId)); // 拼装操作key列表 Set opeKeys = new HashSet<>(); @@ -86,7 +84,7 @@ public class AccessServiceImpl implements AccessService { // 查询该直属机关的orgIdPath Result agencyById = govOrgFeignClient.getAgencyById(agencyId); - if (agencyById.getCode() != 0 || agencyById.getData() == null) { + if (!agencyById.success() || agencyById.getData() == null) { logger.error("根据当前机构id[{}]查询pids失败:{}", agencyId, agencyById.getMsg()); throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); } @@ -98,6 +96,7 @@ public class AccessServiceImpl implements AccessService { staffPermCacheFormDTO.setStaffId(staffId); staffPermCacheFormDTO.setPermissions(opeKeys); staffPermCacheFormDTO.setRoleIdList(roleIds); + staffPermCacheFormDTO.setGridId(gridId); // 拼接orgIdPath staffPermCacheFormDTO.setOrgIdPath(String.format("%s:%s", agencyById.getData().getPids(), agencyId)); govAccessFeignClient.updatePermissionCache(staffPermCacheFormDTO); diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonAgencyIdFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonAgencyIdFormDTO.java new file mode 100644 index 0000000000..df06539bb4 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonAgencyIdFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @ClassName CommonAgencyIdFormDTO + * @Author wangc + * @date 2020.04.23 14:37 + */ +@Data +public class CommonAgencyIdFormDTO implements Serializable { + private static final long serialVersionUID = -4634394162176710898L; + + /** + * 机构Id + * */ + @NotBlank(message = "机构Id不可为空") + private String agencyId; + + /** + * 用户Id(政府工作人员) + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonDepartmentFormDTO.java new file mode 100644 index 0000000000..d821ba7ede --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonDepartmentFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @ClassName CommonDepartmentFormDTO + * @Author wangc + * @date 2020.04.26 16:21 + */ +@Data +public class CommonDepartmentFormDTO implements Serializable { + + private static final long serialVersionUID = -7557299771900280575L; + + /** + * 部门Id + * */ + @NotBlank(message = "部门Id不能为空") + private String departmentId; + + /** + * 用户Id + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonDepartmentStaffInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonDepartmentStaffInfoFormDTO.java new file mode 100644 index 0000000000..9b08da473e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonDepartmentStaffInfoFormDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @ClassName CommonDepartmentStaffInfoFormDTO + * @Author wangc + * @date 2020.04.26 16:52 + */ +@Data +public class CommonDepartmentStaffInfoFormDTO implements Serializable { + private static final long serialVersionUID = 2895745833519899428L; + + /** + * 部门Id + * */ + @NotBlank(message = "部门Id") + private String departmentId; + + /** + * 工作人员Id + * */ + @NotBlank(message = "工作人员Id不能为空") + private String staffId; + + /** + * 用户Id + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridIdFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridIdFormDTO.java new file mode 100644 index 0000000000..936aa4312b --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridIdFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @ClassName CommonGridIdFormDTO + * @Author wangc + * @date 2020.04.24 14:17 + */ +@Data +public class CommonGridIdFormDTO implements Serializable { + private static final long serialVersionUID = 2496019865436084805L; + + /** + * 网格Id + * */ + @NotBlank(message = "网格Id不能为空") + private String gridId; + + /** + * 用户Id + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridStaffInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridStaffInfoFormDTO.java new file mode 100644 index 0000000000..8307f12258 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridStaffInfoFormDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 通用的网格工作人员入参DTO 包含网格Id和用户Id + * @ClassName CommonGridStaffInfoFormDTO + * @Author wangc + * @date 2020.04.26 09:38 + */ +@Data +public class CommonGridStaffInfoFormDTO implements Serializable{ + private static final long serialVersionUID = 6345334778886091374L; + + /** + * 网格Id + * */ + @NotBlank(message = "网格Id不能为空") + private String gridId; + + /** + * 员工Id + * */ + @NotBlank(message = "工作人员Id不能为空") + private String staffId; + + /** + * 当前操作人 + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridStaffListFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridStaffListFromDTO.java new file mode 100644 index 0000000000..6342518664 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CommonGridStaffListFromDTO.java @@ -0,0 +1,38 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 通用的网格工作人员列表入参DTO 包含网格Id和用户Id集合 + * @ClassName CommonGridStaffListFromDTO + * @Author wangc + * @date 2020.04.26 09:38 + */ +@Data +public class CommonGridStaffListFromDTO implements Serializable{ + + private static final long serialVersionUID = -5753128515827497700L; + + /** + * 网格Id + * */ + @NotBlank(message = "网格Id不能为空") + private String gridId; + + /** + * 员工Id列表 + * */ + @NotBlank(message = "工作人员Id不能为空") + private List selectedList; + + /** + * 当前操作人 + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerGridFormDTO.java index c3c237e83a..c34d3c5870 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerGridFormDTO.java @@ -38,5 +38,4 @@ public class CustomerGridFormDTO implements Serializable { @NotBlank(message = "网格ID不能为空") private String gridId; - } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java index e4a410120e..6cc332a6e7 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java @@ -45,4 +45,9 @@ public class EditAgencyFormDTO implements Serializable { @NotBlank(message = "机关组织名称不能为空") private String agencyName; + /** + * token中用户Id + */ + private String userId; + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java index e372d86d8d..055fc8d11c 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java @@ -57,11 +57,6 @@ public class AgencysResultDTO implements Serializable { */ private Integer areaCode; - /** - * 国家 - */ - private String country; - /** * 省份 */ @@ -72,6 +67,11 @@ public class AgencysResultDTO implements Serializable { */ private String city; + /** + * 区县 + */ + private String district; + /** * 本机关的所有上级机关 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java index d36a4222ee..c4b87cc743 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java @@ -33,6 +33,11 @@ public class DepartmentDetailResultDTO implements Serializable { private static final long serialVersionUID = 1L; + /** + * 组织机构Id + */ + private String agencyId; + /** * 部门Id */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridBaseInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridBaseInfoResultDTO.java new file mode 100644 index 0000000000..df2bc63f60 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridBaseInfoResultDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 网格基础信息DTO + * @ClassName GridBaseInfoResultDTO + * @Author wangc + * @date 2020.04.23 14:11 + */ +@Data +public class GridBaseInfoResultDTO implements Serializable { + + private static final long serialVersionUID = -5034984869469273329L; + + /** + * 网格Id + * */ + private String gridId; + + /** + * 网格名称 + * */ + private String gridName; + + /** + * 网格人数 + * */ + private Integer totalUser; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridListInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridListInfoResultDTO.java new file mode 100644 index 0000000000..110ecf7cf4 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridListInfoResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 网格列表信息 + * @ClassName GridListInfoResultDTO + * @Author wangc + * @date 2020.04.23 14:21 + */ +@Data +@AllArgsConstructor +public class GridListInfoResultDTO implements Serializable { + private static final long serialVersionUID = -5513674274570559283L; + + /** + * 网格总数 + * */ + private Integer gridCount; + + /** + * 网格信息列表 + * */ + private List gridList; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java index 7f192ee942..6f554aa48c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -68,6 +68,7 @@ public class AgencyController { */ @PostMapping("editagency") public Result editAgency(@LoginUser TokenDto tokenDTO, @RequestBody EditAgencyFormDTO formDTO) { + formDTO.setUserId(tokenDTO.getUserId()); ValidatorUtils.validateEntity(formDTO); return agencyService.editAgency(formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java index 3bfc887aec..a92d2d8826 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java @@ -17,7 +17,9 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; @@ -27,6 +29,9 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.form.CommonGridIdFormDTO; +import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.dto.result.LatestCustomerResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.excel.CustomerStaffAgencyExcel; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java index b55e48a3e0..0e2058eeb7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -5,16 +5,12 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.*; -import com.epmet.dto.result.AddDepartmentResultDTO; -import com.epmet.dto.result.DepartmentDetailResultDTO; -import com.epmet.dto.result.DepartmentInAgencyResultDTO; -import com.epmet.dto.result.DepartmentListResultDTO; +import com.epmet.dto.result.*; +import com.epmet.service.CustomerStaffAgencyService; +import com.epmet.service.CustomerStaffAgencyService; import com.epmet.service.DepartmentService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -29,6 +25,8 @@ public class DepartmentController { @Autowired private DepartmentService departmentService; + @Autowired + private CustomerStaffAgencyService customerStaffAgencyService; /** * 添加部门人员 @@ -112,4 +110,43 @@ public class DepartmentController { ValidatorUtils.validateEntity(formDTO); return departmentService.departmentList(formDTO); } + + /** + * @Description 查询加入部门的可选人员列表 + * @Param TokenDto + * @Param CommonDepartmentFormDTO + * @return Result> + * @Author wangc + * @Date 2020.04.26 16:47 + **/ + @PostMapping("selectablestaffs") + public Result> selectableStaffs(@LoginUser TokenDto tokenDto,@RequestBody CommonDepartmentFormDTO departmentFormDTO){ + departmentFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(departmentFormDTO); + return customerStaffAgencyService.getSelectableDeptStaffs(departmentFormDTO); + } + + /** + * @Description 移除部门人员 + * @Param TokenDto + * @Param CommonDepartmentStaffInfoFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 17:09 + **/ + public Result removeStaff(@LoginUser TokenDto tokenDto,@RequestBody CommonDepartmentStaffInfoFormDTO departmentStaffInfoFormDTO){ + departmentStaffInfoFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(departmentStaffInfoFormDTO); + return departmentService.removeStaff(departmentStaffInfoFormDTO); + } + + /** + * 根据StaffId查询所属部门列表 + * @return + */ + @PostMapping("staff/{staffId}/departmentlist") + public Result> getDepartmentListByStaffId(@PathVariable("staffId") String staffId) { + List deptList = departmentService.listDepartmentListByStaffId(staffId); + return new Result>().ok(deptList); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java index f3b19c5027..bc751b6e88 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -3,19 +3,23 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.AddGridFormDTO; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.form.DeleteGridFormDTO; -import com.epmet.dto.form.EditGridFormDTO; +import com.epmet.dto.form.*; +import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.result.AddGridResultDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; +import com.epmet.dto.result.GridBaseInfoResultDTO; import com.epmet.dto.result.GridDetailResultDTO; +import com.epmet.dto.result.GridListInfoResultDTO; import com.epmet.service.CustomerGridService; +import com.epmet.service.CustomerStaffAgencyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * @Auther zxc * @Create 2020-04-23 9:50 @@ -26,6 +30,8 @@ public class GridController { @Autowired private CustomerGridService customerGridService; + @Autowired + private CustomerStaffAgencyService customerStaffAgencyService; /** * 获取网格详情 @@ -64,4 +70,75 @@ public class GridController { return customerGridService.deleteGrid(tokenDto,deleteGridFormDTO); } + /** + * @Description 查找指定机构下的网格列表 + * @Param CommonAgencyIdFormDTO -> agencyId + * @return Result + * @Author wangc + * @Date 2020.04.23 14:45 + **/ + @PostMapping("gridlist") + public Result gridList(@LoginUser TokenDto tokenDto,@RequestBody CommonAgencyIdFormDTO agencyFormDTO){ + agencyFormDTO.setAgencyId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(agencyFormDTO); + return customerGridService.getGridListByAgency(agencyFormDTO); + } + + /** + * @Description 查找指定机构下的全部网格列表 + * @Param CommonAgencyIdFormDTO -> agencyId + * @return Result + * @Author wangc + * @Date 2020.04.23 14:45 + **/ + @PostMapping("allgrids") + public Result> allGrids(@LoginUser TokenDto tokenDto, @RequestBody CommonAgencyIdFormDTO agencyFormDTO){ + agencyFormDTO.setAgencyId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(agencyFormDTO); + return customerGridService.getAllGridsByAgency(agencyFormDTO); + } + + /** + * @Description 在给网格添加工作人员时,查询当前机关下没有加入到此网格下的工作人员,禁用的也不能选(不显示) + * @Param CommonGridIdFormDTO + * @return Result> + * @Author wangc + * @Date 2020.04.24 14:14 + **/ + @PostMapping("selectablestaffs") + public Result> selectableStaffs(@LoginUser TokenDto tokenDto, @RequestBody CommonGridIdFormDTO gridIdFormDTO){ + gridIdFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(gridIdFormDTO); + return customerStaffAgencyService.getSelectableStaffs(gridIdFormDTO); + } + + /** + * @Description 添加网格工作人员 批量 + * @Param tokenDto + * @Param CommonGridStaffListFromDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 15:36 + **/ + @PostMapping("addgridstaffs") + public Result addGridStaffs(@LoginUser TokenDto tokenDto, @RequestBody CommonGridStaffListFromDTO commonGridStaffListFromDTO){ + commonGridStaffListFromDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(tokenDto); + return customerGridService.addGridStaffs(commonGridStaffListFromDTO); + } + + /** + * @Description 移除网格工作人员 + * @Param tokenDto + * @Param CommonGridStaffInfoFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 15:36 + **/ + @PostMapping("removegridstaff") + public Result removeGridStaff(@LoginUser TokenDto tokenDto, @RequestBody CommonGridStaffInfoFormDTO commonGridStaffInfoFormDTO){ + commonGridStaffInfoFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(tokenDto); + return customerGridService.removeGridStaff(commonGridStaffInfoFormDTO); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 8a4c14548b..ba4bde9b07 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.result.AgencyListResultDTO; import com.epmet.dto.result.ParentListResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; @@ -68,4 +69,12 @@ public interface CustomerAgencyDao extends BaseDao { * @Description 获取组织列表 **/ List selectAgencyList(@Param("pId") String pId); + + /** + * @param customerAgencyDTO + * @return + * @Author sun + * @Description 查询当前组织的所有下级组织列表 + **/ + List selectFindList(CustomerAgencyDTO customerAgencyDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java index b7569a1396..5ecfdff97f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java @@ -49,4 +49,11 @@ public interface CustomerDepartmentDao extends BaseDao * @Description 根据当前机关Id查询该机关下的直属部门列表 **/ List selectDepartmentList(@Param("agencyId") String agencyId); + + /** + * 根据StaffId查询所属部门列表 + * @param staffId + * @return + */ + List listDepartmentListByStaffId(@Param("staffId") String staffId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 11fb36a5fc..aa3e8ddf5e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -29,6 +29,7 @@ import com.epmet.dto.result.AddGridResultDTO; import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.dto.result.GridDetailResultDTO; +import com.epmet.dto.result.GridBaseInfoResultDTO; import com.epmet.entity.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -133,4 +134,22 @@ public interface CustomerGridDao extends BaseDao { List selectUserIdByGrid(@Param("gridId")String gridId); + + /** + * @Description 得到当前机构的网格总数 + * @Param agencyId(String) 对应CUSTOMER_GRID中的PID字段 + * @return int + * @Author wangc + * @Date 2020.04.23 15:05 + **/ + int selectGridCountByAgencyId(@Param("agencyId") String agencyId); + + /** + * @Description 得到当前机构的网格详情列表 + * @Param agencyId(String) 对应CUSTOMER_GRID中的PID字段 + * @return List -> GridBaseInfoResultDTO :: getGridId :: getGridName :: getTotalUser + * @Author wangc + * @Date 2020.04.23 15:30 + **/ + List selectGridListByAgencyId(@Param("agencyId")String agencyId,@Param("pageSize")Integer pageSize); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java index 533c97b2a5..9de920b942 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java @@ -19,8 +19,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.entity.CustomerStaffAgencyEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; import java.util.List; @@ -46,5 +50,22 @@ public interface CustomerStaffAgencyDao extends BaseDao selectCustomerStaffAgencyList(String agencyId); - + + /** + * @Description 返回给定网格Id所属的机构下未加入该网格的工作人员Id(禁用未知) + * @Param gridId (String) + * @return List UserId列表 + * @Author wangc + * @Date 2020.04.24 14:01 + **/ + List getSelectableStaffsForGrid(@Param("gridId") String gridId); + + /** + * @Description 查询当前网格所属机构下的不在此部门的工作人员Id(禁用未知) + * @Param gridId (String) + * @return List UserId列表 + * @Author wangc + * @Date 2020.04.26 16:33 + **/ + List getSelectableStaffsForDept(@Param("departmentId") String departmentId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java index dc61c9039f..c0e8691363 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java @@ -19,9 +19,15 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.form.LatestGridFormDTO; import com.epmet.entity.CustomerStaffGridEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * 网格人员关系表 @@ -41,4 +47,22 @@ public interface CustomerStaffGridDao extends BaseDao { **/ CustomerGridDTO selectStaffGridOrderByGridName(LatestGridFormDTO latestGridFormDTO); + /** + * @Description 校验用户是否已加入当前网格 + * @Param userIds + * @Param gridId + * @return Set + * @Author wangc + * @Date 2020.04.26 14:08 + **/ + Set distinctGridStaffs(@Param("userIds")List userIds, @Param("gridId")String gridId); + + /** + * @Description 批量插入网格工作人员 + * @Param List + * @return + * @Author wangc + * @Date 2020.04.26 14:57 + **/ + void insertBatch(List list); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index d8a404d782..9f9638ae34 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -15,6 +15,11 @@ import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -142,4 +147,23 @@ public interface EpmetUserFeignClient { @PostMapping("/epmetuser/customerstaff/selectcustomeridbyuserid") Result> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO); + /** + * @Description 通过userId列表查询未被禁用的用户信息 + * @Param CommonUserIdListFormDTO :: getUserIdList + * @return Result> + * @Author wangc + * @Date 2020.04.24 15:44 + **/ + @PostMapping("/epmetuser/customerstaff/enabestaffmsglist") + Result> enableStaffMsgList(CommonUserIdListFormDTO userIdList); + + /** + * @Description 查询一个员工在指定客户下的角色 + * @Param CommonUserFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 13:08 + **/ + @PostMapping("/epmetuser/staffrole/getcustomerstaffroles") + Result getCustomerStaffRoles(CommonUserFormDTO commonUserFormDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 20255d3962..639d83d1b5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -16,6 +16,11 @@ import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; @@ -91,4 +96,14 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectCustomerIdByUserId", addDepartmentStaffFormDTO); } + + @Override + public Result> enableStaffMsgList(CommonUserIdListFormDTO userIdList) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "enableStaffMsgList", userIdList); + } + + @Override + public Result getCustomerStaffRoles(CommonUserFormDTO commonUserFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffRoles", commonUserFormDTO); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index 41390fe5e5..45d3572e74 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -25,9 +25,10 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.AddGridResultDTO; -import com.epmet.dto.result.CustomerGridByUserIdResultDTO; -import com.epmet.dto.result.CustomerGridForStrangerResultDTO; -import com.epmet.dto.result.GridDetailResultDTO; +import com.epmet.dto.form.CommonAgencyIdFormDTO; +import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerGridEntity; import org.springframework.web.bind.annotation.RequestBody; @@ -153,4 +154,41 @@ public interface CustomerGridService extends BaseService { * @return */ Result deleteGrid(TokenDto tokenDto,DeleteGridFormDTO deleteGridFormDTO); + + /** + * @Description 查找指定机构下的网格列表 对应接口:/gov/org/grid/gridlist + * @Param CommonAgencyIdFormDTO -> agencyId + * @return Result + * @Author wangc + * @Date 2020.04.23 14:45 + **/ + Result getGridListByAgency(CommonAgencyIdFormDTO agencyFormDTO); + + /** + * @Description 查找指定机构下的全部网格列表 对应接口:/gov/org/grid/allgrids + * @Param CommonAgencyIdFormDTO -> agencyId + * @return Result> + * @Author wangc + * @Date 2020.04.24 17:16 + **/ + Result> getAllGridsByAgency(CommonAgencyIdFormDTO agencyFormDTO); + + /** + * @Description 移除网格工作人员 + * @Param CommonGridStaffInfoFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 09:48 + **/ + Result removeGridStaff(CommonGridStaffInfoFormDTO staffInfoFormDTO); + + /** + * @Description 批量添加网格工作人员 + * @Param CommonGridStaffListFromDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 09:50 + **/ + Result addGridStaffs(CommonGridStaffListFromDTO staffListFormDTO); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java index c713dbde52..b6b5bd86b0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java @@ -21,7 +21,10 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.form.CommonDepartmentFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.form.CommonGridIdFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.dto.result.LatestCustomerResultDTO; import com.epmet.entity.CustomerStaffAgencyEntity; @@ -112,4 +115,22 @@ public interface CustomerStaffAgencyService extends BaseService> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO); + + /** + * @Description 获取添加网格成员的可选人员列表 + * @Param CommonGridIdFormDTO + * @return com.epmet.dto.result.CommonStaffInfoResultDTO[epmet-user-client] + * @Author wangc + * @Date 2020.04.23 16:15 + **/ + Result> getSelectableStaffs(CommonGridIdFormDTO gridIdFormDTO); + + /** + * @Description 获取添加部门成员的可选人员列表 + * @Param CommonDepartmentFormDTO + * @return com.epmet.dto.result.CommonStaffInfoResultDTO[epmet-user-client] + * @Author wangc + * @Date 2020.04.26 16:37 + **/ + Result> getSelectableDeptStaffs(CommonDepartmentFormDTO departmentFormDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java index 1bc16f7299..2f9adf3d59 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java @@ -21,7 +21,9 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.entity.CustomerStaffGridEntity; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java index 2d49860de2..261b43b5e5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java @@ -86,4 +86,20 @@ public interface DepartmentService { * @return */ Result addDepartmentStaff(TokenDto tokenDto,AddDepartmentStaffFormDTO addDepartmentStaffFormDTO); + + /** + * @Description 部门人员移除 + * @Param CommonDepartmentStaffInfoFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 16:57 + **/ + Result removeStaff(CommonDepartmentStaffInfoFormDTO departmentStaffInfoFormDTO); + + /** + * 根据StaffId查询所属部门列表 + * @param staffId + * @return + */ + List listDepartmentListByStaffId(String staffId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index f1901d64cf..ea5cee6df4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -24,10 +24,12 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; import com.epmet.dao.CustomerAgencyDao; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.service.AgencyService; +import com.epmet.service.CustomerAgencyService; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,8 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.List; +import java.util.*; /** * 机关单位信息 @@ -49,6 +50,8 @@ public class AgencyServiceImpl implements AgencyService { private static final Logger log = LoggerFactory.getLogger(AgencyServiceImpl.class); @Autowired private CustomerAgencyDao customerAgencyDao; + @Autowired + private CustomerAgencyService customerAgencyService; /** * @param formDTO @@ -103,10 +106,46 @@ public class AgencyServiceImpl implements AgencyService { CustomerAgencyEntity entity = new CustomerAgencyEntity(); entity.setId(formDTO.getAgencyId()); entity.setOrganizationName(formDTO.getAgencyName()); + //1:更新当前组织信息 if (customerAgencyDao.updateById(entity) < NumConstant.ONE) { log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); } + //2:查询当前组织的所有下级组织列表(查询pids字段值包含该组织id的数据) + CustomerAgencyDTO agencyDTO = new CustomerAgencyDTO(); + agencyDTO.setPids(formDTO.getAgencyId()); + List agencyList = customerAgencyDao.selectFindList(agencyDTO); + if (null == agencyList || agencyList.size() < NumConstant.ONE) { + return result; + } + //3:循环组织列表,查询每一个组织的所有上级组织重新拼接所有上级名称(allParentName)字段值 + List editList = new ArrayList<>(); + Date date = new Date(); + agencyList.forEach(agency->{ + CustomerAgencyEntity customerAgencyEntity = new CustomerAgencyEntity(); + //3-1:查询当前组织的所有上级组织 + List listStr = Arrays.asList(agency.getPids().split(":")); + List parentList = customerAgencyDao.selectPAgencyById(listStr); + //3-2:重新拼接当前组织的所有上级名称字段值,将组织Id和拼好的值存入集合 + StringBuffer allParentName = new StringBuffer(); + parentList.forEach(parents->{ + if(StringUtils.isBlank(allParentName)){ + allParentName.append(parents.getName()); + }else { + allParentName.append("-").append(parents.getName()); + } + }); + customerAgencyEntity.setId(agency.getId()); + customerAgencyEntity.setAllParentName(allParentName.toString()); + customerAgencyEntity.setUpdatedBy(formDTO.getUserId()); + customerAgencyEntity.setUpdatedTime(date); + editList.add(customerAgencyEntity); + }); + //4:批量更新因一个组织名称变动而引起的其他组织字段值的变动 + if (!customerAgencyService.updateBatchById(editList)) { + log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); + throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); + } return result; } @@ -151,9 +190,11 @@ public class AgencyServiceImpl implements AgencyService { @Override public Result agencyDetail(AgencydetailFormDTO formDTO) { AgencysResultDTO agencysResultDTO = new AgencysResultDTO(); + List parentList = new ArrayList<>(); //1:查询本机关详细信息 CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId()); if (null == entity) { + agencysResultDTO.setParentList(parentList); return new Result().ok(agencysResultDTO); } agencysResultDTO = ConvertUtils.sourceToTarget(entity, AgencysResultDTO.class); @@ -161,10 +202,11 @@ public class AgencyServiceImpl implements AgencyService { agencysResultDTO.setAgencyName(entity.getOrganizationName()); //2:查询本机关的所有上级机关,按自上而下层级顺序 if (null == entity.getPids()) { + agencysResultDTO.setParentList(parentList); return new Result().ok(agencysResultDTO); } List listStr = Arrays.asList(entity.getPids().split(":")); - List parentList = customerAgencyDao.selectPAgencyById(listStr); + parentList = customerAgencyDao.selectPAgencyById(listStr); agencysResultDTO.setParentList(parentList); return new Result().ok(agencysResultDTO); } @@ -180,7 +222,7 @@ public class AgencyServiceImpl implements AgencyService { SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO(); //1:根据当前机关Id查询直属下一级机关列表 List agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId()); - subAgencyResultDTO.setAgencyList(agencyList); + subAgencyResultDTO.setAgencyList(null == agencyList ? new ArrayList() : agencyList); //2:统计下一级机关数 subAgencyResultDTO.setSubAgencyCount(agencyList.size()); return new Result().ok(subAgencyResultDTO); @@ -195,7 +237,7 @@ public class AgencyServiceImpl implements AgencyService { @Override public Result> agencyList(AgencyListFormDTO formDTO) { List agencyList = customerAgencyDao.selectAgencyList(formDTO.getAgencyId()); - return new Result>().ok(agencyList); + return new Result>().ok(null == agencyList ? new ArrayList() : agencyList); } @Override diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index f783b6c336..6889e34433 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -22,30 +22,39 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.ErrorCode; -import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerGridDao; +import com.epmet.dao.CustomerStaffGridDao; import com.epmet.dto.*; import com.epmet.dto.form.*; -import com.epmet.dto.result.AddGridResultDTO; -import com.epmet.dto.result.CustomerGridByUserIdResultDTO; -import com.epmet.dto.result.CustomerGridForStrangerResultDTO; -import com.epmet.dto.result.GridDetailResultDTO; +import com.epmet.dto.result.*; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.CommonAgencyIdFormDTO; +import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; import com.epmet.entity.CustomerGridEntity; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.redis.CustomerGridRedis; import com.epmet.service.CustomerGridService; +import com.epmet.service.CustomerStaffGridService; import com.epmet.util.ModuleConstant; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.util.*; +import java.util.stream.Collectors; /** * 客户网格表 @@ -54,12 +63,18 @@ import java.util.*; * @since v1.0.0 2020-03-16 */ @Service +@Slf4j public class CustomerGridServiceImpl extends BaseServiceImpl implements CustomerGridService { + private static final Logger logger = LoggerFactory.getLogger(CustomerGridServiceImpl.class); @Autowired private CustomerGridRedis customerGridRedis; @Autowired private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private CustomerStaffGridService customerStaffGridService; + @Autowired + private CustomerStaffGridDao customerStaffGridDao; @Override public PageData page(Map params) { @@ -242,4 +257,163 @@ public class CustomerGridServiceImpl extends BaseServiceImpl + * @Author wangc + * @Date 2020.04.23 14:45 + **/ + @Override + public Result getGridListByAgency(CommonAgencyIdFormDTO agencyFormDTO) { + + //1.查当前机构下网格总数 + int gridCount = baseDao.selectGridCountByAgencyId(agencyFormDTO.getAgencyId()); + //2.查当前机构下每个网格的详情,按照创建时间倒叙取前十个 + List gridList = baseDao.selectGridListByAgencyId(agencyFormDTO.getAgencyId(), NumConstant.TEN); + //3.封装结果 + GridListInfoResultDTO resultData = new GridListInfoResultDTO(gridCount,gridList); + return new Result().ok(resultData); + } + + /** + * @Description 查找指定机构下的全部网格列表 + * @Param CommonAgencyIdFormDTO -> agencyId + * @return Result> + * @Author wangc + * @Date 2020.04.24 17:16 + **/ + @Override + public Result> getAllGridsByAgency(CommonAgencyIdFormDTO agencyFormDTO) { + return new Result>().ok(baseDao.selectGridListByAgencyId(agencyFormDTO.getAgencyId(),null)); + } + + /** + * @Description 移除网格工作人员 + * @Param CommonGridStaffInfoFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 09:48 + **/ + @Override + public Result removeGridStaff(CommonGridStaffInfoFormDTO staffInfoFormDTO) { + + Result authResult = authenticateManager(staffInfoFormDTO.getGridId(),staffInfoFormDTO.getUserId()); + if(authResult.success()){ + //3.移除操作 + //3.1 人员剔除 + CustomerStaffGridDTO staff = new CustomerStaffGridDTO(); + staff.setUserId(staffInfoFormDTO.getStaffId()); + staff.setGridId(staffInfoFormDTO.getGridId()); + staff.setUpdatedBy(staffInfoFormDTO.getUserId()); + staff.setDelFlag(NumConstant.ONE); + customerStaffGridService.update(staff); + //3.2 人数减一 + CustomerGridDTO grid = new CustomerGridDTO(); + grid.setId(authResult.getData().getId()); + grid.setUpdatedBy(staffInfoFormDTO.getUserId()); + grid.setTotalUser(authResult.getData().getTotalUser() == null || authResult.getData().getTotalUser() <= 0 + ? 0 : (authResult.getData().getTotalUser() - 1)); + update(grid); + } + + return new Result().error(); + } + + /** + * @Description 批量添加网格工作人员 + * @Param CommonGridStaffListFromDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 09:50 + **/ + @Override + public Result addGridStaffs(CommonGridStaffListFromDTO staffListFormDTO) { + //1.校验管理员权限 + Result authResult = authenticateManager(staffListFormDTO.getGridId(),staffListFormDTO.getUserId()); + if(authResult.success()){ + //2.校验人员重复信息,剔除重复人员 + Set existedStaffIds = + customerStaffGridDao.distinctGridStaffs(staffListFormDTO.getSelectedList(),staffListFormDTO.getGridId()); + Set staffIds = new HashSet<>(staffListFormDTO.getSelectedList()); + staffIds.removeAll(existedStaffIds); + //3.校验人员是否被禁用 + Result> staffsFeignResult = + epmetUserFeignClient.enableStaffMsgList(new CommonUserIdListFormDTO( + new ArrayList<>(staffIds), + authResult.getData().getCustomerId() + )); + if(staffsFeignResult.success() && null != staffsFeignResult.getData() && staffsFeignResult.getData().size() > 0){ + //4.添加 + List validStaffIds = + staffsFeignResult.getData() + .stream() + .map(CommonStaffInfoResultDTO::getStaffId) + .collect(Collectors.toList()); + List staffs2Insert = new LinkedList<>(); + for(String id : validStaffIds){ + CustomerStaffGridDTO staff2Insert = new CustomerStaffGridDTO(); + staff2Insert.setUserId(id); + staff2Insert.setGridId(staffListFormDTO.getGridId()); + staff2Insert.setCustomerId(authResult.getData().getCustomerId()); + staff2Insert.setCreatedBy(staffListFormDTO.getUserId()); + staff2Insert.setUpdatedBy(staffListFormDTO.getUserId()); + staffs2Insert.add(staff2Insert); + } + //4.1 批量新增网格工作人员 + customerStaffGridDao.insertBatch(staffs2Insert); + CustomerGridDTO grid2Update = new CustomerGridDTO(); + grid2Update.setId(staffListFormDTO.getGridId()); + grid2Update.setUpdatedBy(staffListFormDTO.getUserId()); + grid2Update.setTotalUser( + null == authResult.getData().getTotalUser() ? + validStaffIds.size() : authResult.getData().getTotalUser() + validStaffIds.size() + ); + //4.2 更新网格人数 + update(grid2Update); + return new Result(); + } + + } + return new Result().error(); + } + + /** + * @Description 对管理员身份进行权鉴 + * @Param + * @return + * @Author wangc + * @Date 2020.04.26 13:44 + **/ + private Result authenticateManager(String gridId,String userId){ + //1.查询网格相关信息 + CustomerGridEntity gridMsg = + baseDao.selectById(gridId); + //2.校验权限 + if(null != gridMsg && StringUtils.isNotBlank(gridMsg.getId()) && StringUtils.equals(gridMsg.getDelFlag(),NumConstant.ZERO_STR)){ + CommonUserFormDTO userParam = new CommonUserFormDTO(); + userParam.setCustomerId(gridMsg.getCustomerId()); + userParam.setUserId(userId); + Result staffFeignResult = + epmetUserFeignClient.getCustomerStaffRoles(userParam); + StaffRolesResultDTO resultData = staffFeignResult.getData(); + if(staffFeignResult.success() && null != resultData && StringUtils.isNotBlank(resultData.getStaffId())){ + if(null != resultData.getRoleList() + && StringUtils.equals(ModuleConstant.ENABLE,resultData.getEnableFlag()) + && resultData.getRoleList().size() > 0 + && resultData.getRoleList().contains(ModuleConstant.MANAGER)){ + return new Result().ok(gridMsg); + }else{ + log.error(ModuleConstant.NO_AUTH_OR_DISABLE); + } + }else{ + log.error(ModuleConstant.STAFF_INFO_NOT_FOUND); + } + }else{ + log.error(ModuleConstant.GRID_INFO_NOT_FOUND); + } + return new Result().error(); + } + + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java index 77292f2710..38b1c66ce6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java @@ -20,34 +20,36 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerStaffAgencyDao; -import com.epmet.dto.CustomerDTO; -import com.epmet.dto.CustomerStaffAgencyDTO; -import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.*; +import com.epmet.dto.form.CommonDepartmentFormDTO; +import com.epmet.dto.form.CommonUserIdListFormDTO; import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.form.CommonGridIdFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.dto.result.LatestCustomerResultDTO; -import com.epmet.dto.result.StaffInfoResultDTO; -import com.epmet.dto.result.StaffsInAgencyResultDTO; -import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerStaffAgencyEntity; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.OperCrmFeignClient; import com.epmet.redis.CustomerStaffAgencyRedis; import com.epmet.service.CustomerAgencyService; +import com.epmet.service.CustomerDepartmentService; +import com.epmet.service.CustomerGridService; import com.epmet.service.CustomerStaffAgencyService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 人员-机关单位关系表 @@ -66,6 +68,10 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl page(Map params) { @@ -148,4 +154,50 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl>().ok(customerStaffAgencyList); } + /** + * @Description 获取添加网格成员的可选人员列表,先在本服务下查询userId,然后调用EpmetUserFeign校验账户是否被禁用,使用EpmetUser服务的DTO作为返回参数 + * @Param CustomerGridFormDTO -> gridId + * @return Result> -> CommonStaffInfoResultDTO [epmet-user-client] + * @Author wangc + * @Date 2020.04.23 16:28 + **/ + @Override + public Result> getSelectableStaffs(CommonGridIdFormDTO customerGridFormDTO) { + //1.去数据库查询是此网格所属机构且不在此网格下的工作人员,这里无法确认是否被禁用 + List userId = baseDao.getSelectableStaffsForGrid(customerGridFormDTO.getGridId()); + //2.去用户服务下拿取用户基本信息,并校验工作人员身份是否被禁用 + if(null != userId && userId.size() >= NumConstant.ONE){ + CustomerGridDTO gridMsg = + customerGridService.get(customerGridFormDTO.getGridId()); + if(null != gridMsg && StringUtils.isNotBlank(gridMsg.getId())){ + //直接返回结果 + return epmetUserFeignClient.enableStaffMsgList(new CommonUserIdListFormDTO(userId,gridMsg.getCustomerId())); + } + } + return new Result>().ok(new ArrayList<>()); + } + + /** + * @Description 获取添加部门成员的可选人员列表 + * @Param CommonDepartmentFormDTO + * @return com.epmet.dto.result.CommonStaffInfoResultDTO[epmet-user-client] + * @Author wangc + * @Date 2020.04.26 16:37 + **/ + @Override + public Result> getSelectableDeptStaffs(CommonDepartmentFormDTO departmentFormDTO) { + //1.去数据库查询是此网格所属机构且不在此网格下的工作人员,这里无法确认是否被禁用 + List userId = baseDao.getSelectableStaffsForDept(departmentFormDTO.getDepartmentId()); + //2.去用户服务下拿取用户基本信息,并校验工作人员身份是否被禁用 + if(null != userId && userId.size() >= NumConstant.ONE){ + CustomerDepartmentDTO deptMsg = + customerDepartmentService.get(departmentFormDTO.getDepartmentId()); + if(null != deptMsg && StringUtils.isNotBlank(deptMsg.getId())){ + //直接返回结果 + return epmetUserFeignClient.enableStaffMsgList(new CommonUserIdListFormDTO(userId,deptMsg.getCustomerId())); + } + } + return new Result>().ok(new ArrayList<>()); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java index 2622f14529..456d99f584 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java @@ -28,9 +28,12 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerStaffGridDao; import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.entity.CustomerStaffGridEntity; +import com.epmet.feign.EpmetUserFeignClient; import com.epmet.redis.CustomerStaffGridRedis; import com.epmet.service.CustomerStaffGridService; import org.apache.commons.lang3.StringUtils; @@ -54,6 +57,9 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -106,6 +112,13 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl customerId ; staffId + * @return CustomerGridDTO + * @Author wangc + * @Date 2020.04.23 09:11 + **/ @Override public Result getStaffGridOrderByGridName(LatestGridFormDTO latestGridFormDTO) { CustomerGridDTO grid = baseDao.selectStaffGridOrderByGridName(latestGridFormDTO); @@ -115,5 +128,4 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl().ok(result); } - } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java index dda0d02ae7..95e44f7bc1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java @@ -28,6 +28,8 @@ import com.epmet.dao.CustomerAgencyDao; import com.epmet.dao.CustomerDepartmentDao; import com.epmet.dao.CustomerStaffDepartmentDao; import com.epmet.dto.CustomerIdDTO; +import com.epmet.dto.CustomerDepartmentDTO; +import com.epmet.dto.CustomerStaffDepartmentDTO; import com.epmet.dto.StaffRoleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -35,14 +37,18 @@ import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerDepartmentEntity; import com.epmet.entity.CustomerStaffDepartmentEntity; import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.service.CustomerDepartmentService; +import com.epmet.service.CustomerStaffDepartmentService; import com.epmet.service.DepartmentService; import com.epmet.util.ModuleConstant; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -60,8 +66,12 @@ public class DepartmentServiceImpl implements DepartmentService { @Autowired private CustomerDepartmentDao customerDepartmentDao; @Autowired + private CustomerDepartmentService customerDepartmentService; + @Autowired private CustomerStaffDepartmentDao customerStaffDepartmentDao; @Autowired + private CustomerStaffDepartmentService customerStaffDepartmentService; + @Autowired private EpmetUserFeignClient epmetUserFeignClient; /** @@ -153,6 +163,7 @@ public class DepartmentServiceImpl implements DepartmentService { //2:查询部门下工作人员的用户Id集合 List userIdList = customerStaffDepartmentDao.selectUserIdByDepartmentId(formDTO.getDepartmentId()); if (null == userIdList || userIdList.size() < NumConstant.ONE) { + departmentDetailResultDTO.setStaffList(new ArrayList()); return result.ok(departmentDetailResultDTO); } DepartmentInStaffFormDTO departmentInStaffFormDTO = new DepartmentInStaffFormDTO(); @@ -183,7 +194,7 @@ public class DepartmentServiceImpl implements DepartmentService { DepartmentInAgencyResultDTO departmentInAgencyResultDTO = new DepartmentInAgencyResultDTO(); //1:根据当前机关Id查询该机关下的直属部门列表 List departmentList = customerDepartmentDao.selectDepartmentListByAgencyId(formDTO.getAgencyId()); - departmentInAgencyResultDTO.setDepartmentList(departmentList); + departmentInAgencyResultDTO.setDepartmentList(null == departmentList ? new ArrayList() : departmentList); //2:统计下一级机关数 departmentInAgencyResultDTO.setDepartmentCount(departmentList.size()); return new Result().ok(departmentInAgencyResultDTO); @@ -198,7 +209,7 @@ public class DepartmentServiceImpl implements DepartmentService { @Override public Result> departmentList(DepartmentListFormDTO formDTO) { List departmentList = customerDepartmentDao.selectDepartmentList(formDTO.getAgencyId()); - return new Result>().ok(departmentList); + return new Result>().ok((null == departmentList ? new ArrayList() : departmentList)); } /** @@ -226,4 +237,42 @@ public class DepartmentServiceImpl implements DepartmentService { customerStaffDepartmentDao.updateDepartmentStaffCount(data.size(),addDepartmentStaffFormDTO.getDepartmentId()); return new Result(); } + + + /** + * @Description 部门人员移除 + * @Param CommonDepartmentStaffInfoFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 16:57 + **/ + @Override + public Result removeStaff(CommonDepartmentStaffInfoFormDTO departmentStaffInfoFormDTO) { + //1.剔除工作人员 + CustomerStaffDepartmentDTO staff = new CustomerStaffDepartmentDTO(); + staff.setUserId(departmentStaffInfoFormDTO.getStaffId()); + staff.setDepartmentId(departmentStaffInfoFormDTO.getDepartmentId()); + staff.setUpdatedBy(departmentStaffInfoFormDTO.getUserId()); + staff.setDelFlag(NumConstant.ONE_STR); + customerStaffDepartmentService.update(staff); + //2.部门人数减一 + CustomerDepartmentDTO dept = + customerDepartmentService.get(departmentStaffInfoFormDTO.getDepartmentId()); + if(null != dept && StringUtils.isNotBlank(dept.getId())){ + CustomerDepartmentDTO dept2Update = new CustomerDepartmentDTO(); + dept2Update.setId(dept.getId()); + dept2Update.setTotalUser(null == dept.getTotalUser() || dept.getTotalUser() == 0 + ? 0 : dept.getTotalUser() - NumConstant.ONE); + dept2Update.setUpdatedBy(departmentStaffInfoFormDTO.getUserId()); + customerDepartmentService.update(dept2Update); + return new Result(); + } + log.warn(ModuleConstant.DEPT_INFO_NOT_FOUND); + return new Result().error(); + } + + @Override + public List listDepartmentListByStaffId(String staffId) { + return customerDepartmentDao.listDepartmentListByStaffId(staffId); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ModuleConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ModuleConstant.java index 761b3c3781..345909e3ec 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ModuleConstant.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ModuleConstant.java @@ -16,4 +16,39 @@ public interface ModuleConstant { * tokenDto不能为null userId不能为空 */ String USER_NOT_NULL="用户信息不能为空"; + + /** + * 用户未被禁用标识 + * */ + String ENABLE = "enable"; + + /** + * 用户被禁用标识 + * */ + String DISABLE = "disable"; + + /** + * 管理员角色名称 + * */ + String MANAGER = "管理员"; + + /** + * 操作者账号失效或没有相应权限 + * */ + String NO_AUTH_OR_DISABLE = "操作者账号失效或没有相应权限,终止操作。"; + + /** + * 查询操作者身份信息失败 + * */ + String STAFF_INFO_NOT_FOUND = "查询操作者身份信息失败,终止操作。"; + + /** + * 网格信息有误 + * */ + String GRID_INFO_NOT_FOUND = "网格信息有误,终止操作。"; + + /** + * 找不到相关部门信息 + * */ + String DEPT_INFO_NOT_FOUND = "找不到相关部门信息"; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index a849c06edf..017ae50451 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -3,23 +3,26 @@ - - - - - - - - - - - - - - - - - + + ca.id AS "id", + ca.customer_id AS "customerId", + ca.pid AS "pid", + ca.pids AS "pids", + ca.all_parent_name AS "allParentName", + ca.organization_name AS "organizationName", + ca.level AS "level", + ca.area_code AS "areaCode", + ca.total_user AS "totalUser", + ca.province AS "province", + ca.city AS "city", + ca.district AS "district", + ca.del_flag AS "delflag", + ca.revision AS "revision", + ca.created_by AS "createdby", + ca.created_time AS "createdtime", + ca.updated_by AS "updatedby", + ca.updated_time AS "updatedtime" + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml index 932f7f66d3..e440745e06 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml @@ -26,4 +26,11 @@ ORDER BY created_time DESC + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 9ef6c03f93..ec0712bc8d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -206,4 +206,34 @@ AND del_flag = 0 + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml index a9b8baea0d..5183cf79b6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml @@ -39,4 +39,62 @@ AND AGENCY_ID =#{agencyId} + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml index 47a9de4a33..5e4c9bd1a3 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml @@ -41,4 +41,49 @@ LIMIT 1 + + + + + + insert into customer_staff_grid + ( + id, + user_id, + grid_id, + customer_id, + del_flag, + revision, + created_by, + created_time, + updated_by, + updated_time + ) values + + ( + (SELECT REPLACE(UUID(), '-', '') AS id), + #{item.userId}, + #{item.gridId}, + #{item.customerId}, + '0', + 0, + #{item.createdBy}, + now(), + #{item.updatedBy}, + now() + ) + + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonUserFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonUserFormDTO.java new file mode 100644 index 0000000000..9b2eec5757 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonUserFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 通用的用户Id入参 + * @ClassName CommonUserFormDTO + * @Author wangc + * @date 2020.04.26 10:53 + */ +@Data +public class CommonUserFormDTO implements Serializable{ + private static final long serialVersionUID = -7994579456530273809L; + + /** + * 用户Id + * */ + @NotBlank(message = "用户Id不能为空") + private String userId; + + /** + * 客户Id + * */ + @NotBlank(message = "客户Id不能为空") + private String customerId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonUserIdListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonUserIdListFormDTO.java new file mode 100644 index 0000000000..04c87ac74f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonUserIdListFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description 通用用户Id列表参数DTO + * @ClassName CommonUserIdListFormDTO + * @Author wangc + * @date 2020.04.24 15:42 + */ +@Data +@AllArgsConstructor +public class CommonUserIdListFormDTO implements Serializable{ + private static final long serialVersionUID = -7045691156972928671L; + + /** + * 用户列表 + * */ + @NotBlank(message = "用户列表不能为空") + private List userIdList; + + @NotBlank(message = "客户Id不能为空") + private String customerId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CommonStaffInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CommonStaffInfoResultDTO.java new file mode 100644 index 0000000000..f7b7f9b56e --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CommonStaffInfoResultDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 通用工作人员信息DTO + * @ClassName CommonStaffInfoResultDTO + * @Author wangc + * @date 2020.04.23 16:16 + */ +@Data +public class CommonStaffInfoResultDTO implements Serializable { + private static final long serialVersionUID = 4174593133225057232L; + + /** + * 工作人员用户Id + * */ + private String staffId; + + /** + * 工作人员用户头像 + * */ + private String staffHeadPhoto; + + /** + * 工作人员用户显示昵称 + * */ + private String staffName; + + /** + * 性别 1男2女0未知 + * */ + private Integer gender; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffRolesResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffRolesResultDTO.java new file mode 100644 index 0000000000..003a727fac --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffRolesResultDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 通用的员工角色返参 + * @ClassName StaffRolesResultDTO + * @Author wangc + * @date 2020.04.26 10:29 + */ +@Data +public class StaffRolesResultDTO implements Serializable { + private static final long serialVersionUID = -2049883620062097446L; + + /** + * 员工Id + * */ + private String staffId; + + /** + * 角色列表 + * */ + private List roleList; + + /** + * 是否被禁用 未禁用enable,已禁用disabled + * */ + private String enableFlag; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserInfoOnEnterGridResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserInfoOnEnterGridResultDTO.java index 5bcfd548cc..4f4d31bdb5 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserInfoOnEnterGridResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserInfoOnEnterGridResultDTO.java @@ -15,16 +15,34 @@ import java.util.List; public class UserInfoOnEnterGridResultDTO implements Serializable{ private static final long serialVersionUID = 1L; + /** + * 当前客户Id + * */ private String currentCustomerId; + /** + * 当前网格Id + * */ private String currentGridId; + /** + * 当前网格名称 + * */ private String currentGridName; + /** + * 用户昵称 + * */ private String nickname; + /** + * 用户头像 + * */ private String userHeadPhoto; + /** + * 用户身份列表 + * */ private List userRoleList; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index cdc627dcc8..8af4a38647 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -35,6 +35,11 @@ import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; import org.springframework.beans.factory.annotation.Autowired; @@ -179,16 +184,6 @@ public class CustomerStaffController { return customerStaffService.selectGridStaffCountByUserId(userIdDTO); } - /** - * @param fromDTO - * @return - * @Author sun - * @Description 根据客户Id及userId集合查询用户基本信息 - */ - @PostMapping("getdepartmentstafflist") - public Result> getDepartmentStaffList(@RequestBody DepartmentInStaffFormDTO fromDTO) { - return customerStaffService.getDepartmentStaffList(fromDTO); - } @PostMapping(value = "selectcustomeridbyuserid") public Result> selectCustomerIdByUserId(@RequestBody AddDepartmentStaffFormDTO addDepartmentStaffFormDTO){ @@ -260,4 +255,28 @@ public class CustomerStaffController { public Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO){ return customerStaffService.disabledStaff(fromDTO); } + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + @PostMapping("getdepartmentstafflist") + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO fromDTO) { + return customerStaffService.getDepartmentStaffList(fromDTO); + } + + /** + * @Description 通过userId列表查询未被禁用的用户信息 + * @Param CommonUserIdListFormDTO :: getUserIdList + * @return Result> + * @Author wangc + * @Date 2020.04.24 15:44 + **/ + @PostMapping(value = "enabestaffmsglist") + public Result> enableStaffMsgList(@RequestBody CommonUserIdListFormDTO userIdList){ + ValidatorUtils.validateEntity(userIdList); + return customerStaffService.getEnableStaffMsgList(userIdList); + } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java index c3fc1b9f24..a16c1ec5d3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java @@ -5,8 +5,10 @@ import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.StaffRoleFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.dto.result.StaffRolesResultDTO; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.service.GovStaffRoleService; import com.epmet.service.StaffRoleService; @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + import java.util.ArrayList; import java.util.List; @@ -71,4 +74,16 @@ public class StaffRoleController { return new Result>().ok(staffRoleDTOS); } + /** + * @Description 查询一个员工在指定客户下的角色 + * @Param CommonUserFormDTO + * @return Result + * @Author wangc + * @Date 2020.04.26 13:06 + **/ + @PostMapping("getcustomerstaffroles") + public Result getCustomerStaffRoles(@RequestBody CommonUserFormDTO commonUserFormDTO){ + ValidatorUtils.validateEntity(commonUserFormDTO); + return staffRoleService.getStaffRoles(commonUserFormDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index 2b5fe0cb46..7936c026c8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -23,8 +23,10 @@ import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -119,4 +121,13 @@ public interface CustomerStaffDao extends BaseDao { * @auther zxc */ List selectCustomerIdByUserId(AddDepartmentStaffFormDTO departmentStaffFormDTO); + + /** + * @Description 根据UserId列表查询用信息,过滤掉被禁用的,包含未激活的 + * @Param List + * @return List + * @Author wangc + * @Date 2020.04.24 15:34 + **/ + List selectEnableStaffMsg(@Param("userIds") List userIds,@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java index 6d65865681..85dae3de67 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -18,11 +18,15 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.commons.mybatis.entity.DataScope; import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.dto.result.StaffRolesResultDTO; import com.epmet.entity.StaffRoleEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.springframework.context.annotation.Scope; import java.util.List; @@ -40,7 +44,8 @@ public interface StaffRoleDao extends BaseDao { * @param orgId * @return */ - List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); + List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId, + @Param("dataScope") DataScope dataScope); /** * 删除工作人员权限 @@ -49,4 +54,13 @@ public interface StaffRoleDao extends BaseDao { */ boolean delStaffRoles(StaffRoleDTO dto); + /** + * @Description 得到指定客户下的某个用户的全部角色 + * @Param getCustomerId :: getUserId + * @return StaffRolesResultDTO + * @Author wangc + * @Date 2020.04.26 11:01 + **/ + StaffRolesResultDTO getStaffRoles(CommonUserFormDTO commonUserFormDTO); + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index acbb5833f7..1f518e6910 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PostMapping; * @Author sun * @Date 2020/3/16 */ +//, url = "localhost:8092" @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) public interface GovOrgFeignClient { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index 924c85d2f2..67a4b279ef 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -25,10 +25,18 @@ import com.epmet.dto.form.*; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.CommonUserIdListFormDTO; +import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.StaffInfoFromDTO; +import com.epmet.dto.form.StaffSubmitFromDTO; +import com.epmet.dto.form.DepartmentInStaffFormDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; import com.epmet.dto.result.StaffDetailResultDTO; import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import java.util.List; @@ -220,4 +228,13 @@ public interface CustomerStaffService extends BaseService { * @auther: zxc */ Result> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO); + + /** + * @Description 通过userId列表查询未被禁用的用户信息 + * @Param CommonUserIdListFormDTO :: getUserIdList + * @return Result> + * @Author wangc + * @Date 2020.04.24 15:44 + **/ + Result> getEnableStaffMsgList(CommonUserIdListFormDTO userIdList); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java index 9c6af5321e..39680248cb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java @@ -20,8 +20,11 @@ package com.epmet.service; import com.epmet.commons.mybatis.entity.DataScope; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.dto.result.StaffRolesResultDTO; import com.epmet.entity.StaffRoleEntity; import java.util.List; @@ -108,4 +111,13 @@ public interface StaffRoleService extends BaseService { * @param dto */ void clearStaffRoles(StaffRoleDTO dto); + + /** + * @Description 得到某一个员工在一个客户下的所有角色 + * @Param CommonUserFormDTO :: getUserId :: getCustomerId + * @return Result + * @Author wangc + * @Date 2020.04.26 10:59 + **/ + Result getStaffRoles(CommonUserFormDTO userParam); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 799ab62d71..28e22a28f7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -44,6 +44,11 @@ import com.epmet.dto.result.DepartInStaffListResultDTO; import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.dto.result.StaffRoleResultDTO; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.result.CommonStaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import com.epmet.entity.GovStaffRoleEntity; import com.epmet.entity.StaffRoleEntity; @@ -398,4 +403,16 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl>().ok(baseDao.selectCustomerIdByUserId(addDepartmentStaffFormDTO)); } + /** + * @Description 通过userId列表查询未被禁用的用户信息 + * @Param CommonUserIdListFormDTO :: getUserIdList + * @return Result> + * @Author wangc + * @Date 2020.04.24 15:44 + **/ + @Override + public Result> getEnableStaffMsgList(CommonUserIdListFormDTO userIdList) { + return new Result>().ok(baseDao.selectEnableStaffMsg(userIdList.getUserIdList(),userIdList.getCustomerId())); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java index 180521ebe3..15b5b1c311 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -25,9 +25,12 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.StaffRoleDao; import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.dto.result.StaffRolesResultDTO; import com.epmet.entity.StaffRoleEntity; import com.epmet.redis.StaffRoleRedis; import com.epmet.service.StaffRoleService; @@ -111,9 +114,9 @@ public class StaffRoleServiceImpl extends BaseServiceImpl listStaffsInRole(String roleKey, String orgId, DataScope dataScope) { - return baseDao.listStaffIdsByRoleKeyAndOrgId(roleKey, orgId); + return baseDao.listStaffIdsByRoleKeyAndOrgId(roleKey, orgId, dataScope); } @Override @@ -122,4 +125,16 @@ public class StaffRoleServiceImpl extends BaseServiceImpl + * @Author wangc + * @Date 2020.04.26 10:59 + **/ + @Override + public Result getStaffRoles(CommonUserFormDTO userParam) { + return new Result().ok(baseDao.getStaffRoles(userParam)); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index 828aa05c1d..9f96127f78 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -174,4 +174,24 @@ AND del_flag = 0 AND enable_flag = 'enable' + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml index 7ad99146cb..718e47a182 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml @@ -35,4 +35,35 @@ r.ROLE_KEY = #{roleKey} AND sr.ORG_ID = #{orgId} + + + + + + + + + + + + + + + + \ No newline at end of file