Browse Source

Merge branch 'dev_govorg' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_govorg

# Conflicts:
#	epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
#	epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
#	epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
#	epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
#	epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
#	epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml
master
sunyuchao 5 years ago
parent
commit
ede047da34
  1. 2
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java
  2. 63
      epmet-auth/src/test/java/com/epmet/TokenGenTest.java
  3. 20
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java
  4. 172
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java
  5. 106
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java
  6. 26
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java
  7. 9
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java
  8. 26
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java
  9. 25
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java
  10. 8
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java
  11. 6
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java
  12. 100
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java
  13. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java
  14. 46
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java
  15. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  16. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java
  17. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java
  18. 61
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java
  19. 8
      epmet-gateway/pom.xml
  20. 3
      epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java
  21. 15
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java
  22. 15
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java
  23. 10
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java
  24. 15
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  25. 2
      epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql
  26. 11
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java
  27. 18
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java
  28. 17
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java
  29. 3
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java
  30. 16
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  31. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java
  32. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java
  33. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java
  34. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java
  35. 30
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java
  36. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java
  37. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java
  38. 53
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java
  39. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java
  40. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java
  41. 54
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java
  42. 40
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java
  43. 28
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffRoleResultDTO.java
  44. 41
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java
  45. 37
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java
  46. 83
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  47. 38
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  48. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  49. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
  50. 27
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  51. 65
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java
  52. 74
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  53. 51
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  54. 56
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
  55. 56
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java
  56. 17
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  57. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java
  58. 29
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
  59. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java
  60. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java
  61. 68
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  62. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java
  63. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java
  64. 274
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  65. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java
  66. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java
  67. 57
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml
  68. 13
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml
  69. 5
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

2
epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java

@ -31,7 +31,7 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem
* mybatis数据权限演示
*/
@Override
@DataFilter(prefix = "AND", isPendingCreator = false)
//@DataFilter(prefix = "AND", isPendingCreator = false)
public PageData<NewsDTO> page(Map<String, Object> params) {
paramsToLike(params, "title");

63
epmet-auth/src/test/java/com/epmet/TokenGenTest.java

@ -0,0 +1,63 @@
package com.epmet;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
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.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
public class TokenGenTest {
@Autowired
private JwtTokenProperties jwtTokenProperties;
@Autowired
private JwtTokenUtils jwtTokenUtils;
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
@Test
public void genToken() {
String staffId = "wxz";
String tokenStr = generateGovWxmpToken(staffId);
int expire = jwtTokenProperties.getExpire();
GovTokenDto govTokenDto = new GovTokenDto();
govTokenDto.setApp(LoginConstant.APP_GOV);
govTokenDto.setClient(LoginConstant.CLIENT_WXMP);
govTokenDto.setUserId(staffId);
govTokenDto.setOpenId("");
govTokenDto.setSessionKey("");
govTokenDto.setUnionId("");
govTokenDto.setToken(tokenStr);
govTokenDto.setUpdateTime(System.currentTimeMillis());
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(tokenStr).getTime());
govTokenDto.setAgencyId("1");
govTokenDto.setCustomerId("f76def116c9c2dc0269cc17867af122c");
cpUserDetailRedis.set(govTokenDto, expire);
}
/**
* @Description 生成token
* @Date 2020/4/18 23:04
**/
private String generateGovWxmpToken(String staffId) {
Map<String, Object> map = new HashMap<>();
map.put("app", LoginConstant.APP_GOV);
map.put("client", LoginConstant.CLIENT_WXMP);
map.put("userId", staffId);
String token = jwtTokenUtils.createToken(map);
return token;
}
}

20
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java

@ -25,24 +25,4 @@ public @interface DataFilter {
*/
String tableAlias() default "";
/**
* 查询条件前缀可选值有[whereand]
*/
String prefix() default "";
/**
* 用户ID
*/
String userId() default "creator";
/**
* 部门ID
*/
String deptId() default "dept_id";
/**
* 是否拼接用户ID
*/
boolean isPendingCreator() default true;
}

172
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java

@ -8,25 +8,28 @@
package com.epmet.commons.mybatis.aspect;
import cn.hutool.core.collection.CollUtil;
import com.epmet.commons.mybatis.annotation.DataFilter;
import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO;
import com.epmet.commons.mybatis.entity.DataScope;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.enums.SuperAdminEnum;
import com.epmet.commons.mybatis.feign.GovAccessFeignClient;
import com.epmet.commons.tools.aspect.AccessOpeAspect;
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.security.user.SecurityUser;
import com.epmet.commons.tools.security.user.UserDetail;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.Result;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 数据过滤切面处理类
@ -37,69 +40,124 @@ import java.util.Map;
@Aspect
@Component
public class DataFilterAspect {
@Pointcut("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)")
public void dataFilterCut() {
}
private static final Logger log = LoggerFactory.getLogger(DataFilterAspect.class);
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private GovAccessFeignClient govAccessFeignClient;
@Before("dataFilterCut()")
@Before("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)")
public void dataFilter(JoinPoint point) {
Object params = point.getArgs()[0];
if(params != null && params instanceof Map){
UserDetail user = SecurityUser.getUser();
//如果不是超级管理员,则进行数据过滤
if(user.getSuperAdmin() == SuperAdminEnum.NO.value()){
Map map = (Map)params;
String sqlFilter = getSqlFilter(user, point);
map.put(Constant.SQL_FILTER, new DataScope(sqlFilter));
}
// 反射的方式
//MethodSignature signature = (MethodSignature) point.getSignature();
//Class[] parameterTypes = signature.getParameterTypes();
//for (Class parameterType : parameterTypes) {
// if (parameterType == DataScope.class) {
//
// }
//}
String reqiurePermission = AccessOpeAspect.requirePermissionTl.get();
// 没有配置所需权限,不做操作,打印提示日志
if (StringUtils.isBlank(reqiurePermission)) {
log.warn("Api编码需要指定所需权限,请在Api上使用@RequirePermission注解完成所需权限配置");
return;
}
return ;
// 校验操作权限
validateOpePermission(reqiurePermission);
Object[] methodArgs = point.getArgs();
for (Object methodArg : methodArgs) {
if (methodArg instanceof DataScope) {
((DataScope) methodArg).setSqlFilter(getSqlFilterSegment());
return;
}
}
throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR);
//throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR);
}
/**
* 获取数据过滤的SQL
* 校验操作权限
*/
private String getSqlFilter(UserDetail user, JoinPoint point){
MethodSignature signature = (MethodSignature) point.getSignature();
DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class);
//获取表的别名
String tableAlias = dataFilter.tableAlias();
if(StringUtils.isNotBlank(tableAlias)){
tableAlias += ".";
private void validateOpePermission(String requirePermission) {
StaffPermissionFormDTO staffPermissionFormDTO = new StaffPermissionFormDTO();
staffPermissionFormDTO.setApp(loginUserUtil.getLoginUserApp());
staffPermissionFormDTO.setClient(loginUserUtil.getLoginUserClient());
staffPermissionFormDTO.setStaffId(loginUserUtil.getLoginUserId());
Result<Set<String>> permissions = govAccessFeignClient.getStaffCurrPermissions(staffPermissionFormDTO);
if (permissions.getCode() != 0) {
// 查询不到权限,记录日志,抛出8000异常
log.error("调用Access查询权限失败:{}", permissions.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
StringBuilder sqlFilter = new StringBuilder();
//查询条件前缀
String prefix = dataFilter.prefix();
if(StringUtils.isNotBlank(prefix)){
sqlFilter.append(" ").append(prefix);
if (!CollectionUtils.isEmpty(permissions.getData()) && StringUtils.isNotBlank(requirePermission)
&& permissions.getData().contains(requirePermission)) {
// 权限允许,正常结束
return;
}
// 权限不足抛出异常
throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode());
}
sqlFilter.append(" (");
//部门ID列表
List<Long> deptIdList = user.getDeptIdList();
if(CollUtil.isNotEmpty(deptIdList)){
sqlFilter.append(tableAlias).append(dataFilter.deptId());
sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")");
}
/**
* 生成过滤sql片段
* @return
*/
private String getSqlFilterSegment() {
// 根据角色列表查询操作范围列表
//查询本人数据
if (dataFilter.isPendingCreator()) {
if(CollUtil.isNotEmpty(deptIdList)){
sqlFilter.append(" or ");
}
sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId());
}
sqlFilter.append(")");
// 拼接sql语句
return sqlFilter.toString();
// TODO
return "dept_id in (1,2,3)";
}
///**
// * 获取数据过滤的SQL
// */
//@Deprecated
//private String getSqlFilter(UserDetail user, JoinPoint point){
// MethodSignature signature = (MethodSignature) point.getSignature();
// DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class);
// //获取表的别名
// String tableAlias = dataFilter.tableAlias();
// if(StringUtils.isNotBlank(tableAlias)){
// tableAlias += ".";
// }
//
// StringBuilder sqlFilter = new StringBuilder();
//
// //查询条件前缀
// String prefix = dataFilter.prefix();
// if(StringUtils.isNotBlank(prefix)){
// sqlFilter.append(" ").append(prefix);
// }
//
// sqlFilter.append(" (");
//
// //部门ID列表
// List<Long> deptIdList = user.getDeptIdList();
// if(CollUtil.isNotEmpty(deptIdList)){
// sqlFilter.append(tableAlias).append(dataFilter.deptId());
//
// sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")");
// }
//
// //查询本人数据
// if (dataFilter.isPendingCreator()) {
// if(CollUtil.isNotEmpty(deptIdList)){
// sqlFilter.append(" or ");
// }
// sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId());
// }
// sqlFilter.append(")");
//
// return sqlFilter.toString();
//}
}

106
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java

@ -0,0 +1,106 @@
///**
// * Copyright (c) 2018 人人开源 All rights reserved.
// *
// * https://www.renren.io
// *
// * 版权所有,侵权必究!
// */
//
//package com.epmet.commons.mybatis.aspect;
//
//import cn.hutool.core.collection.CollUtil;
//import com.epmet.commons.mybatis.annotation.DataFilter;
//import com.epmet.commons.mybatis.entity.DataScope;
//import com.epmet.commons.tools.constant.Constant;
//import com.epmet.commons.tools.enums.SuperAdminEnum;
//import com.epmet.commons.tools.exception.ErrorCode;
//import com.epmet.commons.tools.exception.RenException;
//import com.epmet.commons.tools.security.user.SecurityUser;
//import com.epmet.commons.tools.security.user.UserDetail;
//import org.apache.commons.lang3.StringUtils;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.stereotype.Component;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.Map;
//
///**
// * 数据过滤,切面处理类
// *
// * @author Mark sunlightcs@gmail.com
// * @since 1.0.0
// */
//@Aspect
//@Component
//public class DataFilterAspectBak {
// @Pointcut("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)")
// public void dataFilterCut() {
//
// }
//
// @Before("dataFilterCut()")
// public void dataFilter(JoinPoint point) {
// Object params = point.getArgs()[0];
// if(params != null && params instanceof Map){
// UserDetail user = SecurityUser.getUser();
//
// //如果不是超级管理员,则进行数据过滤
// if(user.getSuperAdmin() == SuperAdminEnum.NO.value()){
// Map map = (Map)params;
// String sqlFilter = getSqlFilter(user, point);
// map.put(Constant.SQL_FILTER, new DataScope(sqlFilter));
// }
//
// return ;
// }
//
// throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR);
// }
//
// /**
// * 获取数据过滤的SQL
// */
// private String getSqlFilter(UserDetail user, JoinPoint point){
// MethodSignature signature = (MethodSignature) point.getSignature();
// DataFilter dataFilter = signature.getMethod().getAnnotation(DataFilter.class);
// //获取表的别名
// String tableAlias = dataFilter.tableAlias();
// if(StringUtils.isNotBlank(tableAlias)){
// tableAlias += ".";
// }
//
// StringBuilder sqlFilter = new StringBuilder();
//
// //查询条件前缀
// String prefix = dataFilter.prefix();
// if(StringUtils.isNotBlank(prefix)){
// sqlFilter.append(" ").append(prefix);
// }
//
// sqlFilter.append(" (");
//
// //部门ID列表
// List<Long> deptIdList = user.getDeptIdList();
// if(CollUtil.isNotEmpty(deptIdList)){
// sqlFilter.append(tableAlias).append(dataFilter.deptId());
//
// sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")");
// }
//
// //查询本人数据
// if (dataFilter.isPendingCreator()) {
// if(CollUtil.isNotEmpty(deptIdList)){
// sqlFilter.append(" or ");
// }
// sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId());
// }
// sqlFilter.append(")");
//
// return sqlFilter.toString();
// }
//}

26
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.commons.mybatis.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Set;
@Data
public class StaffPermissionFormDTO {
/**
* 工作人员 id
*/
private String staffId;
/**
* 登录头信息app
*/
private String app;
/**
* 登录头信息client
*/
private String client;
}

9
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java

@ -1,8 +1,8 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* <p>
* https://www.renren.io
*
* <p>
* 版权所有侵权必究
*/
@ -15,8 +15,13 @@ package com.epmet.commons.mybatis.entity;
* @since 1.0.0
*/
public class DataScope {
private String sqlFilter;
public static DataScope getDefault() {
return new DataScope("");
}
public DataScope(String sqlFilter) {
this.sqlFilter = sqlFilter;
}

26
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java

@ -0,0 +1,26 @@
package com.epmet.commons.mybatis.feign;
import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO;
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.PostMapping;
import java.util.Set;
/**
* @Description
* @Author sun
*/
@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class)
public interface GovAccessFeignClient {
/**
* 查询用户当前权限列表(DataFilterAspect中用到)
* @return
*/
@PostMapping("/gov/access/access/getcurrpermissions")
Result<Set<String>> getStaffCurrPermissions(StaffPermissionFormDTO dto);
}

25
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java

@ -0,0 +1,25 @@
package com.epmet.commons.mybatis.feign.fallback;
import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO;
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.Set;
/**
* 调用政府端权限
* @Author wxz
* @Description
* @Date 2020/4/24 11:17
**/
@Component
public class GovAccessFeignClientFallback implements GovAccessFeignClient {
@Override
public Result<Set<String>> getStaffCurrPermissions(StaffPermissionFormDTO dto) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getStaffCurrPermissions", dto);
}
}

8
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.security.user.SecurityUser;
import com.epmet.commons.tools.security.user.UserDetail;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@ -40,11 +41,14 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
private final static String UPDATER = "updater";
private final static String DEPT_ID = "deptId";
@Autowired
private LoginUserUtil loginUserUtil;
@Override
public void insertFill(MetaObject metaObject) {
Date date = new Date();
if (metaObject.getOriginalObject() instanceof BaseEpmetEntity) {
String loginUserId = LoginUserUtil.getLoginUserId();
String loginUserId = loginUserUtil.getLoginUserId();
// epmet项目新增的
loginUserId = StringUtils.isBlank(loginUserId) ? Constant.APP_USER_FLAG : loginUserId;
//Long deptId = user == null ? null : user.getDeptId();
@ -107,7 +111,7 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
//更新时间
setFieldValByName(UPDATE_DATE, new Date(), metaObject);
} else if (fillEsuaEntity) {
String loginUserId = LoginUserUtil.getLoginUserId();
String loginUserId = loginUserUtil.getLoginUserId();
String userId = StringUtils.isBlank(loginUserId) ? Constant.APP_USER_FLAG : loginUserId;
setFieldValByName(FieldConstant.UPDATED_BY_HUMP, userId, metaObject);
setFieldValByName(FieldConstant.UPDATED_TIME_HUMP, new Date(), metaObject);

6
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java

@ -8,6 +8,7 @@
package com.epmet.commons.mybatis.interceptor;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler;
@ -55,12 +56,17 @@ public class DataFilterInterceptor extends AbstractSqlParserHandler implements I
// 判断参数里是否有DataScope对象
DataScope scope = null;
if (paramObj instanceof DataScope) {
// 直接传入DataScope,不分页?
scope = (DataScope) paramObj;
} else if (paramObj instanceof Map) {
// 入参是一个Map
for (Object arg : ((Map) paramObj).values()) {
if (arg instanceof DataScope) {
scope = (DataScope) arg;
break;
} else if (arg instanceof QueryWrapper) {
// 通过Mybatis-plus封装的通用方法进行查询
break;
}
}
}

100
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java

@ -0,0 +1,100 @@
///**
// * Copyright (c) 2018 人人开源 All rights reserved.
// * <p>
// * https://www.renren.io
// * <p>
// * 版权所有,侵权必究!
// */
//
//package com.epmet.commons.mybatis.interceptor;
//
//import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
//import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler;
//import com.epmet.commons.mybatis.entity.DataScope;
//import org.apache.ibatis.executor.statement.StatementHandler;
//import org.apache.ibatis.mapping.BoundSql;
//import org.apache.ibatis.mapping.MappedStatement;
//import org.apache.ibatis.mapping.SqlCommandType;
//import org.apache.ibatis.plugin.*;
//import org.apache.ibatis.reflection.MetaObject;
//import org.apache.ibatis.reflection.SystemMetaObject;
//
//import java.sql.Connection;
//import java.util.Map;
//import java.util.Properties;
//
///**
// * 数据过滤
// *
// * @author Mark sunlightcs@gmail.com
// * @since 1.0.0
// */
//@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
//public class DataFilterInterceptorBak extends AbstractSqlParserHandler implements Interceptor {
//
// @Override
// public Object intercept(Invocation invocation) throws Throwable {
// StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
// MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
//
// // SQL解析
// this.sqlParser(metaObject);
//
// // 先判断是不是SELECT操作
// MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
// if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) {
// return invocation.proceed();
// }
//
// // 针对定义了rowBounds,做为mapper接口方法的参数
// BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
// String originalSql = boundSql.getSql();
// Object paramObj = boundSql.getParameterObject();
//
// // 判断参数里是否有DataScope对象
// DataScope scope = null;
// if (paramObj instanceof DataScope) {
// scope = (DataScope) paramObj;
// } else if (paramObj instanceof Map) {
// for (Object arg : ((Map) paramObj).values()) {
// if (arg instanceof DataScope) {
// scope = (DataScope) arg;
// break;
// }
// }
// }
//
// // 不用数据过滤
// if (scope == null) {
// return invocation.proceed();
// }
//
// // 拼接新SQL
// String orderBy = "ORDER BY";
// String groupBy = "GROUP BY";
// if (originalSql.indexOf(groupBy) > -1) {
// originalSql = originalSql.replace(groupBy, scope.getSqlFilter() + groupBy);
// } else if (originalSql.indexOf(orderBy) > -1) {
// originalSql = originalSql.replace(orderBy, scope.getSqlFilter() + orderBy);
// } else {
// originalSql = originalSql + scope.getSqlFilter();
// }
//
// // 重写SQL
// metaObject.setValue("delegate.boundSql.sql", originalSql);
// return invocation.proceed();
// }
//
// @Override
// public Object plugin(Object target) {
// if (target instanceof StatementHandler) {
// return Plugin.wrap(target, this);
// }
// return target;
// }
//
// @Override
// public void setProperties(Properties properties) {
//
// }
//}

36
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java

@ -0,0 +1,36 @@
/**
* Copyright 2018 人人开源 http://www.renren.io
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.epmet.commons.tools.annotation;
import java.lang.annotation.*;
/**
* 权限注解
* @Author wxz
* @Description
* @Date 2020/4/23 16:17
**/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RequirePermission {
String key() default "";
String desc() default "";
}

46
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java

@ -0,0 +1,46 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.commons.tools.aspect;
import com.epmet.commons.tools.annotation.RequirePermission;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
/**
* 每次请求过滤Api中配置的权限key出来
* @Author wxz
* @Description
* @Date 2020/4/23 16:16
**/
@Aspect
@Component
public class AccessOpeAspect {
/**
* 存储所需操作权限的 ThreadLocal
*/
public static final ThreadLocal<String> requirePermissionTl = new ThreadLocal<>();
@Before("@annotation(com.epmet.commons.tools.annotation.RequirePermission)")
public void before(JoinPoint point) throws Throwable {
// 取RequirePermission注解
MethodSignature methodSignature = (MethodSignature) point.getSignature();
RequirePermission requirePermissionAnno = methodSignature.getMethod().getAnnotation(RequirePermission.class);
String key = requirePermissionAnno.key();
String desc = requirePermissionAnno.desc();
System.out.println(key);
System.out.println(desc);
// 放入ThreadLocal,供DataFilterAspect中使用
requirePermissionTl.set(key);
}
}

7
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -25,11 +25,14 @@ public enum EpmetErrorCode {
AUTO_CONFIRM_FAILED(8103, "党员注册失败"),
MOBILE_GET_CODE_ERROR(8104,"获取验证码失败"),
MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"),
NOT_DEL_GRID(8106,"该网格存在工作人员,不允许删除"),
CANNOT_AUDIT_WARM(8201, "请完善居民信息"),
NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"),
NOT_DEL_AGENCY_PER(8203, "该机关存在工作人员,不允许删除"),
NOT_DEL_DEPARTMENT(8204, "该部门存在工作人员,不允许删除");
REQUIRE_PERMISSION(8203, "没有足够的操作权限"),
NOT_DEL_AGENCY(8204, "该机关存在下级机关,不允许删除"),
NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"),
NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除");
private int code;

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java

@ -44,6 +44,8 @@ public class RenExceptionHandler {
private ModuleConfig moduleConfig;
@Autowired
private LogProducer logProducer;
@Autowired
private LoginUserUtil loginUserUtil;
/**
* 处理自定义异常
@ -120,7 +122,7 @@ public class RenExceptionHandler {
//登录用户ID
log.setCreator(LoginUserUtil.getLoginUserId());
log.setCreator(loginUserUtil.getLoginUserId());
//异常信息
log.setErrorInfo(ExceptionUtils.getErrorStackTrace(ex));

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java

@ -67,6 +67,6 @@ public class GovTokenDto extends BaseTokenDto implements Serializable {
/**
* 功能权限列表实际上是gov_staff => staff_role => role_operation查询到的operationKey
*/
private List<String> permissions;
private Set<String> permissions;
}

61
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java

@ -1,33 +1,82 @@
package com.epmet.commons.tools.security.user;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.utils.HttpContextUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 登录用户相关工具
*/
@Component
public class LoginUserUtil {
//@Autowired
//private
/**
* 查询登录用户的id
* @return
*/
public static String getLoginUserId() {
public String getLoginUserId() {
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
if (request == null) {
return null;
}
String userId = request.getHeader(Constant.USER_KEY);
String userId = request.getHeader(AppClientConstant.USER_ID);
if (StringUtils.isBlank(userId)) {
return null;
}
return userId;
}
/**
* 登录用户的App头信息
* @return
*/
public String getLoginUserApp() {
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
if (request == null) {
return null;
}
String app = request.getHeader(AppClientConstant.APP);
if (StringUtils.isBlank(app)) {
return null;
}
return app;
}
/**
* 获取登录用户client头信息
* @return
*/
public String getLoginUserClient() {
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
if (request == null) {
return null;
}
String client = request.getHeader(AppClientConstant.CLIENT);
if (StringUtils.isBlank(client)) {
return null;
}
return client;
}
/**
* 获取用户的部门ID列表
* @return
*/
public List<String> getLoginUserDepartments() {
String loginUserId = getLoginUserId();
String loginUserApp = getLoginUserApp();
String loginUserClient = getLoginUserClient();
// todo
return null;
}
}

8
epmet-gateway/pom.xml

@ -157,12 +157,12 @@
<gateway.routes.resi-partymember-server.uri>lb://resi-partymember-server</gateway.routes.resi-partymember-server.uri>
<!--18.政府端-权限-服务-->
<!--<gateway.routes.gov-access-server.uri>http://127.0.0.1:8099</gateway.routes.gov-access-server.uri>-->
<gateway.routes.gov-access-server.uri>lb://gov-access-server</gateway.routes.gov-access-server.uri>
<gateway.routes.gov-access-server.uri>http://127.0.0.1:8099</gateway.routes.gov-access-server.uri>
<!--<gateway.routes.gov-access-server.uri>lb://gov-access-server</gateway.routes.gov-access-server.uri>-->
<!--19.政府端-我的-服务-->
<!--<gateway.routes.gov-mine-server.uri>http://127.0.0.1:8098</gateway.routes.gov-mine-server.uri>-->
<gateway.routes.gov-mine-server.uri>lb://gov-mine-server</gateway.routes.gov-mine-server.uri>
<gateway.routes.gov-mine-server.uri>http://127.0.0.1:8098</gateway.routes.gov-mine-server.uri>
<!--<gateway.routes.gov-mine-server.uri>lb://gov-mine-server</gateway.routes.gov-mine-server.uri>-->
</properties>
</profile>
<profile>

3
epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java

@ -1,5 +1,6 @@
package com.epmet.filter;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.security.dto.BaseTokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
@ -54,7 +55,7 @@ public class FeignRequestFilter implements GlobalFilter, UserTokenFilter {
if (baseTokenDto != null) {
ServerHttpRequest build = exchange.getRequest().mutate()
.header(Constant.USER_KEY, new String[]{baseTokenDto.getUserId()}).build();
.header(AppClientConstant.USER_ID, new String[]{baseTokenDto.getUserId()}).build();
return chain.filter(exchange.mutate().request(build).build());
}

15
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java

@ -3,7 +3,7 @@ package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Set;
@Data
public class StaffPermCacheFormDTO {
@ -13,27 +13,32 @@ public class StaffPermCacheFormDTO {
*/
public interface UpdatePermissionCache {}
/**
* 查询当前权限列表
*/
public interface GetStaffCurrPermissions {}
/**
* 工作人员 id
*/
@NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class})
@NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class})
private String staffId;
/**
* 登录头信息app
*/
@NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class})
@NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class})
private String app;
/**
* 登录头信息client
*/
@NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class})
@NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class})
private String client;
/**
* 权限列表
*/
private List<String> permissions;
private Set<String> permissions;
}

15
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java

@ -10,7 +10,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.List;
import java.util.Set;
/**
* 权限相关Api
@ -36,8 +36,19 @@ public class AccessController {
String staffId = staffPermCacheFormDTO.getStaffId();
String app = staffPermCacheFormDTO.getApp();
String client = staffPermCacheFormDTO.getClient();
List<String> permissions = staffPermCacheFormDTO.getPermissions();
Set<String> permissions = staffPermCacheFormDTO.getPermissions();
accessService.updatePermissionCache(staffId, app, client, permissions);
return new Result();
}
/**
* 查询用户当前权限列表(DataFilterAspect中用到)
* @return
*/
@PostMapping("getcurrpermissions")
public Result<Set<String>> getStaffCurrPermissions(@RequestBody StaffPermCacheFormDTO dto) {
ValidatorUtils.validateEntity(dto, StaffPermCacheFormDTO.GetStaffCurrPermissions.class);
Set<String> permissions = accessService.listStaffCurrPermissions(dto.getApp(), dto.getClient(), dto.getStaffId());
return new Result<Set<String>>().ok(permissions);
}
}

10
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java

@ -1,6 +1,6 @@
package com.epmet.service;
import java.util.List;
import java.util.Set;
public interface AccessService {
/**
@ -8,5 +8,11 @@ public interface AccessService {
* @param staffId
* @param permissions
*/
void updatePermissionCache(String staffId, String app, String client, List<String> permissions);
void updatePermissionCache(String staffId, String app, String client, Set<String> permissions);
/**
* 查询用户当前权限列表
* @return
*/
Set<String> listStaffCurrPermissions(String app, String client, String staffId);
}

15
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java

@ -7,8 +7,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.List;
import java.util.HashSet;
import java.util.Set;
@Service
public class AccessServiceImpl implements AccessService {
@ -24,7 +26,7 @@ public class AccessServiceImpl implements AccessService {
* @param permissions
*/
@Override
public void updatePermissionCache(String staffId, String app, String client, List<String> permissions) {
public void updatePermissionCache(String staffId, String app, String client, Set<String> permissions) {
GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class);
if (govTokenDto == null) {
logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId);
@ -37,4 +39,13 @@ public class AccessServiceImpl implements AccessService {
cpUserDetailRedis.set(govTokenDto, expire);
logger.warn("更新[{}]用户缓存成功。", staffId);
}
@Override
public Set<String> listStaffCurrPermissions(String app, String client, String staffId) {
GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class);
if (govTokenDto == null || CollectionUtils.isEmpty(govTokenDto.getPermissions())) {
return new HashSet<>();
}
return new HashSet<>(govTokenDto.getPermissions());
}
}

2
epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql

@ -61,7 +61,7 @@ CREATE TABLE `role_operation` (
CREATE TABLE `role_scope` (
`ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`ROLE_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色ID',
`PERMISSION_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '权限key',
`SCOPE_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围Key',
`DEL_FLAG` tinyint(1) NULL DEFAULT NULL COMMENT '是否删除,0:未删除,1:已删除',
`REVISION` int(10) NULL DEFAULT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者id',

11
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java

@ -29,14 +29,21 @@ public class AccessController {
@Autowired
private AccessService accessService;
/**
* 查询用户可操作功能列表(包含缓存)
* @param tokenDto
* @param staffOperationDTO
* @return
*/
@PostMapping("getstaffoperations")
public Result<Set<String>> getStaffOperations(@LoginUser TokenDto tokenDto, @RequestBody StaffOperationDTO staffOperationDTO) {
//public Result<Set<String>> getStaffOperations(@RequestBody StaffOperationDTO staffOperationDTO) {
String agencyId = staffOperationDTO.getAgencyId();
String gridId = staffOperationDTO.getGridId();
String staffId = tokenDto.getUserId();
Set<String> opeKeys = accessService.listOpeKeysByStaffId(staffId, agencyId, gridId);
String app = tokenDto.getApp();
String client = tokenDto.getClient();
Set<String> opeKeys = accessService.listOpeKeysByStaffId(app, client, staffId,agencyId, gridId);
return new Result<Set<String>>().ok(opeKeys);
}
}

18
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java

@ -2,14 +2,13 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.dto.result.RoleOperationResultDTO;
import com.epmet.feign.fallback.GovAccessFeignClientFallback;
import com.epmet.feign.fallback.GovOrgFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
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;
@ -20,6 +19,19 @@ import java.util.List;
@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class)
public interface GovAccessFeignClient {
/**
* 根据角色ID查询角色权限列表
* @param roleId
* @return
*/
@PostMapping("/gov/access/role/operations/{roleId}")
Result<List<RoleOperationResultDTO>> listOperationsByRoleId(@PathVariable("roleId") String roleId);
/**
* 刷新用户权限缓存
* @param staffPermCacheFormDTO
* @return
*/
@PostMapping("/gov/access/access/updatepermissioncache")
Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO);
}

17
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java

@ -3,14 +3,11 @@ package com.epmet.feign.fallback;
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.StaffRoleDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.dto.result.RoleOperationResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovAccessFeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -25,4 +22,14 @@ public class GovAccessFeignClientFallback implements GovAccessFeignClient {
public Result<List<RoleOperationResultDTO>> listOperationsByRoleId(String roleId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listOperationsByRoleId");
}
/**
* 刷新用户权限缓存
* @param staffPermCacheFormDTO
* @return
*/
@Override
public Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "updatePermissionCache");
}
}

3
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java

@ -12,8 +12,7 @@ import java.util.Set;
public interface AccessService {
/**
* 根据staffId查询角色Key列表
* @param staffId
* @return
*/
Set<String> listOpeKeysByStaffId(String staffId, String agencyId, String gridId);
Set<String> listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId);
}

16
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java

@ -1,8 +1,9 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.RoleOperationResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
@ -26,8 +27,11 @@ public class AccessServiceImpl implements AccessService {
@Autowired
private GovAccessFeignClient govAccessFeignClient;
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
@Override
public Set<String> listOpeKeysByStaffId(String staffId, String agencyId, String gridId) {
public Set<String> listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId) {
List<GovStaffRoleDTO> roleDTOS = new ArrayList<>();
// 查询机关单位权限
StaffRoleFormDTO formDTO = new StaffRoleFormDTO();
@ -56,6 +60,14 @@ public class AccessServiceImpl implements AccessService {
}
});
});
// 将最新权限缓存到redis,为了尽量统一操作入口,调用gov-access接口实现
StaffPermCacheFormDTO staffPermCacheFormDTO = new StaffPermCacheFormDTO();
staffPermCacheFormDTO.setApp(app);
staffPermCacheFormDTO.setClient(client);
staffPermCacheFormDTO.setStaffId(staffId);
staffPermCacheFormDTO.setPermissions(opeKeys);
govAccessFeignClient.updatePermissionCache(staffPermCacheFormDTO);
return opeKeys;
}
}

21
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther zxc
* @Create 2020-04-24 9:13
*/
@Data
public class GridStaffCountDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 网格下未被禁用的工作人员数量
*/
private Integer enableCount;
}

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java

@ -31,4 +31,9 @@ public class StaffGridListDTO {
*/
private String roleName;
/**
* 性别
*/
private String gender;
}

21
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther zxc
* @Create 2020-04-24 9:06
*/
@Data
public class UserIdDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* userId
*/
private String userId;
}

31
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther zxc
* @Create 2020-04-23 16:42
*/
@Data
public class AddGridFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机构id
*/
private String agencyId;
/**
* 新建网格名称
*/
private String gridName;
/**
* 管辖区域
*/
private String manageDistrict;
}

30
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther zxc
* @Create 2020-04-23 19:18
*/
@Data
public class DeleteGridFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 网格id
*/
private String gridId;
/**
* 工作人员id
*/
private String staffId;
/**
* userId
*/
private String userId;
}

31
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther zxc
* @Create 2020-04-23 19:12
*/
@Data
public class EditGridFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* gridId 网格id
*/
private String gridId;
/**
* 网格名称
*/
private String gridName;
/**
* 管理区域
*/
private String manageDistrict;
}

31
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/24 10:12
*/
@Data
public class StaffInfoFromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/
@NotBlank(message = "机关ID不能为空")
private String agencyId;
/**
* 用户ID
*/
String staffId;
}

53
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java

@ -0,0 +1,53 @@
package com.epmet.dto.form;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/24 10:43
*/
@NoArgsConstructor
@Data
public class StaffSubmitFromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关ID
*/
@NotBlank(message = "机关ID不能为空")
private String agencyId;
/**
* 人员ID
*/
private String staffId;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空")
private String name;
/**
* 手机
*/
@NotBlank(message = "手机号不能为空")
private String mobile;
/**
* 性别
*/
@NotBlank(message = "性别不能为空")
private Integer gender;
/**
* 专兼职
*/
@NotBlank(message = "专兼职不能为空")
private String workType;
/**
* 角色id列表
*/
@NotBlank(message = "角色不能为空")
private List<String> roles;
}

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java

@ -2,6 +2,7 @@ package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
@ -20,6 +21,7 @@ public class StaffsInAgencyFromDTO implements Serializable {
/**
* 机关ID
*/
@NotBlank(message = "机关ID不能为空")
private String agencyId;
/**
* 用户ID

21
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Auther zxc
* @Create 2020-04-23 16:45
*/
@Data
public class AddGridResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* gridId 网格id
*/
private String gridId;
}

54
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java

@ -0,0 +1,54 @@
package com.epmet.dto.result;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/24 10:50
*/
@NoArgsConstructor
@Data
public class StaffDetailResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 人员ID
*/
private String staffId;
/**
* 姓名
*/
private String name;
/**
* 手机号
*/
private String mobile;
/**
* 头像
*/
private String headPhoto;
/**
* 激活状态inactive未激活active已激活
*/
private String activeFlag;
/**
* 激活时间
*/
private String activeTime;
/**
* 性别
*/
private Integer gender;
/**
* 是否禁用(未禁用enable,已禁用disabled)
*/
private String enableFlag;
/**
* 职责名称列表
*/
private List<String> roles;
}

40
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java

@ -0,0 +1,40 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/24 10:14
*/
@Data
public class StaffInitResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 人员ID
*/
private String staffId;
/**
* 姓名
*/
private String name;
/**
* 手机号
*/
private String mobile;
/**
* 性别
*/
private Integer gender;
/**
* 专兼职
*/
private String workType;
/**
* 职责列表
*/
private List<StaffRoleResultDTO> roleList;
}

28
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffRoleResultDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.result;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/24 10:18
*/
@Data
public class StaffRoleResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 角色ID
*/
private String roleId;
/**
* 角色名称
*/
private String roleName;
/**
* 是否选中(选中的是true)
*/
private Boolean selected;
}

41
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java

@ -1,22 +1,11 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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.AddDepartmentFormDTO;
import com.epmet.service.CustomerStaffDepartmentService;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
@ -27,6 +16,24 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Auther zxc
* @Create 2020-04-24 14:48
*/
@RestController
@RequestMapping(value = "/department")
public class DepartmentController {
@Autowired
private CustomerStaffDepartmentService customerStaffDepartmentService;
@PostMapping(value = "adddepartmentstaff")
public Result addDepartmentStaff(@LoginUser TokenDto tokenDto, @RequestBody AddDepartmentFormDTO addDepartmentFormDTO){
return null;
}
}
import java.util.List;

37
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java

@ -1,7 +1,13 @@
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.result.AddGridResultDTO;
import com.epmet.dto.result.GridDetailResultDTO;
import com.epmet.service.CustomerGridService;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,16 +27,41 @@ public class GridController {
@Autowired
private CustomerGridService customerGridService;
/**
* 获取网格详情
* @param customerGridFormDTO
* @return
*/
@PostMapping("griddetail")
public Result<GridDetailResultDTO> griddetail(@RequestBody CustomerGridFormDTO customerGridFormDTO){
public Result<GridDetailResultDTO> gridDetail(@LoginUser TokenDto tokenDto,@RequestBody CustomerGridFormDTO customerGridFormDTO){
Result<GridDetailResultDTO> griddetail = customerGridService.griddetail(customerGridFormDTO);
return griddetail;
}
/*@PostMapping("addgrid")
/**
* 新建当前机关下的所属网格
*/
@PostMapping("addgrid")
public Result<AddGridResultDTO> addGrid(@LoginUser TokenDto tokenDto, @RequestBody AddGridFormDTO addGridFormDTO){
return customerGridService.addGrid(tokenDto,addGridFormDTO);
}
/**
* 管理员修改网格信息
*/
@PostMapping("editgrid")
public Result editGrid(@LoginUser TokenDto tokenDto, @RequestBody EditGridFormDTO editGridFormDTO){
return customerGridService.editGrid(tokenDto,editGridFormDTO);
@PostMapping("deletegrid")*/
}
/**
* 删除网格
*/
@PostMapping("deletegrid")
public Result deleteGrid(@LoginUser TokenDto tokenDto, @RequestBody DeleteGridFormDTO deleteGridFormDTO){
return customerGridService.deleteGrid(tokenDto,deleteGridFormDTO);
}
}

83
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java

@ -3,8 +3,12 @@ package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.StaffDetailResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.result.StaffsInAgencyResultDTO;
import com.epmet.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
@ -33,4 +37,83 @@ public class StaffController {
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
return staffService.getStaffInfoForHome(fromDTO);
}
/**
* 查看人员列表
*
* @param fromDTO 参数
* @return Result<StaffsInAgencyResultDTO>
* @author zhaoqifeng
*/
@PostMapping("stafflist")
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO){
return staffService.getStaffList(fromDTO);
}
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("rolelist")
public Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO){
return staffService.addStaffInit(fromDTO);
}
/**
* 人员编辑页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("editstaffinit")
public Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO){
return staffService.editStaffInit(fromDTO);
}
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("addstaff")
public Result addStaff(StaffSubmitFromDTO fromDTO){
return staffService.addStaff(fromDTO);
}
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("editstaff")
public Result editStaff(StaffSubmitFromDTO fromDTO){
return staffService.editStaff(fromDTO);
}
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
@PostMapping("staffdetail")
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO){
return staffService.getStaffDetail(fromDTO);
}
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("disabledstaff")
public Result disabledStaff(StaffInfoFromDTO fromDTO){
return staffService.disabledStaff(fromDTO);
}
}

38
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java

@ -18,15 +18,19 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.DeleteGridFormDTO;
import com.epmet.dto.form.ListCustomerGridFormDTO;
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.entity.CustomerGridEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -86,4 +90,38 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
*/
List<CustomerStaffGridDTO> selectUserIdByGridId(CustomerGridFormDTO customerGridFormDTO);
/**
* 根据userId查询customerId
* @param userId
* @return
*/
String selectCustomerIdByUserId(@Param("userId") String userId);
/**
* 根据pid查询pids
* @param pid
* @return
*/
String selectPidsByPid(@Param("pid")String pid);
/**
* 根据gridName查询gridId
* @param gridName
* @return
*/
String selectGridIdByGridName(@Param("gridName")String gridName);
/**
* 编辑网格信息
* @param customerGridDTO
*/
void editGrid(CustomerGridDTO customerGridDTO);
/**
* 删除网格
* @param deleteGridFormDTO
*/
void deleteGrid(DeleteGridFormDTO deleteGridFormDTO);
}

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -2,6 +2,7 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.*;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
@ -11,6 +12,7 @@ import com.epmet.dto.result.DepartInStaffListResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.feign.fallback.EpmetUserFeignClientFallBack;
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;
@ -45,6 +47,9 @@ public interface EpmetUserFeignClient {
@PostMapping("/epmetuser/customerstaff/staffsinagency")
Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO);
@PostMapping(value = "/epmetuser/customerstaff/selectgridstaffcountbyuserid")
Result<GridStaffCountDTO> selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO);
/**
* @param departmentInStaffFormDTO
* @return

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java

@ -3,6 +3,7 @@ package com.epmet.feign.fallback;
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.*;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
@ -35,6 +36,11 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffInfoForHome", fromDTO);
}
@Override
public Result<GridStaffCountDTO> selectGridStaffCountByUserId(UserIdDTO userIdDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectGridStaffCountByUserId", userIdDTO);
}
@Override
public Result<List<DepartInStaffListResultDTO>> getDepartmentStaffList(DepartmentInStaffFormDTO departmentInStaffFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getDepartmentStaffList", departmentInStaffFormDTO);

27
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java

@ -18,15 +18,18 @@
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
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.Result;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.ListCustomerGridFormDTO;
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.entity.CustomerGridEntity;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
@ -130,4 +133,24 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @return
*/
Result<GridDetailResultDTO> griddetail(CustomerGridFormDTO customerGridFormDTO);
/**
* 新建当前机关下的所属网格
*/
Result<AddGridResultDTO> addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO);
/**
* 修改网格信息
* @param tokenDto
* @param editGridFormDTO
*/
Result editGrid(TokenDto tokenDto,EditGridFormDTO editGridFormDTO);
/**
* 删除网格
* @param tokenDto
* @param deleteGridFormDTO
* @return
*/
Result deleteGrid(TokenDto tokenDto,DeleteGridFormDTO deleteGridFormDTO);
}

65
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java

@ -1,9 +1,16 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.StaffDetailResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.result.StaffsInAgencyResultDTO;
import java.util.List;
/**
* 组织结构-工作人员
*
@ -19,4 +26,62 @@ public interface StaffService {
* @author zhaoqifeng
*/
Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO);
/**
* 查看人员列表
*
* @param fromDTO 参数
* @return Result<StaffsInAgencyResultDTO>
* @author zhaoqifeng
*/
Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO);
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO);
/**
* 人员编辑页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO);
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
Result addStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
Result editStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO);
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
Result disabledStaff(StaffInfoFromDTO fromDTO);
}

74
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java

@ -21,15 +21,17 @@ 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.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.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.dto.CustomerGridDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.ListCustomerGridFormDTO;
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;
@ -43,10 +45,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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 客户网格表
@ -169,6 +168,11 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
return new Result<List<CustomerGridByUserIdResultDTO>>().ok(baseDao.getMyGrids(userId));
}
/**
* 查询网格详情
* @param customerGridFormDTO
* @return
*/
@Override
public Result<GridDetailResultDTO> griddetail(CustomerGridFormDTO customerGridFormDTO) {
GridDetailResultDTO griddetail = baseDao.griddetail(customerGridFormDTO);
@ -178,4 +182,56 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
return new Result<GridDetailResultDTO>().ok(griddetail);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddGridResultDTO> addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO) {
CustomerGridEntity customerGridEntity = new CustomerGridEntity();
customerGridEntity.setCustomerId(baseDao.selectCustomerIdByUserId(tokenDto.getUserId()));
customerGridEntity.setGridName(addGridFormDTO.getGridName());
customerGridEntity.setDelFlag("0");
customerGridEntity.setCreatedBy(tokenDto.getUserId());
customerGridEntity.setUpdatedBy(tokenDto.getUserId());
customerGridEntity.setTotalUser(0);
customerGridEntity.setManageDistrict(addGridFormDTO.getManageDistrict());
customerGridEntity.setPid(addGridFormDTO.getAgencyId());
customerGridEntity.setPids(baseDao.selectPidsByPid(addGridFormDTO.getAgencyId()));
baseDao.insert(customerGridEntity);
String gridId = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName());
AddGridResultDTO addGridResultDTO = new AddGridResultDTO();
addGridResultDTO.setGridId(gridId);
return new Result<AddGridResultDTO>().ok(addGridResultDTO);
}
/**
* 修改网格信息
* @param tokenDto
* @param editGridFormDTO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result editGrid(TokenDto tokenDto, EditGridFormDTO editGridFormDTO) {
CustomerGridDTO customerGridDTO = new CustomerGridDTO();
customerGridDTO.setManageDistrict(editGridFormDTO.getManageDistrict());
customerGridDTO.setGridName(editGridFormDTO.getGridName());
customerGridDTO.setUpdatedBy(tokenDto.getUserId());
customerGridDTO.setId(editGridFormDTO.getGridId());
baseDao.editGrid(customerGridDTO);
return new Result();
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result deleteGrid(TokenDto tokenDto,DeleteGridFormDTO deleteGridFormDTO) {
UserIdDTO userIdDTO = new UserIdDTO();
userIdDTO.setUserId(tokenDto.getUserId());
deleteGridFormDTO.setUserId(tokenDto.getUserId());
Result<GridStaffCountDTO> gridStaffCountDTOResult = epmetUserFeignClient.selectGridStaffCountByUserId(userIdDTO);
if (gridStaffCountDTOResult.getData().getEnableCount()==0){
baseDao.deleteGrid(deleteGridFormDTO);
}else {
return new Result().error(EpmetErrorCode.NOT_DEL_GRID.getCode());
}
return new Result();
}
}

51
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java

@ -2,8 +2,12 @@ package com.epmet.service.impl;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerStaffAgencyDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.StaffDetailResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.result.StaffsInAgencyResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.feign.EpmetUserFeignClient;
@ -51,4 +55,51 @@ public class StaffServiceImpl implements StaffService {
resultDTO.setStaffList(staffInfoListResult.getData());
return new Result<StaffsInAgencyResultDTO>().ok(resultDTO);
}
@Override
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
//获取机关所在客户ID
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
List<CustomerStaffAgencyDTO> customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData();
if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) {
return new Result<List<StaffInfoResultDTO>>().ok(null);
}
//提取所有userID
List<String> staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList());
fromDTO.setStaffList(staffIds);
//获取用户列表
Result<List<StaffInfoResultDTO>> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO);
return null;
}
@Override
public Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO) {
return null;
}
@Override
public Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO) {
return null;
}
@Override
public Result addStaff(StaffSubmitFromDTO fromDTO) {
return null;
}
@Override
public Result editStaff(StaffSubmitFromDTO fromDTO) {
return null;
}
@Override
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) {
return null;
}
@Override
public Result disabledStaff(StaffInfoFromDTO fromDTO) {
return null;
}
}

56
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

@ -138,4 +138,60 @@
AND grid_id = #{gridId}
</select>
<!-- 根据userId查询customerId -->
<select id="selectCustomerIdByUserId" resultType="string">
SELECT
customer_id
FROM
customer_staff_grid
WHERE
user_id = #{userId}
LIMIT 1
</select>
<!-- 根据pid查询pids -->
<select id="selectPidsByPid" resultType="string">
SELECT
pids
FROM
customer_agency
WHERE
pid = #{pid}
limit 1
</select>
<!-- 根据gridName查询gridId -->
<select id="selectGridIdByGridName" resultType="string">
SELECT
id AS gridId
FROM
customer_grid
WHERE
grid_name = #{gridName}
AND del_flag = 0
</select>
<!-- 修改网格信息 -->
<update id="editGrid">
update
customer_grid
set
grid_name = #{gridName},
manage_district = #{manageDistrict},
updated_by = #{updatedBy}
where
id = #{id}
</update>
<!-- 删除网格 -->
<update id="deleteGrid">
update
customer_grid
set
updated_by = #{userId},
del_flag = 1
where
id = #{gridId}
</update>
</mapper>

56
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java

@ -0,0 +1,56 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 政府端角色表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-22
*/
@Data
public class GovStaffRoleResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 角色ID
*/
private String roleId;
/**
* 人员id
*/
private String staffId;
/**
* 角色key
*/
private String roleKey;
/**
* 角色名称
*/
private String roleName;
}

17
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -25,6 +25,8 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.*;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
@ -157,6 +159,21 @@ public class CustomerStaffController {
return customerStaffService.getStaffInfoForHome(fromDTO);
}
/**
* 工作人员列表
* @param fromDTO
* @return
*/
@PostMapping("stafflist")
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
return customerStaffService.getStaffList(fromDTO);
}
@PostMapping(value = "selectgridstaffcountbyuserid")
public Result<GridStaffCountDTO> selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO){
return customerStaffService.selectGridStaffCountByUserId(userIdDTO);
}
/**
* @param fromDTO
* @return

9
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java

@ -3,8 +3,8 @@ package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.entity.GovStaffRoleEntity;
import com.epmet.service.GovStaffRoleService;
import com.epmet.service.StaffRoleService;
@ -60,12 +60,13 @@ public class StaffRoleController {
* @return
*/
@PostMapping("staffsinrole")
public Result<List<StaffRoleDTO>> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
//@RequirePermission(key = "org_staff_list")
public Result<List<GovStaffRoleResultDTO>> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) {
ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class);
String roleKey = staffRoleFormDTO.getRoleKey();
String orgId = staffRoleFormDTO.getOrgId();
List<StaffRoleDTO> staffRoleDTOS = staffRoleService.listStaffsInRole(roleKey, orgId);
return new Result<List<StaffRoleDTO>>().ok(staffRoleDTOS);
List<GovStaffRoleResultDTO> staffRoleDTOS = staffRoleService.listStaffsInRole(roleKey, orgId);
return new Result<List<GovStaffRoleResultDTO>>().ok(staffRoleDTOS);
}
}

29
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java

@ -18,10 +18,10 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.*;
import com.epmet.dto.form.CustomerStaffFormDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.DepartmentInStaffFormDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.DepartInStaffListResultDTO;
@ -60,6 +60,12 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
CustomerStaffDTO selectStaffInfoByUserId(CustomerStaffDTO formDTO);
/**
* 根据userId查询网格下未被禁用的人员数量
* @param userIdDTO
* @return
*/
GridStaffCountDTO selectGridStaffCountByUserId(UserIdDTO userIdDTO);
/**
* 根据userId查询查询网格下的用户信息
*
@ -85,6 +91,23 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
**/
CustomerStaffEntity selectByUserId(String userId);
/**
* 工作人员列表
*
* @param fromDTO
* @return
*/
List<StaffInfoResultDTO> selectStaffList(StaffsInAgencyFromDTO fromDTO);
/**
* 获取工作人员详情
* @param fromDTO
* @return
*/
CustomerStaffDTO selectStaffInfo(StaffInfoFromDTO fromDTO);
/**
* @param fromDTO
* @return

7
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.entity.GovStaffRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -41,4 +42,10 @@ public interface GovStaffRoleDao extends BaseDao<GovStaffRoleEntity> {
*/
List<GovStaffRoleEntity> listRolesByStaffId(@Param("staffId") String staffId, @Param("orgId") String orgId);
/**
* 获取客户机关角色列表
* @param params
* @return
*/
List<GovStaffRoleDTO> selectGovStaffRoleList(GovStaffRoleDTO params);
}

4
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java

@ -18,7 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.entity.StaffRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -39,5 +39,5 @@ public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
* @param orgId
* @return
*/
List<StaffRoleDTO> listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId);
List<GovStaffRoleResultDTO> listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId);
}

68
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java

@ -20,14 +20,20 @@ package com.epmet.service;
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.*;
import com.epmet.dto.form.CustomerGridFormDTO;
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.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.entity.CustomerStaffEntity;
import java.util.List;
@ -143,6 +149,68 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
*/
Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO);
/**
* 工作人员列表
* @param fromDTO
* @return
*/
Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO);
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO);
/**
* 人员编辑页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO);
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
Result addStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
Result editStaff(StaffSubmitFromDTO fromDTO);
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO);
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
Result disabledStaff(StaffInfoFromDTO fromDTO);
/**
* 根据userId查询网格下未被禁用的人员数量
* @param userIdDTO
* @return
*/
Result<GridStaffCountDTO> selectGridStaffCountByUserId(UserIdDTO userIdDTO);
/**
* @param fromDTO
* @return

7
epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java

@ -99,4 +99,11 @@ public interface GovStaffRoleService extends BaseService<GovStaffRoleEntity> {
* @return
*/
List<GovStaffRoleEntity> listRolesByStaffId(String staffId, String orgId);
/**
* 获取当前机关下的角色列表
* @param dto
* @return
*/
List<GovStaffRoleDTO> getGovStaffRoleList(GovStaffRoleDTO dto);
}

3
epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java

@ -20,6 +20,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.entity.StaffRoleEntity;
import java.util.List;
@ -99,5 +100,5 @@ public interface StaffRoleService extends BaseService<StaffRoleEntity> {
* @param orgId
* @return
*/
List<StaffRoleDTO> listStaffsInRole(String roleKey, String orgId);
List<GovStaffRoleResultDTO> listStaffsInRole(String roleKey, String orgId);
}

274
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -29,19 +29,30 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserConstant;
import com.epmet.constant.UserRoleConstant;
import com.epmet.dao.CustomerStaffDao;
import com.epmet.dto.*;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.StaffGridListDTO;
import com.epmet.dto.StaffRoleDTO;
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.StaffRoleFormDTO;
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.StaffRoleResultDTO;
import com.epmet.entity.CustomerStaffEntity;
import com.epmet.entity.GovStaffRoleEntity;
import com.epmet.redis.CustomerStaffRedis;
import com.epmet.service.CustomerStaffService;
import com.epmet.service.GovStaffRoleService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -52,6 +63,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 政府工作人员表
@ -59,107 +71,205 @@ import java.util.Map;
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-18
*/
@Slf4j
@Service
public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao, CustomerStaffEntity> implements CustomerStaffService {
private Logger logger = LogManager.getLogger(getClass());
@Autowired
private CustomerStaffRedis customerStaffRedis;
private Logger logger = LogManager.getLogger(getClass());
@Autowired
private CustomerStaffRedis customerStaffRedis;
@Autowired
private GovStaffRoleService govStaffRoleService;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
IPage<CustomerStaffEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerStaffDTO.class);
}
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
IPage<CustomerStaffEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, CustomerStaffDTO.class);
}
@Override
public List<CustomerStaffDTO> list(Map<String, Object> params) {
List<CustomerStaffEntity> entityList = baseDao.selectList(getWrapper(params));
@Override
public List<CustomerStaffDTO> list(Map<String, Object> params) {
List<CustomerStaffEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, CustomerStaffDTO.class);
}
return ConvertUtils.sourceToTarget(entityList, CustomerStaffDTO.class);
}
private QueryWrapper<CustomerStaffEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<CustomerStaffEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerStaffEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
QueryWrapper<CustomerStaffEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
return wrapper;
}
@Override
public CustomerStaffDTO get(String id) {
CustomerStaffEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerStaffDTO.class);
}
@Override
public CustomerStaffDTO get(String id) {
CustomerStaffEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, CustomerStaffDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerStaffDTO dto) {
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(CustomerStaffDTO dto) {
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerStaffDTO dto) {
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CustomerStaffDTO dto) {
CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(String mobile) {
//判断用户是否存在
List<CustomerStaffDTO> customerStaffDTOList = baseDao.selectListCustomerStaffDTO(mobile);
if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", mobile, EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode());
}
return new Result<List<CustomerStaffDTO>>().ok(customerStaffDTOList);
}
@Override
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(String mobile) {
//判断用户是否存在
List<CustomerStaffDTO> customerStaffDTOList = baseDao.selectListCustomerStaffDTO(mobile);
if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", mobile, EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode());
}
return new Result<List<CustomerStaffDTO>>().ok(customerStaffDTOList);
}
@Override
public Result<CustomerStaffDTO> getCustomerStaffInfo(CustomerStaffFormDTO formDTO) {
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(formDTO);
if (null == customerStaffDTO) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", formDTO.getMobile(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode());
}
//判断用户是否已被禁用
if (null != customerStaffDTO && UserConstant.DISABLED.equals(customerStaffDTO.getEnableFlag())) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), EpmetErrorCode.GOV_STAFF_DISABLED.getCode(), EpmetErrorCode.GOV_STAFF_DISABLED.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode());
}
return new Result<CustomerStaffDTO>().ok(customerStaffDTO);
}
@Override
public Result<CustomerStaffDTO> getCustomerStaffInfo(CustomerStaffFormDTO formDTO) {
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(formDTO);
if (null == customerStaffDTO) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", formDTO.getMobile(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode());
}
//判断用户是否已被禁用
if (null != customerStaffDTO && UserConstant.DISABLED.equals(customerStaffDTO.getEnableFlag())) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), EpmetErrorCode.GOV_STAFF_DISABLED.getCode(), EpmetErrorCode.GOV_STAFF_DISABLED.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode());
}
return new Result<CustomerStaffDTO>().ok(customerStaffDTO);
}
@Override
public Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) {
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfoByUserId(formDTO);
return new Result<CustomerStaffDTO>().ok(customerStaffDTO);
}
@Override
public Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) {
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfoByUserId(formDTO);
return new Result<CustomerStaffDTO>().ok(customerStaffDTO);
}
@Override
public Result<List<StaffGridListDTO>> selectStaffGridListByUserId(List<CustomerStaffGridDTO> customerStaffGridDTOS) {
List<StaffGridListDTO> staffGridListDTOS = baseDao.selectStaffGridListByUserId(customerStaffGridDTOS);
return new Result<List<StaffGridListDTO>>().ok(staffGridListDTOS);
}
@Override
public Result<List<StaffGridListDTO>> selectStaffGridListByUserId(List<CustomerStaffGridDTO> customerStaffGridDTOS) {
List<StaffGridListDTO> staffGridListDTOS = baseDao.selectStaffGridListByUserId(customerStaffGridDTOS);
return new Result<List<StaffGridListDTO>>().ok(staffGridListDTOS);
}
@Override
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
List<StaffInfoResultDTO> list = baseDao.selectCustomerStaffList(fromDTO);
return new Result<List<StaffInfoResultDTO>>().ok(list);
}
@Override
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
List<StaffInfoResultDTO> list = baseDao.selectStaffList(fromDTO);
return new Result<List<StaffInfoResultDTO>>().ok(list);
}
@Override
public Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO) {
StaffInitResultDTO resultDTO = new StaffInitResultDTO();
GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO();
govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId());
List<GovStaffRoleDTO> roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO);
if (null == roleList || roleList.size() == 0) {
return new Result<StaffInitResultDTO>().ok(null);
}
List<StaffRoleResultDTO> staffRoleList = roleList.stream().map(p -> {
StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO();
staffRoleResultDTO.setRoleId(p.getId());
staffRoleResultDTO.setRoleName(p.getRoleName());
return staffRoleResultDTO;
}).collect(Collectors.toList());
resultDTO.setRoleList(staffRoleList);
return new Result<StaffInitResultDTO>().ok(resultDTO);
}
@Override
public Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO) {
StaffInitResultDTO resultDTO = new StaffInitResultDTO();
//获取工作人员信息
CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO);
if (null == customerStaffDTO) {
log.error("工作人员不存在");
}
resultDTO.setStaffId(customerStaffDTO.getUserId());
resultDTO.setName(customerStaffDTO.getRealName());
resultDTO.setGender(customerStaffDTO.getGender());
resultDTO.setMobile(customerStaffDTO.getMobile());
resultDTO.setWorkType(customerStaffDTO.getWorkType());
//获取角色列表
GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO();
govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId());
List<GovStaffRoleDTO> roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO);
//获取工作人员角色
List<GovStaffRoleEntity> staffRoles = govStaffRoleService.listRolesByStaffId(fromDTO.getStaffId(), fromDTO.getAgencyId());
List<StaffRoleResultDTO> staffRoleList = roleList.stream().map(p -> {
StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO();
staffRoleResultDTO.setRoleId(p.getId());
staffRoleResultDTO.setRoleName(p.getRoleName());
staffRoleResultDTO.setSelected(false);
return staffRoleResultDTO;
}).collect(Collectors.toList());
staffRoleList.forEach(role -> staffRoles.forEach(staffRole -> {
if (role.getRoleId().equals(staffRole.getId())) {
role.setSelected(true);
}
}));
resultDTO.setRoleList(staffRoleList);
return new Result<StaffInitResultDTO>().ok(resultDTO);
}
@Override
public Result addStaff(StaffSubmitFromDTO fromDTO) {
return null;
}
@Override
public Result editStaff(StaffSubmitFromDTO fromDTO) {
return null;
}
@Override
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) {
return null;
}
@Override
public Result disabledStaff(StaffInfoFromDTO fromDTO) {
return null;
}
/**
* 根据userId查询网格下未被禁用的人员数量
* @param userIdDTO
* @return
*/
@Override
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
List<StaffInfoResultDTO> list = baseDao.selectCustomerStaffList(fromDTO);
return new Result<List<StaffInfoResultDTO>>().ok(list);
public Result<GridStaffCountDTO> selectGridStaffCountByUserId(UserIdDTO userIdDTO) {
Result<GridStaffCountDTO> gridStaffCountDTOResult = new Result<GridStaffCountDTO>();
GridStaffCountDTO gridStaffCountDTO = baseDao.selectGridStaffCountByUserId(userIdDTO);
gridStaffCountDTOResult.setData(gridStaffCountDTO);
return gridStaffCountDTOResult;
}
@Override

5
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java

@ -110,4 +110,9 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go
public List<GovStaffRoleEntity> listRolesByStaffId(String staffId, String orgId) {
return baseDao.listRolesByStaffId(staffId, orgId);
}
@Override
public List<GovStaffRoleDTO> getGovStaffRoleList(GovStaffRoleDTO dto) {
return baseDao.selectGovStaffRoleList(dto);
}
}

4
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java

@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.StaffRoleDao;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.entity.StaffRoleEntity;
import com.epmet.redis.StaffRoleRedis;
import com.epmet.service.StaffRoleService;
@ -108,7 +109,8 @@ public class StaffRoleServiceImpl extends BaseServiceImpl<StaffRoleDao, StaffRol
* @return
*/
@Override
public List<StaffRoleDTO> listStaffsInRole(String roleKey, String orgId) {
//@DataFilter
public List<GovStaffRoleResultDTO> listStaffsInRole(String roleKey, String orgId) {
return baseDao.listStaffIdsByRoleKeyAndOrgId(roleKey, orgId);
}

57
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

@ -30,7 +30,8 @@
cs.id AS staffId,
cs.real_name AS staffName,
cs.head_photo AS staffHeadPhoto,
gsr.role_name AS roleName
gsr.role_name AS roleName,
cs.gender
FROM
customer_staff cs
LEFT JOIN gov_staff_role gsr ON cs.user_id = gsr.id
@ -41,12 +42,24 @@
</foreach>
AND cs.del_flag = 0
</select>
<!-- 根据userId查询网格下未被禁用的人员数量 -->
<select id="selectGridStaffCountByUserId" parameterType="com.epmet.dto.UserIdDTO" resultType="com.epmet.dto.GridStaffCountDTO">
SELECT
count(*) AS enableCount
FROM
customer_staff
WHERE
user_id = #{userId}
AND del_flag = 0
AND enable_flag = 'enable'
</select>
<select id="selectCustomerStaffList" resultType="com.epmet.dto.result.StaffInfoResultDTO" parameterType="com.epmet.dto.form.StaffsInAgencyFromDTO">
SELECT
cs.USER_ID AS "staffId",
cs.REAL_NAME AS "staffName",
cs.GENDER AS "gender",
cs.HEAD_PHOTO AS "staffHeadPhoto",
IFNULL(cs.HEAD_PHOTO, "") AS "staffHeadPhoto",
cs.ENABLE_FLAG AS "enableFlag",
gsr.ROLE_NAME AS "roleName"
FROM
@ -60,8 +73,8 @@
AND gsr.ROLE_KEY = 'agency_leader'
WHERE
cs.DEL_FLAG = '0'
AND
cs.USER_ID in
AND cs.CUSTOMER_ID = #{customerId}
AND cs.USER_ID in
<foreach item="userId" collection="staffList" separator="," open="(" close=")" index="">
#{userId}
</foreach>
@ -79,6 +92,42 @@
cs.DEL_FLAG = '0'
AND CS.USER_ID =#{userId}
</select>
<select id="selectStaffList" resultType="com.epmet.dto.result.StaffInfoResultDTO" parameterType="com.epmet.dto.form.StaffsInAgencyFromDTO">
SELECT
cs.USER_ID AS "staffId",
cs.REAL_NAME AS "staffName",
cs.GENDER AS "gender",
IFNULL(cs.HEAD_PHOTO, "") AS "staffHeadPhoto",
cs.ENABLE_FLAG AS "enableFlag"
FROM
customer_staff cs
WHERE
cs.DEL_FLAG = '0'
AND cs.CUSTOMER_ID = #{customerId}
AND cs.USER_ID in
<foreach item="userId" collection="staffList" separator="," open="(" close=")" index="">
#{userId}
</foreach>
ORDER BY convert(cs.REAL_NAME using gbk) asc ASC
</select>
<select id="selectStaffInfo" resultType="com.epmet.dto.CustomerStaffDTO" parameterType="com.epmet.dto.form.StaffInfoFromDTO">
SELECT
USER_ID,
REAL_NAME,
MOBILE,
GENDER,
IFNULL(HEAD_PHOTO, "") AS "headPhoto",
ENABLE_FLAG,
ACTIVE_FLAG,
ACTIVE_TIME,
WORK_TYPE
FROM
customer_staff
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND USER_ID = #{staffId}
</select>
<select id="selectDepartmentStaffList" resultType="com.epmet.dto.result.DepartInStaffListResultDTO">
SELECT
user_id AS 'staffId',

13
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

@ -23,9 +23,20 @@
r.*
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID )
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID ) AND r.DEL_FLAG = '0'
WHERE
sr.STAFF_ID = #{staffId}
AND sr.ORG_ID = #{orgId}
AND sr.DEL_FLAG = '0'
</select>
<select id="selectGovStaffRoleList" resultType="com.epmet.dto.GovStaffRoleDTO" parameterType="com.epmet.dto.GovStaffRoleDTO">
select
*
from
gov_staff_role
where
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND ORG_TYPE = 'agency'
</select>
</mapper>

5
epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

@ -18,9 +18,8 @@
<!--查询具有某角色的staff列表-->
<select id="listStaffIdsByRoleKeyAndOrgId" resultType="com.epmet.dto.StaffRoleDTO">
SELECT
sr.*
<select id="listStaffIdsByRoleKeyAndOrgId" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
SELECT sr.STAFF_ID, sr.ROLE_ID, r.ROLE_NAME, r.ROLE_KEY
FROM
staff_role sr
INNER JOIN gov_staff_role r ON ( sr.ROLE_ID = r.ID )

Loading…
Cancel
Save