Browse Source

Merge remote-tracking branch 'origin/dev_govorg' into dev_govorg

# Conflicts:
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.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-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
#	epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java
#	epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
#	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
dev_shibei_match
wangchao 5 years ago
parent
commit
2f54e53fe5
  1. 2
      epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java
  2. 2
      epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java
  3. 19
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
  4. 63
      epmet-auth/src/test/java/com/epmet/TokenGenTest.java
  5. 20
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java
  6. 172
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java
  7. 106
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java
  8. 26
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java
  9. 9
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java
  10. 26
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java
  11. 25
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java
  12. 8
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java
  13. 6
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java
  14. 100
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java
  15. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java
  16. 46
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java
  17. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  18. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java
  19. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java
  20. 61
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java
  21. 8
      epmet-gateway/pom.xml
  22. 3
      epmet-gateway/src/main/java/com/epmet/filter/FeignRequestFilter.java
  23. 44
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java
  24. 54
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java
  25. 18
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java
  26. 51
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  27. 2
      epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql
  28. 11
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java
  29. 3
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java
  30. 18
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java
  31. 17
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java
  32. 3
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java
  33. 3
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/StaffAgencyService.java
  34. 16
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  35. 9
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/StaffAgencyServiceImpl.java
  36. 10
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java
  37. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java
  38. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java
  39. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java
  40. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java
  41. 71
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java
  42. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java
  43. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java
  44. 30
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java
  45. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java
  46. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java
  47. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java
  48. 54
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java
  49. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java
  50. 42
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java
  51. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java
  52. 61
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java
  53. 30
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java
  54. 40
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java
  55. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java
  56. 51
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java
  57. 7
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java
  58. 60
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java
  59. 57
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java
  60. 47
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java
  61. 49
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java
  62. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/LatestCustomerResultDTO.java
  63. 55
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java
  64. 38
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java
  65. 40
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java
  66. 13
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffOrgsResultDTO.java
  67. 28
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffRoleResultDTO.java
  68. 27
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java
  69. 30
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java
  70. 113
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  71. 61
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  72. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java
  73. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java
  74. 102
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java
  75. 37
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java
  76. 122
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java
  77. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  78. 21
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java
  79. 37
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  80. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java
  81. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java
  82. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java
  83. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java
  84. 0
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep
  85. 92
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  86. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java
  87. 60
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java
  88. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java
  89. 83
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
  90. 45
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  91. 25
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  92. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java
  93. 80
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java
  94. 88
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java
  95. 187
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  96. 145
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  97. 69
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  98. 19
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java
  99. 200
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java
  100. 124
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java

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");

2
epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java

@ -34,6 +34,6 @@ public class GovWxmpEnteOrgFormDTO implements Serializable {
* 选择的要进入的组织(根组织id)
*/
@NotBlank(message = "组织id不能为空")
private String agencyId;
private String rootAgencyId;
}

19
epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java

@ -127,6 +127,9 @@ public class GovLoginServiceImpl implements GovLoginService {
public Result<UserTokenResultDTO> loginByWxCode(GovWxmpFormDTO formDTO) {
//1、解析微信用户
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode());
if(null!=wxMaJscode2SessionResult){
logger.info(String.format("app=%s,wxCode=%s,openId=%s",formDTO.getApp(),formDTO.getWxCode(),wxMaJscode2SessionResult.getOpenid()));
}
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserFeignClient.getLatestStaffWechatLoginRecord(wxMaJscode2SessionResult.getOpenid());
if (!latestStaffWechat.success() || null == latestStaffWechat.getData()) {
logger.error(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg()));
@ -193,14 +196,14 @@ public class GovLoginServiceImpl implements GovLoginService {
CustomerStaffDTO customerStaff = customerStaffDTOResult.getData();
//2、解析微信用户
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode());
//3、记录staff_wechat
//3、记录staff_wechat,并记录用户激活状态,激活时间
this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid());
//5、记录登录日志
//4、记录登录日志
this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid());
//1、获取用户token
//5.1、获取用户token
String token = this.generateGovWxmpToken(customerStaff.getUserId());
//2、保存到redis
this.saveGovTokenDto(formDTO.getAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token);
//5.2、保存到redis
this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token);
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token);
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO);
@ -223,7 +226,7 @@ public class GovLoginServiceImpl implements GovLoginService {
staffLoginAgencyRecordFormDTO.setStaffId(staffId);
staffLoginAgencyRecordFormDTO.setWxOpenId(openId);
staffLoginAgencyRecordFormDTO.setMobile(formDTO.getMobile());
staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getAgencyId());
staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getRootAgencyId());
Result staffLoginRecordResult = epmetUserFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO);
return staffLoginRecordResult;
}
@ -252,9 +255,9 @@ public class GovLoginServiceImpl implements GovLoginService {
Map<String, Object> map = new HashMap<>();
map.put("app", LoginConstant.APP_GOV);
map.put("client", LoginConstant.CLIENT_WXMP);
map.put("staffId", staffId);
map.put("userId", staffId);
String token = jwtTokenUtils.createToken(map);
logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";staffId:" + staffId + ";生成token[" + token + "]");
logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";userId:" + staffId + ";生成token[" + token + "]");
return token;
}

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,9 +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(8202, "该机关存在下级机关,不允许删除"),
NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"),
NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"),
REQUIRE_PERMISSION(8301, "没有足够的操作权限");
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));

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

@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
/**
* @Description 政府端登录信息
@ -62,5 +63,10 @@ public class GovTokenDto extends BaseTokenDto implements Serializable {
* 最后一次更新时间
*/
private long updateTime;
/**
* 功能权限列表实际上是gov_staff => staff_role => role_operation查询到的operationKey
*/
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());
}

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

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

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

@ -0,0 +1,54 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.service.AccessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Set;
/**
* 权限相关Api
* @Author wxz
* @Description
* @Date 2020/4/23 17:54
**/
@RestController
@RequestMapping("access")
public class AccessController {
@Autowired
private AccessService accessService;
/**
* 更新工作人员权限缓存
* @param staffPermCacheFormDTO
* @return
*/
@PostMapping("updatepermissioncache")
public Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO) {
ValidatorUtils.validateEntity(staffPermCacheFormDTO, StaffPermCacheFormDTO.UpdatePermissionCache.class);
String staffId = staffPermCacheFormDTO.getStaffId();
String app = staffPermCacheFormDTO.getApp();
String client = staffPermCacheFormDTO.getClient();
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);
}
}

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

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

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

@ -0,0 +1,51 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.service.AccessService;
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.HashSet;
import java.util.Set;
@Service
public class AccessServiceImpl implements AccessService {
private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class);
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
/**
* 更新权限缓存
* @param staffId
* @param permissions
*/
@Override
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);
return ;
}
govTokenDto.setPermissions(permissions);
// 将新的TokenDto更新到redis中
long expire = cpUserDetailRedis.getExpire(app, client, staffId);
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);
}
}

3
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java

@ -34,7 +34,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
import java.util.Set;
/**
* 机关单位信息表
@ -78,7 +77,7 @@ public class StaffAgencyController {
* @Date 2020/4/23 10:34
**/
@PostMapping("switchgrid")
public Result<Set<String>> switchGrid(@LoginUser TokenDto tokenDto, @RequestBody @Valid SwitchGridFormDTO switchGridFormDTO) {
public Result switchGrid(@LoginUser TokenDto tokenDto, @RequestBody @Valid SwitchGridFormDTO switchGridFormDTO) {
switchGridFormDTO.setStaffId(tokenDto.getUserId());
return staffAgencyService.switchGrid(switchGridFormDTO);
}

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);
}

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

@ -25,7 +25,6 @@ import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import java.util.List;
import java.util.Set;
/**
* 机关单位信息表
@ -57,7 +56,7 @@ public interface StaffAgencyService {
* @Description 切换网格
* @Date 2020/4/23 10:49
**/
Result<Set<String>> switchGrid(SwitchGridFormDTO switchGridFormDTO);
Result switchGrid(SwitchGridFormDTO switchGridFormDTO);
/**
* @Description 得到工作人员最后一次登录的网格

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;
}
}

9
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/StaffAgencyServiceImpl.java

@ -37,7 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
/**
* 机关单位信息表
@ -94,17 +93,17 @@ public class StaffAgencyServiceImpl implements StaffAgencyService {
@Override
public Result<Set<String>> switchGrid(SwitchGridFormDTO switchGridFormDTO) {
public Result switchGrid(SwitchGridFormDTO switchGridFormDTO) {
//记录网格访问记录
StaffGridVisitedFormDTO staffGridVisitedFormDTO = ConvertUtils.sourceToTarget(switchGridFormDTO, StaffGridVisitedFormDTO.class);
Result saveStaffGridVisitedRecord = epmetUserFeignClient.saveStaffGridVisitedRecord(staffGridVisitedFormDTO);
if (!saveStaffGridVisitedRecord.success()) {
logger.error("保存网格访问记录失败");
return new Result<Set<String>>().error();
}
//查询网格的权限
/* //查询网格的权限
Set<String> opeKeys = accessService.listOpeKeysByStaffId(switchGridFormDTO.getStaffId(), null, switchGridFormDTO.getGridId());
return new Result<Set<String>>().ok(opeKeys);
return new Result<Set<String>>().ok(opeKeys);*/
return new Result();
}

10
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java

@ -112,11 +112,6 @@ public class CustomerAgencyDTO implements Serializable {
*/
private Integer totalUser;
/**
* 国家
*/
private String country;
/**
* 省份
*/
@ -126,5 +121,10 @@ public class CustomerAgencyDTO implements Serializable {
* 城市
*/
private String city;
/**
* 区县
*/
private String district;
}

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;
}

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

@ -62,7 +62,7 @@ public class AddAgencyFormDTO implements Serializable {
/**
* 国家
*/
private String country;
private String district;
/**
* 省份

71
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java

@ -0,0 +1,71 @@
package com.epmet.dto.form;
/**
* 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/>.
*/
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 添加部门人员DTO
* @Auther zxc
* @Create 2020-04-24 14:51
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 添加部门-接口入参
*
* @author sun
*/
@Data
public class AddDepartmentFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*部门id
*/
private String departmentId;
/**
* 选中人员id
*/
private List<String> selectedList;
/**
* 所属组织机构IDcustomer_agency.id
*/
@NotBlank(message = "组织机构Id不能为空")
private String agencyId;
/**
* 部门名称
*/
private String departmentName;
/**
* 部门职责
*/
private String departmentDuty;
}

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;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java

@ -0,0 +1,43 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 获取组织列表-接口入参
*
* @author sun
*/
@Data
public class AgencyListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "组织机构ID不能为空")
private String agencyId;
}

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;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java

@ -0,0 +1,43 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 组织首页-获取机关下部门列表-接口入参
*
* @author sun
*/
@Data
public class DepartmentInAgencyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "组织机构ID不能为空")
private String agencyId;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java

@ -0,0 +1,43 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 获取部门列表-接口入参
*
* @author sun
*/
@Data
public class DepartmentListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "组织机构ID不能为空")
private String agencyId;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java

@ -0,0 +1,43 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 获取部门详情-接口入参
*
* @author sun
*/
@Data
public class DepartmentdetailFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门Id
*/
@NotBlank(message = "部门ID不能为空")
private String departmentId;
}

54
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java

@ -0,0 +1,54 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 部门信息修改-接口入参
*
* @author sun
*/
@Data
public class EditDepartmentFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门Id
*/
@NotBlank(message = "部门ID不能为空")
private String departmentId;
/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空")
private String departmentName;
/**
* 部门职责
*/
@NotBlank(message = "部门职责不能为空")
private String departmentDuty;
}

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;
}

42
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java

@ -0,0 +1,42 @@
/**
* 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.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 删除部门-接口入参
*
* @author sun
*/
@Data
public class RemoveDepartmentFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门Id
*/
@NotBlank(message = "部门ID不能为空")
private String departmentId;
}

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;
}

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

@ -0,0 +1,61 @@
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;
/**
* 来源app(政府端:gov居民端:resi运营端:oper)
*/
private String app;
/**
* 来源client(PC端:web微信小程序:wxmp)
*/
private String client;
}

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

@ -0,0 +1,30 @@
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/23 15:45
*/
@Data
public class StaffsInAgencyFromDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 机关ID
*/
@NotBlank(message = "机关ID不能为空")
private String agencyId;
/**
* 用户ID
*/
private List<String> staffList;
}

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

@ -0,0 +1,40 @@
/**
* 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;
/**
* 添加部门-接口返参
*
* @author sun
*/
@Data
public class AddDepartmentResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 新增部门Id
*/
private String departmentId;
}

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;
}

51
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java

@ -0,0 +1,51 @@
/**
* 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;
/**
* 获取组织列表-接口返参
*
* @author sun
*/
@Data
public class AgencyListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
private String agencyId;
/**
* 机关组织名称
*/
private String agencyName;
/**
* 总人数
*/
private Integer totalUser;
}

7
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencydetailResultDTO.java → epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java

@ -19,18 +19,17 @@ package com.epmet.dto.result;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 组织首页-获取组织机构信息接口返参
* 添加组织-接口返参
*
* @author sun
*/
@Data
public class AgencydetailResultDTO implements Serializable {
public class AgencysResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ -77,6 +76,4 @@ public class AgencydetailResultDTO implements Serializable {
* 本机关的所有上级机关
*/
private List<ParentListResultDTO> parentList;
}

60
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java

@ -0,0 +1,60 @@
/**
* 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;
/**
* 获取部门详情-部门下工作人员列表
*
* @author sun
*/
@Data
public class DepartInStaffListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private String staffId;
/**
* 用户姓名
*/
private String staffName;
/**
* 用户头像
*/
private String staffHeadPhoto;
/**
* 性别
*/
private Integer gender;
/**
* 角色名称
*/
private String roleName;
}

57
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java

@ -0,0 +1,57 @@
/**
* 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.List;
/**
* 获取部门详情-接口返参
*
* @author sun
*/
@Data
public class DepartmentDetailResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门Id
*/
private String departmentId;
/**
* 部门名称
*/
private String departmentName;
/**
* 部门职责
*/
private String departmentDuty;
/**
* 部门下工作人员列表
*/
private List<DepartInStaffListResultDTO> staffList;
}

47
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java

@ -0,0 +1,47 @@
/**
* 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.List;
/**
* 组织首页-获取机关下部门列表-接口返参
*
* @author sun
*/
@Data
public class DepartmentInAgencyResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关下总部门数
*/
private Integer departmentCount;
/**
* 机关下部门列表
*/
private List<DepartmentListResultDTO> departmentList;
}

49
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java

@ -0,0 +1,49 @@
/**
* 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;
/**
* 组织首页-获取机关下部门列表-部门详情数据
*
* @author sun
*/
@Data
public class DepartmentListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门Id
*/
private String departmentId;
/**
* 部门名称
*/
private String departmentName;
/**
* 部门下总人数
*/
private Integer totalUser;
}

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/LatestCustomerResultDTO.java

@ -21,7 +21,7 @@ public class LatestCustomerResultDTO implements Serializable {
*/
private String customerName;
/**
* 客户顶级名称
* 用户所属组织id任意一条
*/
private String agencyId;
/**
@ -29,7 +29,7 @@ public class LatestCustomerResultDTO implements Serializable {
*/
private String staffHeadPhoto;
/**
* 性别
* 性别0未知1男2女
*/
private Integer gender;
}

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

@ -0,0 +1,55 @@
package com.epmet.dto.result;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
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 Date activeTime;
/**
* 性别
*/
private Integer gender;
/**
* 是否禁用(未禁用enable,已禁用disabled)
*/
private String enableFlag;
/**
* 职责名称列表
*/
private List<String> roles;
}

38
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java

@ -0,0 +1,38 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/23 16:08
*/
@Data
public class StaffInfoResultDTO implements Serializable {
/**
* 用户ID
*/
private String staffId;
/**
* 用户姓名
*/
private String staffName;
/**
* 头像
*/
private String staffHeadPhoto;
/**
* 性别
*/
private Integer gender;
/**
* 是否禁用未禁用enable,已禁用disabled
*/
private String enableFlag;
/**
* 权限名
*/
private String roleName;
}

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;
}

13
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffOrgsResultDTO.java

@ -14,9 +14,14 @@ public class StaffOrgsResultDTO implements Serializable {
private static final long serialVersionUID = -9148184731135509803L;
/**
* 组织id
* 根级根级组织id
*/
private String orgId;
private String rootAgencyId;
/**
* 根级组织名称
*/
private String rootAgencyName;
/**
* 客户id
@ -24,8 +29,8 @@ public class StaffOrgsResultDTO implements Serializable {
private String customerId;
/**
* 组织名称
* 客户名称
*/
private String orgName;
private String customerName;
}

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;
}

27
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java

@ -0,0 +1,27 @@
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/23 15:58
*/
@NoArgsConstructor
@Data
public class StaffsInAgencyResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 人员总数
*/
private Integer staffCount;
/**
* 人员列表
*/
private List<StaffInfoResultDTO> staffList;
}

30
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java

@ -0,0 +1,30 @@
package com.epmet.constant;
/**
* @author sun
* @dscription
*/
public interface CustomerDepartmentConstant {
/**
* 部门信息编辑修改失败
*/
String UPDATE_EXCEPTION = "部门信息更新失败";
/**
* 添加部门失败
*/
String SAVE_EXCEPTION = "添加部门失败";
/**
* 部门删除失败
*/
String DEL_EXCEPTION = "删除部门失败";
/**
* 查询用户基本信息失败
*/
String SELECT_STAFFINFO_EXCEPTION = "根据用户Id未查询到用户基本信息";
/**
* 查询部门人员角色
*/
String SELECT_ROLE_EXCEPTION = "查询部门人员角色失败";
}

113
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -0,0 +1,113 @@
/**
* 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.utils.Result;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.dto.result.AgencyListResultDTO;
import com.epmet.dto.result.AgencysResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import com.epmet.service.AgencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 组织机构
*
* @author generator generator@elink-cn.com
*/
@RestController
@RequestMapping("agency")
public class AgencyController {
@Autowired
private AgencyService agencyService;
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
@PostMapping("addagency")
public Result<AddAgencyResultDTO> addAgency(@RequestBody AddAgencyFormDTO formDTO) {
return agencyService.addAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
@PostMapping("editagency")
public Result editAgency(@RequestBody EditAgencyFormDTO formDTO) {
return agencyService.editAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
@PostMapping("removeagency")
public Result removeAgency(@RequestBody RemoveAgencyFormDTO formDTO) {
return agencyService.removeAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
@PostMapping("agencydetail")
public Result<AgencysResultDTO> agencyDetail(@RequestBody AgencydetailFormDTO formDTO) {
return agencyService.agencyDetail(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
@PostMapping("subagencylist")
public Result<SubAgencyResultDTO> subAgencyList(@RequestBody SubAgencyFormDTO formDTO) {
return agencyService.subAgencyList(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取组织列表
*/
@PostMapping("agencylist")
public Result<List<AgencyListResultDTO>> agencyList(@RequestBody AgencyListFormDTO formDTO) {
return agencyService.agencyList(formDTO);
}
}

61
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -26,11 +26,8 @@ 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.CustomerAgencyDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.dto.result.AgencydetailResultDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import com.epmet.excel.CustomerAgencyExcel;
import com.epmet.service.CustomerAgencyService;
import org.springframework.beans.factory.annotation.Autowired;
@ -107,60 +104,4 @@ public class CustomerAgencyController {
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(@RequestBody StaffOrgFormDTO staffOrgsFormDTO) {
return customerAgencyService.getStaffOrgList(staffOrgsFormDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
@PostMapping("addagency")
public Result<AddAgencyResultDTO> addAgency(@RequestBody AddAgencyFormDTO formDTO) {
return customerAgencyService.addAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
@PostMapping("editagency")
public Result editAgency(@RequestBody EditAgencyFormDTO formDTO) {
return customerAgencyService.editAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
@PostMapping("removeagency")
public Result removeAgency(@RequestBody RemoveAgencyFormDTO formDTO) {
return customerAgencyService.removeAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
@PostMapping("agencydetail")
public Result<AgencydetailResultDTO> agencyDetail(@RequestBody AgencydetailFormDTO formDTO) {
return customerAgencyService.agencyDetail(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
@PostMapping("subagencylist")
public Result<SubAgencyResultDTO> subAgencyList(@RequestBody SubAgencyFormDTO formDTO) {
return customerAgencyService.subAgencyList(formDTO);
}
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java

@ -132,7 +132,7 @@ public class CustomerGridController {
* @Description 根据userId查询该用户涉及的所有网格列表
* @Author sun
*/
@PostMapping("getmygrids/{userId}")
@GetMapping("getmygrids/{userId}")
public Result<List<CustomerGridByUserIdResultDTO>> getMyGrids(@PathVariable("userId") String userId) {
return customerGridService.getMyGrids(userId);
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java

@ -28,10 +28,12 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.CustomerStaffAgencyDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.result.CommonStaffInfoResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.excel.CustomerStaffAgencyExcel;
import com.epmet.service.CustomerStaffAgencyService;
import org.springframework.beans.factory.annotation.Autowired;
@ -108,4 +110,8 @@ public class CustomerStaffAgencyController {
public Result<LatestCustomerResultDTO> getLatestCustomer(@PathVariable("userId") String userId) {
return customerStaffAgencyService.getLatestCustomer(userId);
}
}

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

@ -0,0 +1,102 @@
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.*;
import com.epmet.dto.result.AddDepartmentResultDTO;
import com.epmet.dto.result.DepartmentDetailResultDTO;
import com.epmet.dto.result.DepartmentInAgencyResultDTO;
import com.epmet.dto.result.DepartmentListResultDTO;
import com.epmet.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 部门
*
* @author sun
*/
@RestController
@RequestMapping("department")
public class DepartmentController {
@Autowired
private DepartmentService departmentService;
@PostMapping(value = "adddepartmentstaff")
public Result addDepartmentStaff(@LoginUser TokenDto tokenDto, @RequestBody AddDepartmentFormDTO addDepartmentFormDTO){
return null;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加部门
*/
@PostMapping("adddepartment")
public Result<AddDepartmentResultDTO> addDepartment(@RequestBody AddDepartmentFormDTO formDTO) {
return departmentService.addDepartment(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 部门信息修改
*/
@PostMapping("editdepartment")
public Result editDepartment(@RequestBody EditDepartmentFormDTO formDTO) {
return departmentService.editDepartment(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除部门
*/
@PostMapping("removedepartment")
public Result removeDepartment(@RequestBody RemoveDepartmentFormDTO formDTO) {
return departmentService.removeDepartment(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取部门详情
*/
@PostMapping("departmentdetail")
public Result<DepartmentDetailResultDTO> departmentDetail(@RequestBody DepartmentdetailFormDTO formDTO) {
return departmentService.departmentDetail(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取机关下部门列表
*/
@PostMapping("departmentinagencylist")
public Result<DepartmentInAgencyResultDTO> departmentInAgencyList(@RequestBody DepartmentInAgencyFormDTO formDTO) {
return departmentService.departmentInAgencyList(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取机构下部门列表
*/
@PostMapping("departmentlist")
public Result<List<DepartmentListResultDTO>> departmentList(@RequestBody DepartmentListFormDTO formDTO) {
return departmentService.departmentList(formDTO);
}
}

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

@ -3,10 +3,14 @@ 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.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CommonAgencyIdFormDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
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.CommonStaffInfoResultDTO;
import com.epmet.dto.result.GridDetailResultDTO;
import com.epmet.dto.result.GridListInfoResultDTO;
@ -30,20 +34,45 @@ public class GridController {
@Autowired
private CustomerGridService customerGridService;
@Autowired
private CustomerStaffAgencyService customerStaffAgencyService;
/**
* 获取网格详情
* @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);
}
/**
* @Description 查找指定机构下的网格列表

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

@ -0,0 +1,122 @@
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.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;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 组织结构-工作人员
* @author zhaoqifeng
* @date 2020/4/23 17:59
*/
@RestController
@RequestMapping("staff")
public class StaffController {
@Autowired
private StaffService staffService;
/**
* 组织首页-工作人员列表
* @param fromDTO
* @return
*/
@PostMapping("staffsinagency")
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(@RequestBody StaffsInAgencyFromDTO fromDTO) {
return staffService.getStaffInfoForHome(fromDTO);
}
/**
* 查看人员列表
*
* @param fromDTO 参数
* @return Result<StaffsInAgencyResultDTO>
* @author zhaoqifeng
*/
@PostMapping("stafflist")
public Result<List<StaffInfoResultDTO>> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO){
return staffService.getStaffList(fromDTO);
}
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("rolelist")
public Result<StaffInitResultDTO> addStaffInit(@RequestBody StaffInfoFromDTO fromDTO){
return staffService.addStaffInit(fromDTO);
}
/**
* 人员编辑页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("editstaffinit")
public Result<StaffInitResultDTO> editStaffInit(@RequestBody StaffInfoFromDTO fromDTO){
return staffService.editStaffInit(fromDTO);
}
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("addstaff")
public Result addStaff(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitFromDTO fromDTO){
return staffService.addStaff(tokenDto, fromDTO);
}
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("editstaff")
public Result editStaff(@LoginUser TokenDto tokenDto, @RequestBody StaffSubmitFromDTO fromDTO){
return staffService.editStaff(tokenDto, fromDTO);
}
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
@PostMapping("staffdetail")
public Result<StaffDetailResultDTO> getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO){
return staffService.getStaffDetail(fromDTO);
}
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("disabledstaff")
public Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO){
return staffService.disabledStaff(fromDTO);
}
}

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.AgencyListResultDTO;
import com.epmet.dto.result.ParentListResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.SubListResultDTO;
@ -59,4 +60,12 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @Description 组织首页-下级机关列表
**/
List<SubListResultDTO> selectSubAgencyById(@Param("pId") String pId);
/**
* @param pId
* @return
* @Author sun
* @Description 获取组织列表
**/
List<AgencyListResultDTO> selectAgencyList(@Param("pId") String pId);
}

21
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java

@ -18,8 +18,13 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.DepartmentListResultDTO;
import com.epmet.dto.result.SubListResultDTO;
import com.epmet.entity.CustomerDepartmentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 客户部门表
@ -29,5 +34,19 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CustomerDepartmentDao extends BaseDao<CustomerDepartmentEntity> {
/**
* @param agencyId
* @return
* @Author sun
* @Description 根据当前机关Id查询该机关下的直属部门列表,只查询前十条
**/
List<DepartmentListResultDTO> selectDepartmentListByAgencyId(@Param("agencyId") String agencyId);
/**
* @param agencyId
* @return
* @Author sun
* @Description 根据当前机关Id查询该机关下的直属部门列表
**/
List<DepartmentListResultDTO> selectDepartmentList(@Param("agencyId") String agencyId);
}

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

@ -18,10 +18,13 @@
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;
@ -88,6 +91,40 @@ 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);
/**
* @Description 得到当前机构的网格总数

11
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java

@ -26,6 +26,8 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.List;
/**
* 人员-机关单位关系表
*
@ -42,6 +44,13 @@ public interface CustomerStaffAgencyDao extends BaseDao<CustomerStaffAgencyEntit
*/
CustomerStaffAgencyDTO selectLatestCustomerByStaff(String userId);
/**
* 获取机关下的工作人员
* @param agencyId
* @return
*/
List<CustomerStaffAgencyDTO> selectCustomerStaffAgencyList(String agencyId);
/**
* @Description 返回给定网格Id所属的机构下未加入该网格的工作人员Id(禁用未知)
* @Param gridId (String)
@ -50,5 +59,5 @@ public interface CustomerStaffAgencyDao extends BaseDao<CustomerStaffAgencyEntit
* @Date 2020.04.24 14:01
**/
List<String> getSelectableStaffsForGrid(@Param("gridId") String gridId);
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java

@ -20,6 +20,9 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.CustomerStaffDepartmentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 部门人员关系表
@ -29,5 +32,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CustomerStaffDepartmentDao extends BaseDao<CustomerStaffDepartmentEntity> {
List<String> selectUserIdByDepartmentId(@Param("departmentId") String departmentId);
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java

@ -82,11 +82,6 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
*/
private Integer totalUser;
/**
* 国家
*/
private String country;
/**
* 省份
*/
@ -97,4 +92,9 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
*/
private String city;
/**
* 区县
*/
private String district;
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java

@ -76,14 +76,12 @@ public class CustomerAgencyExcel {
@Excel(name = "总人数")
private Integer totalUser;
@Excel(name = "国家")
private String country;
@Excel(name = "省份")
private String province;
@Excel(name = "城市")
private String city;
@Excel(name = "区县")
private String district;
}

0
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep

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

@ -2,6 +2,15 @@ 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.form.DepartmentInStaffFormDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.DepartInStaffListResultDTO;
import com.epmet.dto.result.StaffDetailResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
@ -30,11 +39,92 @@ public interface EpmetUserFeignClient {
* @date 2020/4/22 10:05
**/
@PostMapping(value = "/epmetuser/customerstaff/getstaffinfobyuserid")
Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO);
Result<CustomerStaffDTO> getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO);
@PostMapping("/epmetuser/customerstaff/selectstaffgridlistbyuserid")
Result<List<StaffGridListDTO>> getStaffGridList(@RequestBody List<CustomerStaffGridDTO> customerStaffGridDTOS);
/**
* 组织首页-工作人员列表
* @param fromDTO
* @return
*/
@PostMapping("/epmetuser/customerstaff/staffsinagency")
Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO);
@PostMapping(value = "/epmetuser/customerstaff/selectgridstaffcountbyuserid")
Result<GridStaffCountDTO> selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO);
/**
* 工作人员列表
* @param fromDTO
* @return
*/
@PostMapping("/epmetuser/customerstaff/stafflist")
Result<List<StaffInfoResultDTO>> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO);
/**
* 人员添加页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("/epmetuser/customerstaff/rolelist")
Result<StaffInitResultDTO> addStaffInit(@RequestBody StaffInfoFromDTO fromDTO);
/**
* 人员编辑页面初始化
*
* @param fromDTO 参数
* @return Result<StaffInitResultDTO>
*/
@PostMapping("/epmetuser/customerstaff/editstaffinit")
Result<StaffInitResultDTO> editStaffInit(@RequestBody StaffInfoFromDTO fromDTO);
/**
* 人员添加
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("/epmetuser/customerstaff/addstaff")
Result addStaff(@RequestBody StaffSubmitFromDTO fromDTO);
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("/epmetuser/customerstaff/editstaff")
Result editStaff(@RequestBody StaffSubmitFromDTO fromDTO);
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
@PostMapping("/epmetuser/customerstaff/staffdetail")
Result<StaffDetailResultDTO> getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO);
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
@PostMapping("/epmetuser/customerstaff/disabledstaff")
Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO);
/**
* @param departmentInStaffFormDTO
* @return
* @Author sun
* @Description 根据客户Id及userId集合查询用户基本信息
*/
@PostMapping("/epmetuser/customerstaff/getdepartmentstafflist")
Result<List<DepartInStaffListResultDTO>> getDepartmentStaffList(DepartmentInStaffFormDTO departmentInStaffFormDTO);
/**
* @Description 通过userId列表查询未被禁用的用户信息
* @Param CommonUserIdListFormList :: getUserIdList

13
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java

@ -3,11 +3,14 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.CustomerFormDTO;
import com.epmet.feign.fallback.OperCrmFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
@ -22,4 +25,14 @@ public interface OperCrmFeignClient {
*/
@PostMapping("/oper/crm/customer/getcostomerInfo")
Result<CustomerDTO> getCustomerInfo(@RequestBody CustomerDTO dto);
/**
* @param customerFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.CustomerDTO>>
* @Author yinzuomei
* @Description 根据客户id查询客户信息
* @Date 2020/4/24 9:07
**/
@PostMapping("/oper/crm/customer/queryCustomerList")
Result<List<CustomerDTO>> queryCustomerList(CustomerFormDTO customerFormDTO);
}

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

@ -3,6 +3,15 @@ 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.form.DepartmentInStaffFormDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.result.DepartInStaffListResultDTO;
import com.epmet.dto.result.StaffDetailResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffInitResultDTO;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
@ -28,6 +37,57 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS);
}
@Override
public Result<List<StaffInfoResultDTO>> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
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);
}
@Override
public Result<List<StaffInfoResultDTO>> getStaffList(StaffsInAgencyFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "StaffsInAgencyFromDTO", fromDTO);
}
@Override
public Result<StaffInitResultDTO> addStaffInit(StaffInfoFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaffInit", fromDTO);
}
@Override
public Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaffInit", fromDTO);
}
@Override
public Result addStaff(StaffSubmitFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaff", fromDTO);
}
@Override
public Result editStaff(StaffSubmitFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editStaff", fromDTO);
}
@Override
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffDetail", fromDTO);
}
@Override
public Result disabledStaff(StaffInfoFromDTO fromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "disabledStaff", fromDTO);
}
@Override
public Result<List<CommonStaffInfoResultDTO>> enableStaffMsgList(CommonUserIdListFormList userIdList) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "enableStaffMsgList", userIdList);

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java

@ -4,9 +4,12 @@ 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.CustomerDTO;
import com.epmet.dto.form.CustomerFormDTO;
import com.epmet.feign.OperCrmFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
@ -18,4 +21,9 @@ public class OperCrmFeignClientFallBack implements OperCrmFeignClient {
public Result<CustomerDTO> getCustomerInfo(CustomerDTO dto) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto);
}
@Override
public Result<List<CustomerDTO>> queryCustomerList(CustomerFormDTO customerFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "queryCustomerList", customerFormDTO);
}
}

83
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java

@ -0,0 +1,83 @@
/**
* 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.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.dto.result.AgencyListResultDTO;
import com.epmet.dto.result.AgencysResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import java.util.List;
/**
* 机关单位信息
*
* @author generator generator@elink-cn.com
*/
public interface AgencyService {
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
Result editAgency(EditAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
Result removeAgency(RemoveAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
Result<AgencysResultDTO> agencyDetail(AgencydetailFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取组织列表
*/
Result<List<AgencyListResultDTO>> agencyList(AgencyListFormDTO formDTO);
}

45
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -21,11 +21,8 @@ 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.CustomerAgencyDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.dto.result.AgencydetailResultDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import java.util.List;
@ -107,44 +104,4 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @Date 2020/4/20 21:45
**/
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
Result editAgency(EditAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
Result removeAgency(RemoveAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
Result<AgencydetailResultDTO> agencyDetail(AgencydetailFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO);
}

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

@ -18,9 +18,13 @@
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.*;
import com.epmet.dto.result.AddGridResultDTO;
import com.epmet.dto.form.CommonAgencyIdFormDTO;
import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.ListCustomerGridFormDTO;
@ -29,6 +33,7 @@ import com.epmet.dto.result.CustomerGridForStrangerResultDTO;
import com.epmet.dto.result.GridDetailResultDTO;
import com.epmet.dto.result.GridListInfoResultDTO;
import com.epmet.entity.CustomerGridEntity;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
@ -133,6 +138,26 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
*/
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);
/**
* @Description 查找指定机构下的网格列表 对应接口:/gov/org/grid/gridlist
* @Param CommonAgencyIdFormDTO -> gridId

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerStaffAgencyDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.result.CommonStaffInfoResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
@ -105,6 +106,15 @@ public interface CustomerStaffAgencyService extends BaseService<CustomerStaffAge
*/
Result<LatestCustomerResultDTO> getLatestCustomer(String userId);
/**
* 获取组织下关联人员
* @param fromDTO
* @return
*/
Result<List<CustomerStaffAgencyDTO>> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO);
/**
* @Description 获取添加网格成员的可选人员列表
* @Param CommonGridIdFormDTO

80
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java

@ -0,0 +1,80 @@
/**
* 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.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import java.util.List;
/**
* 机关单位信息
*
* @author sun
*/
public interface DepartmentService {
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加部门
*/
Result<AddDepartmentResultDTO> addDepartment(AddDepartmentFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 部门信息修改
*/
Result editDepartment(EditDepartmentFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除部门
*/
Result removeDepartment(RemoveDepartmentFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取部门详情
*/
Result<DepartmentDetailResultDTO> departmentDetail(DepartmentdetailFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取机关下部门列表
*/
Result<DepartmentInAgencyResultDTO> departmentInAgencyList(DepartmentInAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取机构下部门列表
*/
Result<List<DepartmentListResultDTO>> departmentList(DepartmentListFormDTO formDTO);
}

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

@ -0,0 +1,88 @@
package com.epmet.service;
import com.epmet.commons.tools.security.dto.TokenDto;
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;
/**
* 组织结构-工作人员
*
* @author zhaoqifeng
* @date 2020/4/23 18:00
*/
public interface StaffService {
/**
* 组织首页-工作人员列表
*
* @param fromDTO 参数
* @return Result<StaffsInAgencyResultDTO>
* @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(TokenDto tokenDto, StaffSubmitFromDTO fromDTO);
/**
* 人员编辑
*
* @param fromDTO 参数
* @return Result
*/
Result editStaff(TokenDto tokenDto,StaffSubmitFromDTO fromDTO);
/**
* 人员详情
*
* @param fromDTO 参数
* @return Result<StaffDetailResultDTO>
*/
Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO);
/**
* 人员禁用
*
* @param fromDTO 参数
* @return Result
*/
Result disabledStaff(StaffInfoFromDTO fromDTO);
}

187
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -0,0 +1,187 @@
/**
* 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.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.service.AgencyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
/**
* 机关单位信息
*
* @author generator generator@elink-cn.com
*/
@Service
public class AgencyServiceImpl implements AgencyService {
private static final Logger log = LoggerFactory.getLogger(AgencyServiceImpl.class);
@Autowired
private CustomerAgencyDao customerAgencyDao;
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO) {
Result<AddAgencyResultDTO> result = new Result<AddAgencyResultDTO>();
AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO();
//0:属性映射赋值
CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
entity.setOrganizationName(formDTO.getAgencyName());
entity.setTotalUser(NumConstant.ZERO);
//1:查询上级机关信息
CustomerAgencyEntity parentEntity = customerAgencyDao.selectById(formDTO.getPid());
entity.setCustomerId(parentEntity.getCustomerId());
if (null == parentEntity.getPid()) {
entity.setPids(parentEntity.getId());
entity.setAllParentName(parentEntity.getOrganizationName());
} else {
entity.setPids(":" + parentEntity.getId());
entity.setAllParentName("-" + parentEntity.getOrganizationName());
}
//2:保存组织信息
if (customerAgencyDao.insert(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.SAVE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION);
}
//3:返回新组织Id
addAgencyResultDTO.setAgencyId(entity.getId());
return result.ok(addAgencyResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result editAgency(EditAgencyFormDTO formDTO) {
Result result = new Result();
CustomerAgencyEntity entity = new CustomerAgencyEntity();
entity.setId(formDTO.getAgencyId());
entity.setOrganizationName(formDTO.getAgencyName());
if (customerAgencyDao.updateById(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result removeAgency(RemoveAgencyFormDTO formDTO) {
Result result = new Result();
//1:查询当前机关是否存在所属下级机关,存在下级的不能删除
List<SubListResultDTO> agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId());
if (null != agencyList && agencyList.size() > NumConstant.ZERO) {
result.setCode(EpmetErrorCode.NOT_DEL_AGENCY.getCode());
result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY.getMsg());
return result;
}
//2:删除当前机关组织(逻辑删)
if (customerAgencyDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.DEL_EXCEPTION);
throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
@Override
public Result<AgencysResultDTO> agencyDetail(AgencydetailFormDTO formDTO) {
AgencysResultDTO agencysResultDTO = new AgencysResultDTO();
//1:查询本机关详细信息
CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId());
if (null == entity) {
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
agencysResultDTO = ConvertUtils.sourceToTarget(entity, AgencysResultDTO.class);
agencysResultDTO.setAgencyId(entity.getId());
agencysResultDTO.setAgencyName(entity.getOrganizationName());
//2:查询本机关的所有上级机关,按自上而下层级顺序
if (null == entity.getPids()) {
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
List<String> listStr = Arrays.asList(entity.getPids().split(":"));
List<ParentListResultDTO> parentList = customerAgencyDao.selectPAgencyById(listStr);
agencysResultDTO.setParentList(parentList);
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
@Override
public Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO) {
SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO();
//1:根据当前机关Id查询直属下一级机关列表
List<SubListResultDTO> agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId());
subAgencyResultDTO.setAgencyList(agencyList);
//2:统计下一级机关数
subAgencyResultDTO.setSubAgencyCount(agencyList.size());
return new Result<SubAgencyResultDTO>().ok(subAgencyResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取组织列表
*/
@Override
public Result<List<AgencyListResultDTO>> agencyList(AgencyListFormDTO formDTO) {
List<AgencyListResultDTO> agencyList = customerAgencyDao.selectAgencyList(formDTO.getAgencyId());
return new Result<List<AgencyListResultDTO>>().ok(agencyList);
}
}

145
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -30,9 +30,11 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.feign.OperCrmFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService;
import org.apache.commons.lang3.StringUtils;
@ -55,10 +57,11 @@ import java.util.Map;
@Service
public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao, CustomerAgencyEntity> implements CustomerAgencyService {
private static final Logger log = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class);
@Autowired
private CustomerAgencyRedis customerAgencyRedis;
@Autowired
private OperCrmFeignClient operCrmFeignClient;
@Override
public PageData<CustomerAgencyDTO> page(Map<String, Object> params) {
IPage<CustomerAgencyEntity> page = baseDao.selectPage(
@ -117,130 +120,22 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
return new Result<>();
}
List<StaffOrgsResultDTO> list = baseDao.selectStaffOrgList(staffOrgsFormDTO.getCustomerIdList());
return new Result<List<StaffOrgsResultDTO>>().ok(list);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO) {
Result<AddAgencyResultDTO> result = new Result<AddAgencyResultDTO>();
AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO();
//0:属性映射赋值
CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
entity.setOrganizationName(formDTO.getAgencyName());
entity.setTotalUser(NumConstant.ZERO);
//1:查询上级机关信息
CustomerAgencyEntity parentEntity = baseDao.selectById(formDTO.getPid());
entity.setCustomerId(parentEntity.getCustomerId());
if (null == parentEntity.getPid()) {
entity.setPids(parentEntity.getId());
entity.setAllParentName(parentEntity.getOrganizationName());
CustomerFormDTO customerFormDTO = new CustomerFormDTO();
customerFormDTO.setCustomerIdList(staffOrgsFormDTO.getCustomerIdList());
Result<List<CustomerDTO>> customerDTOResult = operCrmFeignClient.queryCustomerList(customerFormDTO);
List<CustomerDTO> customerDTOList = customerDTOResult.getData();
if (customerDTOResult.success() && customerDTOList.size() > 0) {
for (CustomerDTO customer : customerDTOList) {
for (StaffOrgsResultDTO staffOrgsResultDTO : list) {
if (customer.getId().equals(staffOrgsResultDTO.getCustomerId())) {
staffOrgsResultDTO.setCustomerName(customer.getCustomerName());
break;
}
}
}
} else {
entity.setPids(":" + parentEntity.getId());
entity.setAllParentName("-" + parentEntity.getOrganizationName());
}
//2:保存组织信息
if (baseDao.insert(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.SAVE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION);
}
//3:返回新组织Id
addAgencyResultDTO.setAgencyId(entity.getId());
return result.ok(addAgencyResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result editAgency(EditAgencyFormDTO formDTO) {
Result result = new Result();
CustomerAgencyEntity entity = new CustomerAgencyEntity();
entity.setId(formDTO.getAgencyId());
entity.setOrganizationName(formDTO.getAgencyName());
if (baseDao.updateById(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result removeAgency(RemoveAgencyFormDTO formDTO) {
Result result = new Result();
//1:查询当前机关是否存在所属下级机关,存在下级的不能删除
List<SubListResultDTO> agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId());
if (null != agencyList && agencyList.size() > NumConstant.ZERO) {
result.setCode(EpmetErrorCode.NOT_DEL_AGENCY.getCode());
result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY.getMsg());
return result;
}
//2:删除当前机关组织(逻辑删)
if (baseDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.DEL_EXCEPTION);
throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
@Override
public Result<AgencydetailResultDTO> agencyDetail(AgencydetailFormDTO formDTO) {
AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO();
//1:查询本机关详细信息
CustomerAgencyEntity entity = baseDao.selectById(formDTO.getAgencyId());
if (null == entity) {
return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO);
logger.error("获取客户名称失败");
}
agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class);
agencydetailResultDTO.setAgencyId(entity.getId());
agencydetailResultDTO.setAgencyName(entity.getOrganizationName());
//2:查询本机关的所有上级机关,按自上而下层级顺序
if (null == entity.getPids()) {
return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO);
}
List<String> listStr = Arrays.asList(entity.getPids().split(":"));
List<ParentListResultDTO> parentList = baseDao.selectPAgencyById(listStr);
agencydetailResultDTO.setParentList(parentList);
return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
@Override
public Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO) {
SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO();
//1:根据当前机关Id查询直属下一级机关列表
List<SubListResultDTO> agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId());
subAgencyResultDTO.setAgencyList(agencyList);
//2:统计下一级机关数
subAgencyResultDTO.setSubAgencyCount(agencyList.size());
return new Result<SubAgencyResultDTO>().ok(subAgencyResultDTO);
return new Result<List<StaffOrgsResultDTO>>().ok(list);
}
}

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

@ -21,10 +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.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddGridResultDTO;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.CustomerStaffGridDTO;
import com.epmet.dto.StaffGridListDTO;
@ -46,10 +53,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.*;
/**
* 客户网格表
@ -172,6 +176,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);
@ -181,6 +190,58 @@ 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();
}
/**
* @Description 查找指定机构下的网格列表 对应接口:/gov/org/grid/gridlist
* @Param CommonAgencyIdFormDTO

19
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java

@ -29,14 +29,19 @@ import com.epmet.dao.CustomerStaffAgencyDao;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.CustomerStaffAgencyDTO;
import com.epmet.dto.CustomerStaffDTO;
import com.epmet.dto.form.StaffsInAgencyFromDTO;
import com.epmet.dto.form.CommonGridIdFormDTO;
import com.epmet.dto.form.CommonUserIdListFormList;
import com.epmet.dto.result.CommonStaffInfoResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.dto.result.StaffInfoResultDTO;
import com.epmet.dto.result.StaffsInAgencyResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerStaffAgencyEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.OperCrmFeignClient;
import com.epmet.redis.CustomerStaffAgencyRedis;
import com.epmet.service.CustomerAgencyService;
import com.epmet.service.CustomerStaffAgencyService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,6 +52,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 人员-机关单位关系表
@ -63,6 +69,8 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl<CustomerStaf
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private OperCrmFeignClient operCrmFeignClient;
@Autowired
private CustomerAgencyService customerAgencyService;
@Override
public PageData<CustomerStaffAgencyDTO> page(Map<String, Object> params) {
@ -126,8 +134,7 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl<CustomerStaf
//获取工作人员头像
CustomerStaffDTO customerStaffParam = new CustomerStaffDTO();
customerStaffParam.setUserId(userId);
Result<CustomerStaffDTO> staffInfo =
epmetUserFeignClient.getCustomerStaffInfoByUserId(customerStaffParam);
Result<CustomerStaffDTO> staffInfo = epmetUserFeignClient.getCustomerStaffInfoByUserId(customerStaffParam);
resultDTO.setStaffHeadPhoto(staffInfo.getData().getHeadPhoto());
resultDTO.setGender(staffInfo.getData().getGender());
//获取客户名称
@ -138,6 +145,14 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl<CustomerStaf
return new Result<LatestCustomerResultDTO>().ok(resultDTO);
}
@Override
public Result<List<CustomerStaffAgencyDTO>> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO) {
List<CustomerStaffAgencyDTO> customerStaffAgencyList = baseDao.selectCustomerStaffAgencyList(fromDTO.getAgencyId());
return new Result<List<CustomerStaffAgencyDTO>>().ok(customerStaffAgencyList);
}
/**
* @Description 获取添加网格成员的可选人员列表先在本服务下查询userId然后调用EpmetUserFeign校验账户是否被禁用使用EpmetUser服务的DTO作为返回参数
* @Param CustomerGridFormDTO -> gridId

200
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java

@ -0,0 +1,200 @@
/**
* 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.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerDepartmentConstant;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dao.CustomerDepartmentDao;
import com.epmet.dao.CustomerStaffDepartmentDao;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerDepartmentEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.service.DepartmentService;
import com.epmet.util.ModuleConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
/**
* 机关单位信息
*
* @author sun
*/
@Service
public class DepartmentServiceImpl implements DepartmentService {
private static final Logger log = LoggerFactory.getLogger(DepartmentServiceImpl.class);
@Autowired
private CustomerAgencyDao customerAgencyDao;
@Autowired
private CustomerDepartmentDao customerDepartmentDao;
@Autowired
private CustomerStaffDepartmentDao customerStaffDepartmentDao;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddDepartmentResultDTO> addDepartment(AddDepartmentFormDTO formDTO) {
Result<AddDepartmentResultDTO> result = new Result<AddDepartmentResultDTO>();
AddDepartmentResultDTO addDepartmentResultDTO = new AddDepartmentResultDTO();
CustomerDepartmentEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerDepartmentEntity.class);
entity.setTotalUser(NumConstant.ZERO);
//1:查询当前组织机构信息,获取客户Id
CustomerAgencyEntity parentEntity = customerAgencyDao.selectById(formDTO.getAgencyId());
entity.setCustomerId(parentEntity.getCustomerId());
//2:保存部门信息
if (customerDepartmentDao.insert(entity) < NumConstant.ONE) {
log.error(CustomerDepartmentConstant.SAVE_EXCEPTION);
throw new RenException(CustomerDepartmentConstant.SAVE_EXCEPTION);
}
//3:返回新部门Id
addDepartmentResultDTO.setDepartmentId(entity.getId());
return result.ok(addDepartmentResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 部门信息修改
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result editDepartment(EditDepartmentFormDTO formDTO) {
Result result = new Result();
CustomerDepartmentEntity entity = new CustomerDepartmentEntity();
entity.setId(formDTO.getDepartmentId());
entity.setDepartmentName(formDTO.getDepartmentName());
entity.setDepartmentDuty(formDTO.getDepartmentDuty());
if (customerDepartmentDao.updateById(entity) < NumConstant.ONE) {
log.error(CustomerDepartmentConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerDepartmentConstant.UPDATE_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result removeDepartment(RemoveDepartmentFormDTO formDTO) {
Result result = new Result();
//1:判断当前部门下是否存在工作人员,不存在的可以删除
CustomerDepartmentEntity entity = customerDepartmentDao.selectById(formDTO.getDepartmentId());
if (null != entity && entity.getTotalUser() > NumConstant.ZERO) {
result.setCode(EpmetErrorCode.NOT_DEL_DEPARTMENT.getCode());
result.setMsg(EpmetErrorCode.NOT_DEL_DEPARTMENT.getMsg());
return result;
}
//2:删除部门信息(逻辑删)
if (customerDepartmentDao.deleteById(formDTO.getDepartmentId()) < NumConstant.ONE) {
log.error(CustomerDepartmentConstant.DEL_EXCEPTION);
throw new RenException(CustomerDepartmentConstant.DEL_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取部门详情
*/
@Override
public Result<DepartmentDetailResultDTO> departmentDetail(DepartmentdetailFormDTO formDTO) {
Result<DepartmentDetailResultDTO> result = new Result<DepartmentDetailResultDTO>();
DepartmentDetailResultDTO departmentDetailResultDTO = new DepartmentDetailResultDTO();
//1:根据部门Id查询部门详情信息
CustomerDepartmentEntity entity = customerDepartmentDao.selectById(formDTO.getDepartmentId());
departmentDetailResultDTO = ConvertUtils.sourceToTarget(entity, DepartmentDetailResultDTO.class);
departmentDetailResultDTO.setDepartmentId(entity.getId());
//2:查询部门下工作人员的用户Id集合
List<String> userIdList = customerStaffDepartmentDao.selectUserIdByDepartmentId(formDTO.getDepartmentId());
if (null == userIdList || userIdList.size() < NumConstant.ONE) {
return result.ok(departmentDetailResultDTO);
}
DepartmentInStaffFormDTO departmentInStaffFormDTO = new DepartmentInStaffFormDTO();
//部门Id用于查询部门领导角色使用
departmentInStaffFormDTO.setDepartmentId(formDTO.getDepartmentId());
departmentInStaffFormDTO.setCustomerId(entity.getCustomerId());
departmentInStaffFormDTO.setUserIdList(userIdList);
//3:调用epmet_user服务,查询人员基本信息,按姓名对应的拼音升序
Result<List<DepartInStaffListResultDTO>> resultList = epmetUserFeignClient.getDepartmentStaffList(departmentInStaffFormDTO);
if (!resultList.success() || null == resultList.getData()) {
log.error(CustomerDepartmentConstant.SELECT_STAFFINFO_EXCEPTION);
throw new RenException(CustomerDepartmentConstant.SELECT_STAFFINFO_EXCEPTION);
}
//部门下所有工作人员基本信息
List<DepartInStaffListResultDTO> staffList = resultList.getData();
departmentDetailResultDTO.setStaffList(staffList);
return new Result<DepartmentDetailResultDTO>().ok(departmentDetailResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取机关下部门列表
*/
@Override
public Result<DepartmentInAgencyResultDTO> departmentInAgencyList(DepartmentInAgencyFormDTO formDTO) {
DepartmentInAgencyResultDTO departmentInAgencyResultDTO = new DepartmentInAgencyResultDTO();
//1:根据当前机关Id查询该机关下的直属部门列表
List<DepartmentListResultDTO> departmentList = customerDepartmentDao.selectDepartmentListByAgencyId(formDTO.getAgencyId());
departmentInAgencyResultDTO.setDepartmentList(departmentList);
//2:统计下一级机关数
departmentInAgencyResultDTO.setDepartmentCount(departmentList.size());
return new Result<DepartmentInAgencyResultDTO>().ok(departmentInAgencyResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 获取机构下部门列表
*/
@Override
public Result<List<DepartmentListResultDTO>> departmentList(DepartmentListFormDTO formDTO) {
List<DepartmentListResultDTO> departmentList = customerDepartmentDao.selectDepartmentList(formDTO.getAgencyId());
return new Result<List<DepartmentListResultDTO>>().ok(departmentList);
}
}

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

@ -0,0 +1,124 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.security.dto.TokenDto;
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;
import com.epmet.feign.OperCrmFeignClient;
import com.epmet.service.CustomerAgencyService;
import com.epmet.service.CustomerStaffAgencyService;
import com.epmet.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/4/23 18:05
*/
@Service
public class StaffServiceImpl implements StaffService {
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private OperCrmFeignClient operCrmFeignClient;
@Autowired
private CustomerAgencyService customerAgencyService;
@Autowired
private CustomerStaffAgencyService customerStaffAgencyService;
@Override
public Result<StaffsInAgencyResultDTO> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) {
StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO();
//获取机关所在客户ID和人员总数
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
resultDTO.setStaffCount(customerAgencyEntity.getTotalUser());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
List<CustomerStaffAgencyDTO> customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData();
if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) {
return new Result<StaffsInAgencyResultDTO>().ok(null);
}
//提取所有userID
List<String> staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList());
fromDTO.setStaffList(staffIds);
//获取用户信息
Result<List<StaffInfoResultDTO>> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO);
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) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
return epmetUserFeignClient.addStaffInit(fromDTO);
}
@Override
public Result<StaffInitResultDTO> editStaffInit(StaffInfoFromDTO fromDTO) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
return epmetUserFeignClient.editStaffInit(fromDTO);
}
@Override
public Result addStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) {
fromDTO.setApp(tokenDto.getApp());
fromDTO.setClient(tokenDto.getClient());
Result result = epmetUserFeignClient.addStaff(fromDTO);
//机关总人数加一
if (result.success()) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
customerAgencyEntity.setTotalUser(customerAgencyEntity.getTotalUser() + 1);
customerAgencyService.updateById(customerAgencyEntity);
}
return new Result();
}
@Override
public Result editStaff(TokenDto tokenDto, StaffSubmitFromDTO fromDTO) {
fromDTO.setApp(tokenDto.getApp());
fromDTO.setClient(tokenDto.getClient());
return epmetUserFeignClient.editStaff(fromDTO);
}
@Override
public Result<StaffDetailResultDTO> getStaffDetail(StaffInfoFromDTO fromDTO) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId());
fromDTO.setCustomerId(customerAgencyEntity.getCustomerId());
return epmetUserFeignClient.getStaffDetail(fromDTO);
}
@Override
public Result disabledStaff(StaffInfoFromDTO fromDTO) {
return epmetUserFeignClient.disabledStaff(fromDTO);
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save