diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java index 31d7c6c310..220cf7d171 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/NewsServiceImpl.java @@ -31,7 +31,7 @@ public class NewsServiceImpl extends BaseServiceImpl implem * mybatis数据权限演示 */ @Override - @DataFilter(prefix = "AND", isPendingCreator = false) + //@DataFilter(prefix = "AND", isPendingCreator = false) public PageData page(Map params) { paramsToLike(params, "title"); diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 9d1876810e..d7f65bb65c 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -92,6 +92,12 @@ 2.0.0 compile + + com.epmet + gov-org-client + 2.0.0 + compile + @@ -129,7 +135,7 @@ 0 - 127.0.0.1 + 192.168.1.130 6379 123456 @@ -150,8 +156,8 @@ wx9b6102a8ee5add65 16fdb68bc2b3e732324ba5d8b8a9b5e2 - wx3d1372029eb816a3 - 651f02d71ed3f123dfb584b8bf0f4d8b + wx3d1372029eb816a3 + 651f02d71ed3f123dfb584b8bf0f4d8b @@ -187,8 +193,8 @@ wx9b6102a8ee5add65 16fdb68bc2b3e732324ba5d8b8a9b5e2 - wx3d1372029eb816a3 - 651f02d71ed3f123dfb584b8bf0f4d8b + wx3d1372029eb816a3 + 651f02d71ed3f123dfb584b8bf0f4d8b @@ -224,8 +230,8 @@ wx9b6102a8ee5add65 16fdb68bc2b3e732324ba5d8b8a9b5e2 - wx3d1372029eb816a3 - 651f02d71ed3f123dfb584b8bf0f4d8b + wx3d1372029eb816a3 + 651f02d71ed3f123dfb584b8bf0f4d8b diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java new file mode 100644 index 0000000000..fbc883c70f --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java @@ -0,0 +1,97 @@ +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.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.GovWxmpEnteOrgFormDTO; +import com.epmet.dto.form.GovWxmpFormDTO; +import com.epmet.dto.form.SendSmsCodeFormDTO; +import com.epmet.dto.form.StaffOrgsFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; +import com.epmet.dto.result.UserTokenResultDTO; +import com.epmet.service.GovLoginService; +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; + +/** + * @Description 政府端登录 + * @Author yinzuomei + * @Date 2020/4/20 10:54 + */ +@RestController +@RequestMapping("gov") +public class GovLoginController { + @Autowired + private GovLoginService govLoginService; + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 1、政府端小程序根据wxCode获取上一次登录信息,返回token + * @Date 2020/4/20 11:22 + **/ + @PostMapping(value = "/loginwxmp/loginbywxcode") + public Result loginByWxCode(@RequestBody GovWxmpFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return govLoginService.loginByWxCode(formDTO); + } + + /** + * @param formDTO 手机号 + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 2、政府端微信小程序登录-发送验证码 + * @Date 2020/4/18 10:58 + **/ + @PostMapping(value = "/loginwxmp/sendsmscode") + public Result sendSmsCode(@RequestBody SendSmsCodeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return govLoginService.sendSmsCode(formDTO); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 3、手机验证码获取组织 + * @Date 2020/4/18 21:14 + **/ + @PostMapping(value = "/loginwxmp/getmyorg") + public Result> getmyorg(@RequestBody StaffOrgsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return govLoginService.getMyOrg(formDTO); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 4、选择组织,进入首页 + * @Date 2020/4/20 13:07 + **/ + @PostMapping(value = "/loginwxmp/enterorg") + public Result enterOrg(@RequestBody GovWxmpEnteOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return govLoginService.enterOrg(formDTO); + } + + /** + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 政府端小程序退出 + * @Date 2020/4/21 22:22 + **/ + @PostMapping("/loginwxmp/loginout") + public Result loginOut(@LoginUser TokenDto tokenDto) { + return govLoginService.loginOut(tokenDto); + } +} + diff --git a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java index 47c778977a..12f697188a 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java @@ -7,9 +7,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.LoginByPassWordFormDTO; -import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.LoginByWxCodeFormDTO; -import com.epmet.dto.form.SendSmsCodeFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.CaptchaService; import com.epmet.service.LoginService; @@ -99,30 +97,4 @@ public class LoginController { //String token = request.getParameter(Constant.TOKEN_HEADER); return loginService.logoutByToken(tokenDto); } - - /** - * @param formDTO 手机号 - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 政府端微信小程序登录-发送验证码 - * @Date 2020/4/18 10:58 - **/ - @PostMapping(value = "/govwxmp/sendsmscode") - public Result sendSmsCode(@RequestBody SendSmsCodeFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); - return loginService.sendSmsCode(formDTO); - } - - /** - * @param formDTO - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 政府端微信小程序登录-手机验证码登录 - * @Date 2020/4/18 21:14 - **/ - @PostMapping(value = "/govwxmp/loginbyphone") - public Result loginByPhone(LoginByPhoneFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); - return loginService.loginByPhone(formDTO); - } } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java new file mode 100644 index 0000000000..855313c695 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 选择组织,进入首页入参Dto + * @Author yinzuomei + * @Date 2020/4/20 13:03 + */ +@Data +public class GovWxmpEnteOrgFormDTO implements Serializable { + /** + * wxCode + */ + @NotBlank(message = "wxCode不能为空") + private String wxCode; + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空") + private String mobile; + + /** + * 选择的组织所属的id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 选择的要进入的组织(根组织id) + */ + @NotBlank(message = "组织id不能为空") + private String rootAgencyId; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java new file mode 100644 index 0000000000..4eb52a4bf7 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 政府端小程序根据wxCode获取上一次登录信息,返回token + * @Author yinzuomei + * @Date 2020/4/20 11:20 + */ +@Data +public class GovWxmpFormDTO extends LoginCommonFormDTO implements Serializable { + private static final long serialVersionUID = -207861963128774742L; + /** + * wxCode + */ + @NotBlank(message = "wxCode不能为空") + private String wxCode; +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/SendSmsCodeFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/SendSmsCodeFormDTO.java index 806ddc43e2..8d82624aee 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/SendSmsCodeFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/SendSmsCodeFormDTO.java @@ -11,9 +11,9 @@ import java.io.Serializable; * @Date 2020/04/18 10:26 */ @Data -public class SendSmsCodeFormDTO extends LoginCommonFormDTO implements Serializable { +public class SendSmsCodeFormDTO implements Serializable { private static final long serialVersionUID = -1852541457359282018L; @NotBlank(message = "手机号不能为空") - private String phone; + private String mobile; } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgsFormDTO.java similarity index 60% rename from epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java rename to epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgsFormDTO.java index 591e6063b1..e36c100809 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgsFormDTO.java @@ -6,22 +6,24 @@ import javax.validation.constraints.NotBlank; import java.io.Serializable; /** - * @Description 政府端手机号+验证码登录接口入参 + * @Description 手机验证码获取组织接口入参 * @Author yinzuomei * @Date 2020/4/18 10:38 */ @Data -public class LoginByPhoneFormDTO extends LoginCommonFormDTO implements Serializable { +public class StaffOrgsFormDTO implements Serializable { private static final long serialVersionUID = 4193133227120225342L; - @NotBlank(message = "wxCode不能为空") - private String wxCode; - + /** + * 手机号 + */ @NotBlank(message = "手机号不能为空") - private String phone; + private String mobile; + /** + * 验证码 + */ @NotBlank(message="验证码不能为空") private String smsCode; - } diff --git a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 5b339e18ce..6bebb97f96 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -5,10 +5,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.UserDTO; import com.epmet.dto.UserWechatDTO; -import com.epmet.dto.form.PasswordLoginUserInfoFormDTO; -import com.epmet.dto.form.StaffWechatFormDTO; -import com.epmet.dto.form.WxLoginUserInfoFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; @@ -17,6 +16,8 @@ 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; + /** * @Description * @Author yinzuomei @@ -58,14 +59,14 @@ public interface EpmetUserFeignClient { Result selectLoginUserInfoByPassword(@RequestBody PasswordLoginUserInfoFormDTO passwordLoginUserInfoFormDTO); /** - * @param phone + * @param mobile * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 根据手机号查询政府端工作人员基本信息,校验用户是否存在 * @Date 2020/4/18 14:03 **/ - @GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyphone/{phone}") - Result checkCustomerStaff(@PathVariable("phone") String phone); + @GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyphone/{mobile}") + Result> checkCustomerStaff(@PathVariable("mobile") String mobile); /** * @param staffWechatFormDTO @@ -75,5 +76,35 @@ public interface EpmetUserFeignClient { * @Date 2020/4/18 22:44 **/ @PostMapping(value = "epmetuser/staffwechat/savestaffwechat", consumes = MediaType.APPLICATION_JSON_VALUE) - Result savestaffwechat(@RequestBody StaffWechatFormDTO staffWechatFormDTO); + Result saveStaffWechat(@RequestBody StaffWechatFormDTO staffWechatFormDTO); + + /** + * @param openId + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 获取当前微信上次登录的账号信息 + * @Date 2020/4/20 12:53 + **/ + @GetMapping(value = "epmetuser/staffagencyvisited/getlatest/{openId}") + Result getLatestStaffWechatLoginRecord(@PathVariable("openId") String openId); + + /** + * @param customerStaffFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:16 + **/ + @PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfo", consumes = MediaType.APPLICATION_JSON_VALUE) + Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO customerStaffFormDTO); + + /** + * @param staffLoginHistoryFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存登录日志 + * @Date 2020/4/20 14:38 + **/ + @PostMapping(value = "epmetuser/staffagencyvisited/saveStaffLoginRecord", consumes = MediaType.APPLICATION_JSON_VALUE) + Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO staffLoginHistoryFormDTO); } diff --git a/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java new file mode 100644 index 0000000000..527db417ef --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -0,0 +1,30 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffOrgFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; +import com.epmet.feign.fallback.GovOrgFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +/** + * @Description 政府端组织机构模块 + * @Author yinzuomei + * @Date 2020/4/20 15:18 + */ +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallback.class) +public interface GovOrgFeignClient { + /** + * @return com.epmet.commons.tools.utils.Result> + * @param staffOrgFormDTO + * @Author yinzuomei + * @Description 获取客户对应的根级组织名称 + * @Date 2020/4/20 21:37 + **/ + @PostMapping(value = "/gov/org/customeragency/getStaffOrgList",consumes = MediaType.APPLICATION_JSON_VALUE) + Result> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO); +} diff --git a/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java index 60b63d04da..b08fcbca1a 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java +++ b/epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java @@ -6,13 +6,14 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.UserDTO; import com.epmet.dto.UserWechatDTO; -import com.epmet.dto.form.PasswordLoginUserInfoFormDTO; -import com.epmet.dto.form.StaffWechatFormDTO; -import com.epmet.dto.form.WxLoginUserInfoFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; +import java.util.List; + /** * @Description * @Author yinzuomei @@ -37,13 +38,28 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { } @Override - public Result checkCustomerStaff(String phone) { + public Result> checkCustomerStaff(String phone) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustsomerStaffByPhone", phone); } @Override - public Result savestaffwechat(StaffWechatFormDTO staffWechatFormDTO) { + public Result saveStaffWechat(StaffWechatFormDTO staffWechatFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffWechat", staffWechatFormDTO); } + @Override + public Result getLatestStaffWechatLoginRecord(String openId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getLatestStaffWechatLoginRecord", openId); + } + + @Override + public Result getCustomerStaffInfo(CustomerStaffFormDTO customerStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfo", customerStaffFormDTO); + } + + @Override + public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO staffLoginHistoryFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffLoginRecord", staffLoginHistoryFormDTO); + } + } diff --git a/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java b/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java new file mode 100644 index 0000000000..a1ccd0bdf0 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java @@ -0,0 +1,26 @@ +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.form.StaffOrgFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; +import com.epmet.feign.GovOrgFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Description 政府端组织机构模块 + * @Author yinzuomei + * @Date 2020/4/20 15:19 + */ +@Component +public class GovOrgFeignClientFallback implements GovOrgFeignClient { + + @Override + public Result> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffOrgList", staffOrgFormDTO); + } +} + diff --git a/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java b/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java index 7363eb93c2..acdd85f490 100644 --- a/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java +++ b/epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java @@ -8,9 +8,9 @@ package com.epmet.redis; +import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; -import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.SendSmsCodeFormDTO; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -65,20 +65,20 @@ public class CaptchaRedis { * @Date 2020/4/18 13:53 **/ public void saveSmsCode(SendSmsCodeFormDTO sendSmsCodeFormDTO, String smsCode) { - String smsCodeKey = RedisKeys.getLoginSmsCodeKey(sendSmsCodeFormDTO.getApp(), sendSmsCodeFormDTO.getClient(), sendSmsCodeFormDTO.getPhone()); + String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_GOV, LoginConstant.CLIENT_WXMP, sendSmsCodeFormDTO.getMobile()); logger.info(String.format("短信验证码key=%s", smsCodeKey)); redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE); } /** - * @param formDTO + * @param mobile * @return java.lang.String * @Author yinzuomei * @Description 获取登录时发送的验证码 * @Date 2020/4/18 21:33 **/ - public String getSmsCode(LoginByPhoneFormDTO formDTO) { - String smsCodeKey = RedisKeys.getLoginSmsCodeKey(formDTO.getApp(), formDTO.getClient(), formDTO.getPhone()); + public String getSmsCode(String mobile) { + String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_GOV, LoginConstant.CLIENT_WXMP, mobile); String smsCode = (String) redisUtils.get(smsCodeKey); return smsCode; } diff --git a/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java new file mode 100644 index 0000000000..f61e9c8fab --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java @@ -0,0 +1,64 @@ +package com.epmet.service; + +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.GovWxmpEnteOrgFormDTO; +import com.epmet.dto.form.GovWxmpFormDTO; +import com.epmet.dto.form.SendSmsCodeFormDTO; +import com.epmet.dto.form.StaffOrgsFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; +import com.epmet.dto.result.UserTokenResultDTO; + +import java.util.List; + +/** + * @Description 政府端登录服务 + * @Author yinzuomei + * @Date 2020/4/20 10:56 + */ +public interface GovLoginService { + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 政府端微信小程序登录-发送验证码 + * @Date 2020/4/18 10:59 + **/ + Result sendSmsCode(SendSmsCodeFormDTO formDTO); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 3、手机验证码获取组织 + * @Date 2020/4/18 21:11 + **/ + Result> getMyOrg(StaffOrgsFormDTO formDTO); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 政府端小程序根据wxCode获取上一次登录信息,返回token + * @Date 2020/4/20 11:23 + **/ + Result loginByWxCode(GovWxmpFormDTO formDTO); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 4、选择组织,进入首页 + * @Date 2020/4/20 13:08 + **/ + Result enterOrg(GovWxmpEnteOrgFormDTO formDTO); + + /** + * @return com.epmet.commons.tools.utils.Result + * @param tokenDto + * @Author yinzuomei + * @Description 政府端工作人员退出登录 + * @Date 2020/4/21 22:08 + **/ + Result loginOut(TokenDto tokenDto); +} diff --git a/epmet-auth/src/main/java/com/epmet/service/LoginService.java b/epmet-auth/src/main/java/com/epmet/service/LoginService.java index 1433393413..37ab5f8f74 100644 --- a/epmet-auth/src/main/java/com/epmet/service/LoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/LoginService.java @@ -4,9 +4,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.LoginByPassWordFormDTO; -import com.epmet.dto.form.LoginByPhoneFormDTO; import com.epmet.dto.form.LoginByWxCodeFormDTO; -import com.epmet.dto.form.SendSmsCodeFormDTO; import com.epmet.dto.result.UserTokenResultDTO; /** @@ -52,21 +50,4 @@ public interface LoginService { **/ WxMaJscode2SessionResult getWxMaUser(String app, String wxCode); - /** - * @param formDTO - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 政府端微信小程序登录-发送验证码 - * @Date 2020/4/18 10:59 - **/ - Result sendSmsCode(SendSmsCodeFormDTO formDTO); - - /** - * @param formDTO - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 政府端微信小程序登录-手机验证码登录 - * @Date 2020/4/18 21:11 - **/ - Result loginByPhone(LoginByPhoneFormDTO formDTO); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java new file mode 100644 index 0000000000..35ce90b25c --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -0,0 +1,290 @@ +package com.epmet.service.impl; + +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; +import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.PhoneValidatorUtils; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; +import com.epmet.dto.result.UserTokenResultDTO; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.GovOrgFeignClient; +import com.epmet.feign.MessageFeignClient; +import com.epmet.jwt.JwtTokenProperties; +import com.epmet.jwt.JwtTokenUtils; +import com.epmet.redis.CaptchaRedis; +import com.epmet.service.GovLoginService; +import com.epmet.service.LoginService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description 政府端登录服务 + * @Author yinzuomei + * @Date 2020/4/20 10:56 + */ +@Service +public class GovLoginServiceImpl implements GovLoginService { + private static final Logger logger = LoggerFactory.getLogger(GovLoginServiceImpl.class); + private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]"; + @Autowired + private LoginService loginService; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private CaptchaRedis captchaRedis; + @Autowired + private MessageFeignClient messageFeignClient; + @Autowired + private JwtTokenUtils jwtTokenUtils; + @Autowired + private JwtTokenProperties jwtTokenProperties; + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + @Autowired + private GovOrgFeignClient govOrgFeignClient; + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 政府端微信小程序登录-发送验证码 + * @Date 2020/4/18 10:59 + **/ + @Override + public Result sendSmsCode(SendSmsCodeFormDTO formDTO) { + //1、校验手机号是否符合规范 + if (!PhoneValidatorUtils.isMobile(formDTO.getMobile())) { + logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); + return new Result().error(EpmetErrorCode.ERROR_PHONE.getCode()); + } + //2、根据手机号校验用户是否存在 + Result> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); + if (!customerStaffResult.success()) { + logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); + return new Result().error(customerStaffResult.getCode()); + } + //3、发送短信验证码 + Result> smsCodeResult = messageFeignClient.sendSmsCaptcha(formDTO.getMobile()); + if (!smsCodeResult.success()) { + logger.error(String.format(SEND_SMS_CODE_ERROR, formDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg())); + return new Result().error(smsCodeResult.getCode()); + } + //4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis) + captchaRedis.saveSmsCode(formDTO, smsCodeResult.getData().get("code")); + logger.info(String.format("发送短信验证码成功,手机号[%s]", formDTO.getMobile())); + return new Result(); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 3、手机验证码获取组织 + * @Date 2020/4/18 21:11 + **/ + @Override + public Result> getMyOrg(StaffOrgsFormDTO formDTO) { + //1、根据手机号查询到用户信息 + Result> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile()); + if (!customerStaffResult.success()) { + logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]", formDTO.getMobile(), customerStaffResult.getCode(), customerStaffResult.getMsg())); + return new Result().error(customerStaffResult.getCode()); + } + //2、验证码是否正确 + String rightSmsCode = captchaRedis.getSmsCode(formDTO.getMobile()); + if (!formDTO.getSmsCode().equals(rightSmsCode)) { + logger.error(String.format("验证码错误code[%s],msg[%s]",EpmetErrorCode.MOBILE_CODE_ERROR.getCode(),EpmetErrorCode.MOBILE_CODE_ERROR.getMsg())); + return new Result>().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + //3、查询用户所有的组织信息 + List customerIdList = new ArrayList<>(); + for (CustomerStaffDTO customerStaffDTO : customerStaffResult.getData()) { + customerIdList.add(customerStaffDTO.getCustomerId()); + } + StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO(); + staffOrgFormDTO.setCustomerIdList(customerIdList); + Result> result = govOrgFeignClient.getStaffOrgList(staffOrgFormDTO); + return result; + } + + @Override + public Result 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 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())); + return new Result().error(EpmetErrorCode.PLEASE_LOGIN.getCode()); + } + StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = latestStaffWechat.getData(); + //2、记录staff_wechat + this.savestaffwechat(staffLatestAgencyResultDTO.getStaffId(), wxMaJscode2SessionResult.getOpenid()); + //3、记录登录日志 + this.saveStaffLoginRecord(staffLatestAgencyResultDTO); + //4、获取用户token + String token = this.generateGovWxmpToken(staffLatestAgencyResultDTO.getStaffId()); + //5、保存到redis + this.saveLatestGovTokenDto(staffLatestAgencyResultDTO, wxMaJscode2SessionResult, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return new Result().ok(userTokenResultDTO); + } + + //保存tokenDto到redis + private void saveLatestGovTokenDto(StaffLatestAgencyResultDTO staffLatestAgency, + WxMaJscode2SessionResult wxMaJscode2SessionResult, + String token) { + int expire = jwtTokenProperties.getExpire(); + GovTokenDto govTokenDto = new GovTokenDto(); + govTokenDto.setApp(LoginConstant.APP_GOV); + govTokenDto.setClient(LoginConstant.CLIENT_WXMP); + govTokenDto.setUserId(staffLatestAgency.getStaffId()); + govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); + govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); + govTokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); + govTokenDto.setToken(token); + govTokenDto.setUpdateTime(System.currentTimeMillis()); + govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + govTokenDto.setAgencyId(staffLatestAgency.getAgencyId()); + govTokenDto.setCustomerId(staffLatestAgency.getCustomerId()); + cpUserDetailRedis.set(govTokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + } + + //保存登录日志 + private Result saveStaffLoginRecord(StaffLatestAgencyResultDTO latestStaffWechatLoginDTO) { + StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); + staffLoginAgencyRecordFormDTO.setCustomerId(latestStaffWechatLoginDTO.getCustomerId()); + staffLoginAgencyRecordFormDTO.setStaffId(latestStaffWechatLoginDTO.getStaffId()); + staffLoginAgencyRecordFormDTO.setWxOpenId(latestStaffWechatLoginDTO.getWxOpenId()); + staffLoginAgencyRecordFormDTO.setMobile(latestStaffWechatLoginDTO.getMobile()); + staffLoginAgencyRecordFormDTO.setAgencyId(latestStaffWechatLoginDTO.getAgencyId()); + Result staffLoginRecordResult = epmetUserFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); + return staffLoginRecordResult; + } + + @Override + public Result enterOrg(GovWxmpEnteOrgFormDTO formDTO) { + //1、需要校验要登录的客户,是否被禁用 + CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO(); + customerStaffFormDTO.setCustomerId(formDTO.getCustomerId()); + customerStaffFormDTO.setMobile(formDTO.getMobile()); + Result customerStaffDTOResult = epmetUserFeignClient.getCustomerStaffInfo(customerStaffFormDTO); + if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { + logger.error(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); + return new Result().error(customerStaffDTOResult.getCode()); + } + CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); + //2、解析微信用户 + WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode()); + //3、记录staff_wechat,并记录用户激活状态,激活时间 + this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + //4、记录登录日志 + this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid()); + //5.1、获取用户token + String token = this.generateGovWxmpToken(customerStaff.getUserId()); + //5.2、保存到redis + this.saveGovTokenDto(formDTO.getRootAgencyId(), formDTO.getCustomerId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return new Result().ok(userTokenResultDTO); + } + + @Override + public Result loginOut(TokenDto tokenDto) { + if(null == tokenDto){ + logger.error("token解析失败,直接跳转重新登录即可"); + throw new RenException("当前用户信息获取失败"); + } + cpUserDetailRedis.logout(tokenDto.getApp() , tokenDto.getClient() , tokenDto.getUserId()); + return new Result(); + } + + //保存登录日志 + private Result saveStaffLoginRecord(GovWxmpEnteOrgFormDTO formDTO, String staffId, String openId) { + StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); + staffLoginAgencyRecordFormDTO.setCustomerId(formDTO.getCustomerId()); + staffLoginAgencyRecordFormDTO.setStaffId(staffId); + staffLoginAgencyRecordFormDTO.setWxOpenId(openId); + staffLoginAgencyRecordFormDTO.setMobile(formDTO.getMobile()); + staffLoginAgencyRecordFormDTO.setAgencyId(formDTO.getRootAgencyId()); + Result staffLoginRecordResult = epmetUserFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); + return staffLoginRecordResult; + } + + + /** + * @param userId + * @param openid + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存微信和当前登录用户关系 + * @Date 2020/4/18 22:54 + **/ + private Result savestaffwechat(String userId, String openid) { + StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO(); + staffWechatFormDTO.setUserId(userId); + staffWechatFormDTO.setWxOpenId(openid); + return epmetUserFeignClient.saveStaffWechat(staffWechatFormDTO); + } + + /** + * @Description 生成token + * @Date 2020/4/18 23:04 + **/ + private String generateGovWxmpToken(String staffId) { + Map map = new HashMap<>(); + map.put("app", LoginConstant.APP_GOV); + map.put("client", LoginConstant.CLIENT_WXMP); + map.put("userId", staffId); + String token = jwtTokenUtils.createToken(map); + logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";userId:" + staffId + ";生成token[" + token + "]"); + return token; + } + + /** + * @Description 生成token + * @Date 2020/4/18 23:04 + **/ + private void saveGovTokenDto(String orgId, + String customerId, + String staffId, + WxMaJscode2SessionResult wxMaJscode2SessionResult, + String token) { + int expire = jwtTokenProperties.getExpire(); + GovTokenDto govTokenDto = new GovTokenDto(); + govTokenDto.setApp(LoginConstant.APP_GOV); + govTokenDto.setClient(LoginConstant.CLIENT_WXMP); + govTokenDto.setUserId(staffId); + govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); + govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); + govTokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); + govTokenDto.setToken(token); + govTokenDto.setUpdateTime(System.currentTimeMillis()); + govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); + govTokenDto.setAgencyId(orgId); + govTokenDto.setCustomerId(customerId); + cpUserDetailRedis.set(govTokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + } +} + diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java index 669c0596a5..f3cef61f98 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java @@ -3,7 +3,6 @@ package com.epmet.service.impl; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; import com.epmet.common.token.constant.LoginConstant; -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.dto.TokenDto; @@ -11,18 +10,14 @@ import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.PhoneValidatorUtils; -import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.UserDTO; import com.epmet.dto.UserWechatDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.feign.EpmetUserFeignClient; -import com.epmet.feign.MessageFeignClient; import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; -import com.epmet.redis.CaptchaRedis; import com.epmet.service.CaptchaService; import com.epmet.service.LoginService; import com.epmet.utils.WxMaServiceUtils; @@ -65,12 +60,6 @@ public class LoginServiceImpl implements LoginService { @Autowired private CaptchaService captchaService; - @Autowired - private CaptchaRedis captchaRedis; - - @Autowired - private MessageFeignClient messageFeignClient; - /** * 居民端微信小程序登录 * @@ -324,97 +313,9 @@ public class LoginServiceImpl implements LoginService { } cpUserDetailRedis.logout(tokenDto.getApp() , tokenDto.getClient() , tokenDto.getUserId()); //web端清空菜单栏和权限 - return new Result().ok("退出登录!"); - } - - private static final String SEND_SMS_CODE_ERROR="发送短信验证码异常,手机号[%s],code[%s],msg[%s]"; - - /** - * @param formDTO - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 政府端微信小程序登录-发送验证码 - * @Date 2020/4/18 10:59 - **/ - @Override - public Result sendSmsCode(SendSmsCodeFormDTO formDTO) { - //1、校验手机号是否符合规范 - if(!PhoneValidatorUtils.isMobile(formDTO.getPhone())){ - logger.error(String.format(SEND_SMS_CODE_ERROR,formDTO.getPhone(), EpmetErrorCode.ERROR_PHONE.getCode(),EpmetErrorCode.ERROR_PHONE.getMsg())); - return new Result().error(EpmetErrorCode.ERROR_PHONE.getCode()); - } - //2、根据手机号校验用户是否存在 - Result customerStaffResult=epmetUserFeignClient.checkCustomerStaff(formDTO.getPhone()); - if(!customerStaffResult.success()){ - logger.error(String.format(SEND_SMS_CODE_ERROR,formDTO.getPhone(),customerStaffResult.getCode(),customerStaffResult.getMsg())); - return new Result().error(customerStaffResult.getCode()); - } - //3、发送短信验证码 - Result> smsCodeResult=messageFeignClient.sendSmsCaptcha(formDTO.getPhone()); - if(!smsCodeResult.success()){ - logger.error(String.format(SEND_SMS_CODE_ERROR,formDTO.getPhone(),smsCodeResult.getCode(),smsCodeResult.getMsg())); - return new Result().error(smsCodeResult.getCode()); - } - //4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis) - captchaRedis.saveSmsCode(formDTO,smsCodeResult.getData().get("code")); - logger.info(String.format("发送短信验证码成功,手机号[%s]",formDTO.getPhone())); return new Result(); } - /** - * @param formDTO - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 政府端微信小程序登录-手机验证码登录 - * @Date 2020/4/18 21:11 - **/ - @Override - public Result loginByPhone(LoginByPhoneFormDTO formDTO) { - //1、根据手机号查询到用户信息 - Result customerStaffResult=epmetUserFeignClient.checkCustomerStaff(formDTO.getPhone()); - if(!customerStaffResult.success()){ - logger.error(String.format("手机验证码登录异常,手机号[%s],code[%s],msg[%s]",formDTO.getPhone(),customerStaffResult.getCode(),customerStaffResult.getMsg())); - return new Result().error(customerStaffResult.getCode()); - } - //2、验证码是否正确 - String rightSmsCode=captchaRedis.getSmsCode(formDTO); - if(!formDTO.getSmsCode().equals(rightSmsCode)){ - return new Result().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); - } - //3、解析wxCode - UserTokenResultDTO userTokenResultDTO=this.getAuthorizationInfo(formDTO,customerStaffResult.getData()); - return new Result().ok(userTokenResultDTO); - } - - private UserTokenResultDTO getAuthorizationInfo(LoginByPhoneFormDTO formDTO, CustomerStaffDTO customerStaff) { - //1、解析微信用户 - WxMaJscode2SessionResult wxMaJscode2SessionResult=this.getWxMaUser(formDTO.getApp(),formDTO.getWxCode()); - //2、记录staff_wechat - this.savestaffwechat(customerStaff.getUserId(),wxMaJscode2SessionResult.getOpenid()); - //3、获取用户token - String token=this.generateToken(formDTO,customerStaff.getUserId()); - //4、保存到redis - this.saveTokenDto(formDTO,customerStaff.getUserId(),wxMaJscode2SessionResult,token); - UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); - userTokenResultDTO.setToken(token); - return userTokenResultDTO; - } - - /** - * @return com.epmet.commons.tools.utils.Result - * @param userId - * @param openid - * @Author yinzuomei - * @Description 保存微信和当前登录用户关系 - * @Date 2020/4/18 22:54 - **/ - private Result savestaffwechat(String userId, String openid) { - StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO(); - staffWechatFormDTO.setUserId(userId); - staffWechatFormDTO.setWxOpenId(openid); - return epmetUserFeignClient.savestaffwechat(staffWechatFormDTO); - } - /** * @Description 生成token * @Date 2020/4/18 23:04 diff --git a/epmet-auth/src/test/java/com/epmet/TokenGenTest.java b/epmet-auth/src/test/java/com/epmet/TokenGenTest.java new file mode 100644 index 0000000000..3368e2d1cf --- /dev/null +++ b/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 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; + } + +} diff --git a/epmet-cloud-generator/src/main/resources/application.yml b/epmet-cloud-generator/src/main/resources/application.yml index ec95859518..f759f036b9 100644 --- a/epmet-cloud-generator/src/main/resources/application.yml +++ b/epmet-cloud-generator/src/main/resources/application.yml @@ -9,9 +9,9 @@ spring: type: com.alibaba.druid.pool.DruidDataSource #MySQL配置 driverClassName: com.mysql.jdbc.Driver - url: jdbc:mysql://localhost:3306/epmet_user?useUnicode=true&characterEncoding=UTF-8&useSSL=false - username: epmet - password: elink@833066 + url: jdbc:mysql://192.168.1.130:3306/epmet_user?useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: epmet_dba + password: EpmEt-dbA-UsEr #oracle配置 # driverClassName: oracle.jdbc.OracleDriver # url: jdbc:oracle:thin:@192.168.10.10:1521:helowin diff --git a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/enums/ErrorCode.java b/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/enums/ErrorCode.java deleted file mode 100644 index 9296333cac..0000000000 --- a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/enums/ErrorCode.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.epmet.common.token.enums; - - -import com.epmet.common.token.error.IErrorCode; - -/** - * client token错误码 - * - * @author rongchao - * @Date 18-11-24 - */ -public enum ErrorCode implements IErrorCode { - - SUCCESS(0, "请求成功"), - - ERR10001(10001, "token解析失败"), - ERR10002(10002, "token失效"), - ERR10003(10003, "token生成失败,请重试。"), - ERR10004(10004, "返回的Object类型不是EsuaResponse,无法添加token!"), - ERR10005(10005, "token不能为空"), - ERR10006(10006, "登录超时,请重新登录"), - ERR10007(10007, "当前帐号已在别处登录"), - - ERR500(500, "Internal Server Error"), - ERR501(501, "参数绑定异常"), - ERR401(401, "未授权"), - - - ERR(ErrorCode.COMMON_ERR_CODE, "其他异常"); - - private int code; - - private String msg; - - ErrorCode(final int code, final String msg) { - this.code = code; - this.msg = msg; - } - - public static final int COMMON_ERR_CODE = -1; - - @Override - public int getCode() { - return code; - } - - @Override - public String getMsg() { - return msg; - } -} diff --git a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/error/IErrorCode.java b/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/error/IErrorCode.java deleted file mode 100644 index 9b58ccc96e..0000000000 --- a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/error/IErrorCode.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.epmet.common.token.error; - -/** - * @author rongchao - * @Date 18-11-20 - */ -public interface IErrorCode { - int getCode(); - - String getMsg(); -} diff --git a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/util/TokenUtil.java b/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/util/TokenUtil.java index efefc5e16a..8042695c85 100644 --- a/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/util/TokenUtil.java +++ b/epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/util/TokenUtil.java @@ -25,11 +25,6 @@ public class TokenUtil { @Autowired private CpUserDetailRedis redisUtils; - public TokenDto getTokenInfo(String app, String client, String userId) { - TokenDto tokenDto = redisUtils.get(app,client,userId); - return tokenDto; - } - public void expireToken(String app,String client,String userId) { redisUtils.logout(app,client,userId); } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java index dd1d3aee3b..96b7691f22 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/annotation/DataFilter.java +++ b/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 ""; - /** - * 查询条件前缀,可选值有:[where、and] - */ - String prefix() default ""; - - /** - * 用户ID - */ - String userId() default "creator"; - - /** - * 部门ID - */ - String deptId() default "dept_id"; - - /** - * 是否拼接用户ID - */ - boolean isPendingCreator() default true; - } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java index f322f631f9..13910a6f3a 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java @@ -1,32 +1,38 @@ /** * 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.constant.OpeScopeConstant; +import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; +import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; +import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; +import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; import com.epmet.commons.mybatis.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.mybatis.feign.GovAccessFeignClient; +import com.epmet.commons.tools.aspect.AccessOpeAspect; +import com.epmet.commons.tools.exception.EpmetErrorCode; 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.List; -import java.util.Map; +import java.util.*; /** * 数据过滤,切面处理类 @@ -37,69 +43,330 @@ 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; - @Before("dataFilterCut()") + @Autowired + private GovAccessFeignClient govAccessFeignClient; + + public static final String orgIdPathSpliter = ":"; + + @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)); - } + // 通过反射,取到注解属性 + DataFilter dataFilterAnno = ((MethodSignature) point.getSignature()).getMethod().getAnnotation(DataFilter.class); + String tableAlias = dataFilterAnno.tableAlias(); - return ; + // 从ThreadLocal中取所需权限 + String requirePermission = AccessOpeAspect.requirePermissionTl.get(); + // 没有配置所需权限,不做操作,打印提示日志 + if (StringUtils.isBlank(requirePermission)) { + log.warn("Api编码需要指定所需权限,请在Api上使用@RequirePermission注解完成所需权限配置"); + return; } - throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR); + String app = loginUserUtil.getLoginUserApp(); + String client = loginUserUtil.getLoginUserClient(); + String userId = loginUserUtil.getLoginUserId(); + + StaffPermissionFormDTO staffPermissionFormDTO = new StaffPermissionFormDTO(); + staffPermissionFormDTO.setApp(app); + staffPermissionFormDTO.setClient(client); + staffPermissionFormDTO.setStaffId(userId); + Result result = govAccessFeignClient.getStaffCurrPermissions(staffPermissionFormDTO); + + if (result.getCode() != 0) { + // 查询不到权限,记录日志,抛出8000异常 + log.error("调用Access查询权限失败:{}", result.getMsg()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + StaffPermCacheResultDTO permCacheResultDTO = result.getData(); + + if (permCacheResultDTO == null || CollectionUtils.isEmpty(permCacheResultDTO.getPermissions())) { + log.error("操作权限不足,查询不到权限"); + throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); + } + + // 校验操作权限 + validateOpePermission(permCacheResultDTO.getPermissions(), requirePermission); + + // 生成过滤sql + Object[] methodArgs = point.getArgs(); + for (Object methodArg : methodArgs) { + if (methodArg instanceof DataScope) { + ((DataScope) methodArg).setSqlFilter(getSqlFilterSegment( + userId, + permCacheResultDTO.getRoleIdList(), + requirePermission, + permCacheResultDTO.getOrgIdPath(), + permCacheResultDTO.getGridId(), + tableAlias)); + return; + } + } + + //throw new RenException(ErrorCode.DATA_SCOPE_PARAMS_ERROR); + } + + /** + * 校验操作权限 + */ + private void validateOpePermission(Set permissions, String reqiurePermission) { + if (!permissions.contains(reqiurePermission)) { + // 权限不足 + log.error("操作权限不足"); + throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); + } } /** - * 获取数据过滤的SQL + * 生成过滤sql片段 + * + * @return */ - 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 String getSqlFilterSegment(String userId,Set roleIds, String reqiurePermission, String orgIdPath, String gridId, String tableAlias) { + // 根据角色列表查询操作范围列表 + Set scopeDTOS = new HashSet<>(); + roleIds.forEach(roleId -> { + OperationScopeFormDTO osformDto = new OperationScopeFormDTO(); + osformDto.setRoleId(roleId); + osformDto.setOperationKey(reqiurePermission); + Result> result = govAccessFeignClient.getOperationScopesByRoleId(osformDto); + if (result.success()) { + scopeDTOS.addAll(result.getData()); + } + }); + + // 过滤范围 + HashSet scopes = filteScopes(scopeDTOS); + if (CollectionUtils.isEmpty(scopes)) { + // 没有范围限制 + return ""; } + StringBuilder sb = new StringBuilder(); + + // 1.生成sql:组织范围过滤 + genOrgScopeSql(sb, orgIdPath, scopes, tableAlias); - StringBuilder sqlFilter = new StringBuilder(); + // 2.生成sql:我发起的 + genIStartedSql(sb, userId, tableAlias); + + // 3.生成sql:本网格的 + genInGrid(sb, gridId, tableAlias); + + //sb.append(")"); + System.out.println("生成的过滤sql:" + sb.toString()); + return sb.toString(); + } - //查询条件前缀 - String prefix = dataFilter.prefix(); - if(StringUtils.isNotBlank(prefix)){ - sqlFilter.append(" ").append(prefix); + /** + * 网格sql + * @param sb + * @param gridId + * @param tableAlias + */ + private void genInGrid(StringBuilder sb, String gridId, String tableAlias) { + if (StringUtils.isBlank(tableAlias)) { + sb.append(" OR GRID_ID ='").append(gridId).append("'"); + } else { + sb.append(" OR ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("'"); } + } - sqlFilter.append(" ("); + /** + * sql:我发起的 + * @param userId + */ + private void genIStartedSql(StringBuilder sb, String userId, String tableAlias) { + if (StringUtils.isBlank(tableAlias)) { + sb.append(" OR CREATED_BY ='").append(userId).append("'"); + } else { + sb.append(" OR ").append(tableAlias).append(".CREATED_BY ='").append(userId).append("'"); + } + } - //部门ID列表 - List deptIdList = user.getDeptIdList(); - if(CollUtil.isNotEmpty(deptIdList)){ - sqlFilter.append(tableAlias).append(dataFilter.deptId()); + /** + * 计算组织范围过滤sql,整体入口 + * @param sb + * @param orgIdPath + * @param scopes + */ + public void genOrgScopeSql(StringBuilder sb, String orgIdPath, HashSet scopes, String tableAlias) { + // 取出父组织ID path 和当前组织ID + String pOrgPath = orgIdPath.substring(0, orgIdPath.lastIndexOf(orgIdPathSpliter)); + String currOrgPath = orgIdPath.substring(orgIdPath.lastIndexOf(orgIdPathSpliter) + 1); + genOrgScopeSql(sb, scopes, currOrgPath, pOrgPath, tableAlias); + sb.replace(sb.lastIndexOf("OR"), sb.lastIndexOf("OR") + 3, ""); + } - sqlFilter.append(" in(").append(StringUtils.join(deptIdList, ",")).append(")"); + /** + * 计算组织范围过滤sql + * @param scopes + * @param currOrg + * @param pOrgPath + * @return + */ + private void genOrgScopeSql(StringBuilder sb,HashSet scopes, String currOrg, String pOrgPath, String tableAlias) { + for (String scope : scopes) { + switch (scope) { + case OpeScopeConstant.ORG_CURR: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" ORG_ID = '").append(currOrg).append("' OR "); + } else { + sb.append(" ").append(tableAlias).append(".ORG_ID = '").append(currOrg).append("' OR "); + } + break; + case OpeScopeConstant.ORG_CURR_AND_SUB: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" ORG_ID_PATH like '").append(pOrgPath).append("%' ").append(" OR "); + } else { + sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(pOrgPath).append("%' ").append(" OR "); + } + break; + case OpeScopeConstant.ORG_CURR_SUB: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" ORG_ID_PATH like '").append(pOrgPath).append(orgIdPathSpliter).append(currOrg).append("%' ").append(" OR "); + } else { + sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(pOrgPath).append(orgIdPathSpliter).append(currOrg).append("%' ").append(" OR "); + } + break; + case OpeScopeConstant.ORG_EQUAL: + // todo 同级 + //sb.append(" OR "); + break; + case OpeScopeConstant.ORG_EQUAL_AND_SUB: + // todo 同级及其子级 + //sb.append(" OR "); + break; + case OpeScopeConstant.ORG_EQUAL_SUB: + // todo 同级的子级 + //sb.append(" OR "); + break; + } } + } - //查询本人数据 - if (dataFilter.isPendingCreator()) { - if(CollUtil.isNotEmpty(deptIdList)){ - sqlFilter.append(" or "); + /** + * 过滤有效范围 + * + * @param scopeDTOS + * @return + */ + private HashSet filteScopes(Set scopeDTOS) { + HashMap filtedScopes = new HashMap<>(); + + for (OperationScopeDTO scope : scopeDTOS) { + String scopeIndex = scope.getScopeIndex(); + String[] currArr = scopeIndex.split("_"); + if ("0".equals(currArr[1])) { + // 为0,说明没有包含关系,直接放入 + filtedScopes.put(scopeIndex, scope); + continue; + } + + OperationScopeDTO tempScope = filtedScopes.get(currArr[0]); + if (tempScope != null) { + // 已经有ac开头的了 + String tempScopeIndex = tempScope.getScopeIndex(); + if (Integer.valueOf(currArr[1]) < Integer.valueOf(tempScopeIndex.split("_")[1])) { + filtedScopes.put(currArr[0], scope); + } + } else { + filtedScopes.put(currArr[0], scope); } - sqlFilter.append(tableAlias).append(dataFilter.userId()).append("=").append(user.getId()); } - sqlFilter.append(")"); + HashSet scopeStrs = new HashSet<>(); + Set> entries = filtedScopes.entrySet(); + for (Map.Entry entry : entries) { + scopeStrs.add(entry.getValue().getScopeKey()); + } + return scopeStrs; + } + + /** + * 模拟范围数据 + * + * @return + */ + private Set genScopeDtos() { + OperationScopeDTO scopeDTO1 = new OperationScopeDTO(); + scopeDTO1.setScopeKey("org_curr"); + scopeDTO1.setScopeName("本机关"); + scopeDTO1.setScopeIndex("ac_0"); + + OperationScopeDTO scopeDTO2 = new OperationScopeDTO(); + scopeDTO2.setScopeKey("org_curr_and_sub"); + scopeDTO2.setScopeName("本机关及下级"); + scopeDTO2.setScopeIndex("ac_501"); + + OperationScopeDTO scopeDTO3 = new OperationScopeDTO(); + scopeDTO3.setScopeKey("org_curr_sub"); + scopeDTO3.setScopeName("本机关的下级"); + scopeDTO3.setScopeIndex("ac_502"); - return sqlFilter.toString(); + OperationScopeDTO scopeDTO4 = new OperationScopeDTO(); + scopeDTO4.setScopeKey("org_equal_and_sub"); + scopeDTO4.setScopeName("同级机关及下级"); + scopeDTO4.setScopeIndex("ae_601"); + + OperationScopeDTO scopeDTO5 = new OperationScopeDTO(); + scopeDTO5.setScopeKey("org_equal_sub"); + scopeDTO5.setScopeName("同级机关的下级"); + scopeDTO5.setScopeIndex("ae_602"); + + Set scopeDTOS = new HashSet<>(); + scopeDTOS.add(scopeDTO1); + scopeDTOS.add(scopeDTO2); + scopeDTOS.add(scopeDTO3); + scopeDTOS.add(scopeDTO4); + scopeDTOS.add(scopeDTO5); + return scopeDTOS; } + + ///** + // * 获取数据过滤的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 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(); + //} } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspectBak.java new file mode 100644 index 0000000000..2c4c532bda --- /dev/null +++ b/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 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(); +// } +//} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/constant/OpeScopeConstant.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/constant/OpeScopeConstant.java new file mode 100644 index 0000000000..3d415ffb30 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/constant/OpeScopeConstant.java @@ -0,0 +1,17 @@ +package com.epmet.commons.mybatis.constant; + +public class OpeScopeConstant { + //"同级组织的下级" + public static final String ORG_EQUAL_SUB = "org_equal_sub"; + //"同级组织及下级" + public static final String ORG_EQUAL_AND_SUB = "org_equal_and_sub"; + //"同级组织" + public static final String ORG_EQUAL = "org_equal"; + //"本组织的下级" + public static final String ORG_CURR_SUB = "org_curr_sub"; + //"本组织及下级" + public static final String ORG_CURR_AND_SUB = "org_curr_and_sub"; + //"本组织" + public static final String ORG_CURR = "org_curr"; + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/OperationScopeDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/OperationScopeDTO.java new file mode 100644 index 0000000000..3e65b753d7 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/OperationScopeDTO.java @@ -0,0 +1,92 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.commons.mybatis.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +public class OperationScopeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 角色id + */ + private String roleId; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + + /** + * 范围序号 + */ + private String scopeIndex; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/OperationScopeFormDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/OperationScopeFormDTO.java new file mode 100644 index 0000000000..fe5aca825b --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/OperationScopeFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.commons.mybatis.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class OperationScopeFormDTO { + + public interface ListOperationScopeGroup {} + + @NotBlank(message = "角色ID不能为空", groups = {ListOperationScopeGroup.class}) + private String roleId; + + @NotBlank(message = "操作的key不能为空", groups = {ListOperationScopeGroup.class}) + private String operationKey; + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java new file mode 100644 index 0000000000..7775756b38 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermCacheResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.commons.mybatis.dto.form; + +import lombok.Data; + +import java.util.Set; + +@Data +public class StaffPermCacheResultDTO { + + /** + * 权限列表 + */ + private Set permissions; + + /** + * 角色列表 + */ + private Set roleIdList; + + /** + * 机构Id + */ + private String orgIdPath; + + /** + * 网格ID + */ + private String gridId; + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/StaffPermissionFormDTO.java new file mode 100644 index 0000000000..3bc88d6fb1 --- /dev/null +++ b/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; + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java index 43d3ca1619..59dd035fac 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/entity/DataScope.java +++ b/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. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ @@ -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; } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java new file mode 100644 index 0000000000..50b20890e7 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/GovAccessFeignClient.java @@ -0,0 +1,39 @@ +package com.epmet.commons.mybatis.feign; + +import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; +import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; +import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; +import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.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 org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; +import java.util.Set; + +/** + * @Description + * @Author sun + */ +@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class) +public interface GovAccessFeignClient { + + /** + * 查询用户当前权限列表 + * @return + */ + @PostMapping("/gov/access/access/getcurrpermissions") + Result getStaffCurrPermissions(StaffPermissionFormDTO dto); + + /** + * 查询角色的操作key对应操作范围列表 + * @param operationScopeFormDTO + * @return + */ + @PostMapping("/gov/access/access/operationscopes") + Result> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO); + +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java new file mode 100644 index 0000000000..6dfa1b89cc --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/GovAccessFeignClientFallback.java @@ -0,0 +1,33 @@ +package com.epmet.commons.mybatis.feign.fallback; + +import com.epmet.commons.mybatis.dto.form.OperationScopeDTO; +import com.epmet.commons.mybatis.dto.form.OperationScopeFormDTO; +import com.epmet.commons.mybatis.dto.form.StaffPermCacheResultDTO; +import com.epmet.commons.mybatis.dto.form.StaffPermissionFormDTO; +import com.epmet.commons.mybatis.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 getStaffCurrPermissions(StaffPermissionFormDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getStaffCurrPermissions", dto); + } + + @Override + public Result> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getOperationScopesByRoleId", operationScopeFormDTO); + } +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java index bd7d0619fd..fcd85b0c0e 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java +++ b/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); diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java index eea6262cd4..d26f7525a1 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptor.java @@ -8,10 +8,11 @@ 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; import com.epmet.commons.mybatis.entity.DataScope; +import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.executor.statement.StatementHandler; import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.MappedStatement; @@ -42,10 +43,10 @@ public class DataFilterInterceptor extends AbstractSqlParserHandler implements I this.sqlParser(metaObject); // 先判断是不是SELECT操作 - MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement"); - if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) { - return invocation.proceed(); - } + //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"); @@ -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; } } } @@ -73,12 +79,18 @@ public class DataFilterInterceptor extends AbstractSqlParserHandler implements I // 拼接新SQL String orderBy = "ORDER BY"; String groupBy = "GROUP BY"; + String sqlFilter = scope.getSqlFilter(); + if (originalSql.indexOf("WHERE") == 0) { + // 不包含where,需要手动拼接上 + sqlFilter = " WHERE ".concat(sqlFilter); + } + if (originalSql.indexOf(groupBy) > -1) { - originalSql = originalSql.replace(groupBy, scope.getSqlFilter() + groupBy); + originalSql = originalSql.replace(groupBy, sqlFilter + groupBy); } else if (originalSql.indexOf(orderBy) > -1) { - originalSql = originalSql.replace(orderBy, scope.getSqlFilter() + orderBy); + originalSql = originalSql.replace(orderBy, sqlFilter + orderBy); } else { - originalSql = originalSql + scope.getSqlFilter(); + originalSql = originalSql.concat(" AND (").concat(scope.getSqlFilter()).concat(")"); } // 重写SQL diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/DataFilterInterceptorBak.java new file mode 100644 index 0000000000..1a3445f0f5 --- /dev/null +++ b/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. +// *

+// * https://www.renren.io +// *

+// * 版权所有,侵权必究! +// */ +// +//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) { +// +// } +//} diff --git a/epmet-commons/epmet-commons-tools-wx-ma/src/main/java/com/epmet/utils/WxMaServiceUtils.java b/epmet-commons/epmet-commons-tools-wx-ma/src/main/java/com/epmet/utils/WxMaServiceUtils.java index 8d7aaa463d..5122fa505f 100644 --- a/epmet-commons/epmet-commons-tools-wx-ma/src/main/java/com/epmet/utils/WxMaServiceUtils.java +++ b/epmet-commons/epmet-commons-tools-wx-ma/src/main/java/com/epmet/utils/WxMaServiceUtils.java @@ -17,10 +17,10 @@ public class WxMaServiceUtils { @Value("${wx.ma.appId.resi}") private String APPID_RESI; - /*@Value("${wx.ma.appId.gov}") + @Value("${wx.ma.appId.gov}") private String APPID_GOV; - @Value("${wx.ma.appId.oper}") + /*@Value("${wx.ma.appId.oper}") private String APPID_OPER;*/ /** @@ -43,8 +43,7 @@ public class WxMaServiceUtils { * @date 2020/03/13 10:44 */ public final WxMaService govWxMaService() { -// final WxMaService wxMaService = WxMaConfig.getMaService(APPID_GOV); - final WxMaService wxMaService = WxMaConfig.getMaService(APPID_RESI); + final WxMaService wxMaService = WxMaConfig.getMaService(APPID_GOV); return wxMaService; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/LoginUser.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/LoginUser.java index 0a7f7b625a..03ba0cb04f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/LoginUser.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/LoginUser.java @@ -19,7 +19,7 @@ package com.epmet.commons.tools.annotation; import java.lang.annotation.*; /** - * 登录用户信息 + * 居民登录用户信息 * * @author chenshun * @email sunlightcs@gmail.com diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/RequirePermission.java new file mode 100644 index 0000000000..3a5fe74459 --- /dev/null +++ b/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 + *

+ * 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 + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * 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 ""; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java new file mode 100644 index 0000000000..72070ee6e1 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/AccessOpeAspect.java @@ -0,0 +1,44 @@ +/** + * 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 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(); + + // 放入ThreadLocal,供DataFilterAspect中使用 + requirePermissionTl.set(key); + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java index 6083e647f6..79f32f7d1f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java @@ -78,4 +78,9 @@ public interface ServiceConstant { * 楼院小组 */ String RESI_GROUP_SERVER ="resi-group-server"; + + /** + * 政府端权限服务 + */ + String GOV_ACCESS_SERVER = "gov-access-server"; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index a77e4f3130..161c9cd9ef 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -6,6 +6,11 @@ package com.epmet.commons.tools.exception; * @Description: */ public enum EpmetErrorCode { + ERR10005(10005, "token不能为空"), + ERR10006(10006, "登录超时,请重新登录"), + ERR10007(10007, "当前帐号已在别处登录"), + ERR401(401, "未授权"), + SERVER_ERROR(8000, "服务器开小差了..."), CANNOT_JOIN_GROUP(8001, "只有认证党员和居民才可以加入小组,请选择您的身份"), CANNOT_CREATE_GROUP(8002, "只有党员和热心居民才能创建小组,请选择您的身份"), @@ -14,13 +19,20 @@ public enum EpmetErrorCode { GOV_STAFF_DISABLED(8005,"您好,您的账户已被冻结,请联系管理员。"), LOSE_EFFICACY(8006,"此邀请链接已过期"), ERROR_PHONE(8007,"请输入正确的手机号"), + PLEASE_LOGIN(8008,"请重新登录"), MOBILE_HAS_BEEN_USED(8101, "该手机号已注册,请更换手机号或使用原绑定的微信账号登录"), MOBILE_CODE_ERROR(8102, "验证码错误"), AUTO_CONFIRM_FAILED(8103, "党员注册失败"), MOBILE_GET_CODE_ERROR(8104,"获取验证码失败"), MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"), + NOT_DEL_GRID(8106,"该网格存在工作人员,不允许删除"), + + CANNOT_AUDIT_WARM(8201, "请完善居民信息"), + NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), + NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"), + NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"), - CANNOT_AUDIT_WARM(8201, "请完善居民信息"); + REQUIRE_PERMISSION(8301, "没有足够的操作权限"); private int code; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java index b2936413d2..e49e03d52d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/RenExceptionHandler.java +++ b/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; /** * 处理自定义异常 @@ -53,7 +55,10 @@ public class RenExceptionHandler { @ExceptionHandler(RenException.class) public Result handleRRException(RenException ex){ logger.error(ExceptionUtils.getErrorStackTrace(ex)); - return new Result().error(); + Result result=new Result().error(); + result.setData(ex.getMsg()); + return result; +// return new Result().error(); } /** @@ -64,7 +69,10 @@ public class RenExceptionHandler { @ExceptionHandler(RuntimeException.class) public Result handleRuntimeException(RuntimeException ex){ logger.error(ExceptionUtils.getErrorStackTrace(ex)); - return new Result().error(); + Result result=new Result().error(); + result.setData(ex.getMessage()); + return result; +// return new Result().error(); } /** @@ -87,7 +95,10 @@ public class RenExceptionHandler { public Result handleException(Exception ex){ logger.error(ExceptionUtils.getErrorStackTrace(ex)); // saveLog(ex); - return new Result().error(); + Result result=new Result().error(); + result.setData(ex.getMessage()); + return result; +// return new Result().error(); } /** @@ -111,7 +122,7 @@ public class RenExceptionHandler { //登录用户ID - log.setCreator(LoginUserUtil.getLoginUserId()); + log.setCreator(loginUserUtil.getLoginUserId()); //异常信息 log.setErrorInfo(ExceptionUtils.getErrorStackTrace(ex)); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 199e38e235..6598010561 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -207,4 +207,14 @@ public class RedisKeys { public static String getLoginSmsCodeKey(String app, String client, String phone) { return String.format(rootPrefix+"smsCode:login:%s:%s:%s",app,client,phone); } + + /** + * 角色的操作权限对应的可操作范围 + * @param roleId 角色ID + * @param opeKey 操作Key + * @return + */ + public static String getRoleOpeScopesKey(String roleId, String opeKey) { + return rootPrefix.concat("gov:access:role:opescopes:").concat(roleId).concat(opeKey); + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/BaseTokenDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/BaseTokenDto.java new file mode 100644 index 0000000000..c3065c7200 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/BaseTokenDto.java @@ -0,0 +1,42 @@ +package com.epmet.commons.tools.security.dto; + +import lombok.Data; + +@Data +public class BaseTokenDto { + /** + * 政府端:gov、居民端:resi、运营端:oper + */ + private String app; + + /** + * PC端:web、微信小程序:wxmp + */ + private String client; + + /** + * 用户ID + */ + private String userId; + + /** + * token字符串 + */ + private String token; + + public BaseTokenDto() { + } + + public BaseTokenDto(String app, String client, String userId) { + this.app = app; + this.client = client; + this.userId = userId; + } + + public BaseTokenDto(String app, String client, String userId, String token) { + this.app = app; + this.client = client; + this.userId = userId; + this.token = token; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java new file mode 100644 index 0000000000..49d6cb15a3 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java @@ -0,0 +1,77 @@ +package com.epmet.commons.tools.security.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Set; + +/** + * @Description 政府端登录信息 + * @Author yinzuomei + * @Date 2020/4/20 11:01 + */ +@Data +public class GovTokenDto extends BaseTokenDto implements Serializable { + + /** + * sessionKey + */ + private String sessionKey; + + /** + * openId + */ + private String openId; + + /** + * unionId + */ + private String unionId; + + /** + * 当前工作人员进入的客户id + */ + private String customerId; + + /** + * 过期时间戳 + */ + private Long expireTime; + + /** + * 最后一次更新时间 + */ + private long updateTime; + + /** + * 当前登录的组织id(顶级) + */ + private String agencyId; + + /** + * 当前网格对应的组织结构id的全路径用:隔开 + */ + private String orgIdPath; + + /** + * 当前所在网格id + */ + private String gridId; + + /** + * 部门id列表 + */ + private List deptIdList; + + /** + * 功能权限列表,实际上是gov_staff => staff_role => role_operation查询到的operationKey + */ + private Set permissions; + + /** + * 角色ID列表 + */ + private Set roleIdList; +} + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/TokenDto.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/TokenDto.java index fb8a5dd7ec..402dfc1b59 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/TokenDto.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/TokenDto.java @@ -11,22 +11,8 @@ import java.io.Serializable; * @Date 2020-03-14 */ @Data -public class TokenDto implements Serializable { +public class TokenDto extends BaseTokenDto implements Serializable { private static final long serialVersionUID = 8883581762088390769L; - /** - * 政府端:gov、居民端:resi、运营端:oper - */ - private String app; - - /** - * PC端:web、微信小程序:wxmp - */ - private String client; - - /** - * 用户ID - */ - private String userId; /** * sessionKey @@ -43,11 +29,6 @@ public class TokenDto implements Serializable { */ private String unionId; - /** - * token字符串 - */ - private String token; - /** * 过期时间戳 */ @@ -57,4 +38,5 @@ public class TokenDto implements Serializable { * 最后一次更新时间 */ private long updateTime; + } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java index 7af851b8bf..ec70df9403 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -72,12 +72,11 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu if (StringUtils.isEmpty(redisKey)) { throw new RenException(ErrorCode.UNAUTHORIZED); } - String[] keyArray=redisKey.split("-"); - String app=keyArray[0]; - String client=keyArray[1]; - String userId=keyArray[2]; - - //TokenDto tokenDto = cpUserDetailRedis.get(app,client,userId); +// String[] keyArray=redisKey.split("-"); +// String app=keyArray[0]; +// String client=keyArray[1]; +// String userId=keyArray[2]; +// TokenDto tokenDto = cpUserDetailRedis.get(app,client,userId); TokenDto tokenDto = new TokenDto(); tokenDto.setUserId(request.getHeader("userId")); tokenDto.setApp(request.getHeader("app")); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java index 2b249bee22..088a26eb73 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java +++ b/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 getLoginUserDepartments() { + String loginUserId = getLoginUserId(); + String loginUserApp = getLoginUserApp(); + String loginUserClient = getLoginUserClient(); + // todo + return null; + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java index f49c9ddcb5..4c0845fc6c 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java @@ -12,6 +12,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.map.MapUtil; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -48,7 +49,7 @@ public class CpUserDetailRedis { * @param userId oper_user、customer_user、customer_staff表主键 * @return */ - public TokenDto get(String app, String client, String userId) { + public T get(String app, String client, String userId, Class clz) { String key = RedisKeys.getCpUserKey(app,client,userId); Map map = redisUtils.hGetAll(key); @@ -57,9 +58,7 @@ public class CpUserDetailRedis { } //map to bean - TokenDto user = BeanUtil.mapToBean(map, TokenDto.class, true); - - return user; + return BeanUtil.mapToBean(map, clz, true); } /** @@ -99,4 +98,34 @@ public class CpUserDetailRedis { public long getExpire(String app, String client, String userId) { return redisUtils.getExpire(RedisKeys.getCpUserKey(app, client, userId)); } + + public void set(GovTokenDto user, long expire) { + if (user == null) { + return; + } + String key = RedisKeys.getCpUserKey(user.getApp(), user.getClient(), user.getUserId()); + //bean to map + Map map = BeanUtil.beanToMap(user, false, true); + redisUtils.hMSet(key, map, expire); + } + + /** + * 获取token信息 + * + * @param app 居民端resi;政府端gov;运营端oper + * @param client PC端:web;微信小程序端:wxmp + * @param userId oper_user、customer_user、customer_staff表主键 + * @return + */ + public GovTokenDto getGovTokenDto(String app, String client, String userId) { + String key = RedisKeys.getCpUserKey(app,client,userId); + + Map map = redisUtils.hGetAll(key); + if (MapUtil.isEmpty(map)) { + return null; + } + //map to bean + GovTokenDto govTokenDto = BeanUtil.mapToBean(map, GovTokenDto.class, true); + return govTokenDto; + } } diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 0c1bb611f6..3dad66dba9 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -95,7 +95,7 @@ 0 - 127.0.0.1 + 192.168.1.130 6379 123456 @@ -108,51 +108,61 @@ - - http://127.0.0.1:8081 + lb://epmet-auth-server + - - http://127.0.0.1:8082 + lb://epmet-admin-server + - - http://127.0.0.1:8083 + lb://epmet-oss-server + - - http://127.0.0.1:8085 + lb://epmet-message-server + - - http://127.0.0.1:8086 + lb://epmet-activiti-server + - - http://127.0.0.1:8084 + lb://epmet-job-server + - - http://127.0.0.1:8087 + lb://epmet-user-server + http://127.0.0.1:8088 - - http://127.0.0.1:8089 + lb://oper-customize-server + - - http://127.0.0.1:8090 + lb://oper-crm-server + - - http://127.0.0.1:8091 + lb://resi-guide-server + - - http://127.0.0.1:8092 + lb://gov-org-server + - - http://127.0.0.1:8093 + lb://oper-access-server + - - http://127.0.0.1:8094 + lb://resi-mine-server + - - http://127.0.0.1:8095 + lb://resi-group-server + + + lb://resi-partymember-server + + + http://127.0.0.1:8099 + + + + http://127.0.0.1:8098 + http://127.0.0.1:8096 http://127.0.0.1:8097 @@ -215,6 +225,12 @@ lb://resi-partymember-server lb://gov-grid-server + + + lb://gov-access-server + + + lb://gov-mine-server @@ -271,6 +287,11 @@ lb://resi-group-server lb://resi-partymember-server + + lb://gov-access-server + + + lb://gov-mine-server lb://gov-grid-server diff --git a/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java b/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java index e398b5978a..d3c7d60b6d 100644 --- a/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java +++ b/epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java @@ -2,15 +2,16 @@ package com.epmet.filter; import com.alibaba.fastjson.JSON; -import com.epmet.common.token.enums.ErrorCode; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.Constant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.BaseTokenDto; +import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.Result; import com.epmet.jwt.JwtTokenUtils; -import io.jsonwebtoken.Claims; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +32,6 @@ import reactor.core.publisher.Mono; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; -import java.util.function.Consumer; /** * app接口权限过滤器 @@ -88,27 +88,33 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory().error(ErrorCode.ERR10005.getCode(),ErrorCode.ERR10005.getMsg())); + return response(exchange,new Result<>().error(EpmetErrorCode.ERR10005.getCode(),EpmetErrorCode.ERR10005.getMsg())); } try { - //当前登录用户userId,添加到header中 - TokenDto user = getLoginUserInfoByToken(token, jwtTokenUtils, cpUserDetailRedis); - if (user != null) { - String redisKey = user.getApp() + "-" + user.getClient() + "-" + user.getUserId(); - logger.info("redisKey=" + redisKey); - ServerHttpRequest build = exchange.getRequest().mutate() - .header(Constant.APP_USER_KEY, redisKey) - .header(AppClientConstant.APP,user.getApp()) - .header(AppClientConstant.CLIENT,user.getClient()) - .header(AppClientConstant.USER_ID,user.getUserId()) - .build(); - return chain.filter(exchange.mutate().request(build).build()); + BaseTokenDto baseTokenDto = getBaseTokenDto(token, jwtTokenUtils); + if (AppClientConstant.APP_RESI.equals(baseTokenDto.getApp())) { + // 居民端 + TokenDto resiTokenDto = getLoginUserInfoByToken(token, jwtTokenUtils, cpUserDetailRedis, TokenDto.class); + validateTokenDto(resiTokenDto, token); + } else if (AppClientConstant.APP_GOV.equals(baseTokenDto.getApp())) { + // 政府端 + GovTokenDto govTokenDto = getLoginUserInfoByToken(token, jwtTokenUtils, cpUserDetailRedis, GovTokenDto.class); + validateTokenDto(govTokenDto, token); } + + //当前登录用户userId,添加到header中 + String redisKey = baseTokenDto.getApp() + "-" + baseTokenDto.getClient() + "-" + baseTokenDto.getUserId(); + logger.info("redisKey=" + redisKey); + ServerHttpRequest build = exchange.getRequest().mutate() + .header(Constant.APP_USER_KEY, redisKey) + .header(AppClientConstant.APP,baseTokenDto.getApp()) + .header(AppClientConstant.CLIENT,baseTokenDto.getClient()) + .header(AppClientConstant.USER_ID,baseTokenDto.getUserId()) + .build(); + return chain.filter(exchange.mutate().request(build).build()); }catch(RenException e){ return response(exchange,new Result<>().error(e.getCode(),e.getMsg())); } - - return chain.filter(exchange); }; } @@ -182,4 +188,25 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory T getLoginUserInfoByToken(String token, JwtTokenUtils jwtTokenUtils, CpUserDetailRedis cpUserDetailRedis, Class clz) { + BaseTokenDto baseTokenDto = getBaseTokenDto(token, jwtTokenUtils); + //查询Redis + return cpUserDetailRedis.get(baseTokenDto.getApp(), baseTokenDto.getClient(), baseTokenDto.getUserId(), clz); } } diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index df1d12f050..c62dda3be3 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -176,6 +176,27 @@ spring: filters: - StripPrefix=1 - CpAuth=true + + + #政府端权限服务 + - id: gov-access-server + uri: @gateway.routes.gov-access-server.uri@ + order: 18 + predicates: + - Path=${server.servlet.context-path}/gov/access/** + filters: + - StripPrefix=1 + - CpAuth=true + + #政府端-我的-服务 + - id: gov-mine-server + uri: @gateway.routes.gov-mine-server.uri@ + order: 19 + predicates: + - Path=${server.servlet.context-path}/gov/mine/** + filters: + - StripPrefix=1 + - CpAuth=true nacos: discovery: server-addr: @nacos.server-addr@ @@ -283,6 +304,8 @@ epmet: - /resi/group/** - /resi/partymember/** - /gov/grid/** + - /gov/mine/** + - /gov/access/** swaggerUrls: jwt: diff --git a/epmet-module/gov-access/gov-access-client/pom.xml b/epmet-module/gov-access/gov-access-client/pom.xml new file mode 100644 index 0000000000..b20a28582a --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/pom.xml @@ -0,0 +1,21 @@ + + + + gov-access + com.epmet + 2.0.0 + + 4.0.0 + + gov-access-client + + + + com.epmet + epmet-commons-tools + 2.0.0 + + + \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/OperationScopeDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/OperationScopeDTO.java new file mode 100644 index 0000000000..19e1111e96 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/OperationScopeDTO.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +public class OperationScopeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/RoleOperationDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/RoleOperationDTO.java new file mode 100644 index 0000000000..bda4931386 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/RoleOperationDTO.java @@ -0,0 +1,82 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class RoleOperationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/RoleScopeDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/RoleScopeDTO.java new file mode 100644 index 0000000000..17f8866215 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/RoleScopeDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +public class RoleScopeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围Key + */ + private String scopeKey; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/OperationScopeFormDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/OperationScopeFormDTO.java new file mode 100644 index 0000000000..af992b7d51 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/OperationScopeFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class OperationScopeFormDTO { + + public interface ListOperationScopeGroup {} + + @NotBlank(message = "角色ID不能为空", groups = {ListOperationScopeGroup.class}) + private String roleId; + + @NotBlank(message = "操作的key不能为空", groups = {ListOperationScopeGroup.class}) + private String operationKey; + +} diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java new file mode 100644 index 0000000000..191314af0a --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java @@ -0,0 +1,54 @@ +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; + + /** + * 组织ID路径 + */ + private String orgIdPath; + + /** + * 权限列表 + */ + private Set permissions; + + /** + * 角色列表 + */ + private Set roleIdList; + +} diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java new file mode 100644 index 0000000000..fbafb374e7 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class RoleOpeScopeResultDTO { + + /** + * 角色ID + */ + private String roleId; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + + /** + * 范围序号 + */ + private String scopeIndex; + +} diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationResultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationResultDTO.java new file mode 100644 index 0000000000..dc7fc1559e --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOperationResultDTO.java @@ -0,0 +1,87 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class RoleOperationResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 操作名称 + */ + private String operationName; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java new file mode 100644 index 0000000000..ce24cf9501 --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/StaffPermCacheResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Set; + +@Data +public class StaffPermCacheResultDTO { + + /** + * 权限列表 + */ + private Set permissions; + + /** + * 角色列表 + */ + private Set roleIdList; + + /** + * 组织ID + */ + private String orgIdPath; + + /** + * 网格ID + */ + private String gridId; + +} diff --git a/epmet-module/gov-access/gov-access-server/pom.xml b/epmet-module/gov-access/gov-access-server/pom.xml new file mode 100644 index 0000000000..f71a21d4a0 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/pom.xml @@ -0,0 +1,182 @@ + + + 0.3.0 + + gov-access + com.epmet + 2.0.0 + + 4.0.0 + + gov-access-server + jar + + + + com.epmet + gov-access-client + 2.0.0 + + + com.epmet + epmet-commons-tools + 2.0.0 + + + com.epmet + epmet-commons-mybatis + 2.0.0 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-actuator + + + de.codecentric + spring-boot-admin-starter-client + ${spring.boot.admin.version} + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + io.github.openfeign + feign-httpclient + 10.3.0 + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + + + + + + dev-local + + true + + + 8099 + dev + + + + + + epmet_gov_access_user + EpmEt-db-UsEr + + 0 + 192.168.1.130 + 6379 + 123456 + + false + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + dev + + + 8099 + dev + + + + + + epmet + elink@833066 + + 0 + r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com + 6379 + EpmEtrEdIs!q@w + + true + 192.168.10.150:8848 + 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae + + + false + + + + + test + + + 8099 + test + + + + + + epmet + elink@833066 + + 0 + 10.10.10.248 + 6379 + 123456 + + true + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java new file mode 100644 index 0000000000..f4781aa923 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java @@ -0,0 +1,20 @@ +package com.epmet; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +public class GovAccessApplication { + public static void main(String[] args) { + SpringApplication.run(GovAccessApplication.class, args); + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/ModuleConfigImpl.java new file mode 100644 index 0000000000..128f1060ef --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/ModuleConfigImpl.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.config; + +import com.epmet.commons.tools.config.ModuleConfig; +import org.springframework.stereotype.Service; + +/** + * 模块配置信息-新闻公告模块 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Service +public class ModuleConfigImpl implements ModuleConfig { + @Override + public String getName() { + return "govaccess"; + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java new file mode 100644 index 0000000000..e34df14a06 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java @@ -0,0 +1,81 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.OperationScopeDTO; +import com.epmet.dto.form.OperationScopeFormDTO; +import com.epmet.dto.form.StaffPermCacheFormDTO; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.dto.result.StaffPermCacheResultDTO; +import com.epmet.entity.OperationScopeEntity; +import com.epmet.service.AccessService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +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 permissions = staffPermCacheFormDTO.getPermissions(); + Set roleIdList = staffPermCacheFormDTO.getRoleIdList(); + String orgId = staffPermCacheFormDTO.getOrgIdPath(); + accessService.updatePermissionCache(staffId, app, client, permissions, roleIdList, orgId); + return new Result(); + } + + /** + * 查询用户当前权限列表(DataFilterAspect中用到) + * @return + */ + @PostMapping("getcurrpermissions") + public Result getStaffCurrPermissions(@RequestBody StaffPermCacheFormDTO dto) { + ValidatorUtils.validateEntity(dto, StaffPermCacheFormDTO.GetStaffCurrPermissions.class); + GovTokenDto govTokenDto = accessService.listStaffCurrPermissions(dto.getApp(), dto.getClient(), dto.getStaffId()); + StaffPermCacheResultDTO resultDTO = null; + if (govTokenDto != null) { + resultDTO = new StaffPermCacheResultDTO(); + resultDTO.setPermissions(govTokenDto.getPermissions()); + resultDTO.setRoleIdList(govTokenDto.getRoleIdList()); + resultDTO.setOrgIdPath(govTokenDto.getOrgIdPath()); + resultDTO.setGridId(govTokenDto.getGridId()); + } + return new Result().ok(resultDTO); + } + + /** + * 查询角色的操作key对应操作范围列表(缓存) + * @return + */ + @PostMapping("operationscopes") + public Result> getOperationScopesByRoleId(@RequestBody OperationScopeFormDTO operationScopeFormDTO) { + ValidatorUtils.validateEntity(operationScopeFormDTO, OperationScopeFormDTO.ListOperationScopeGroup.class); + Set scopes = accessService.listOperationScopesByRoleId(operationScopeFormDTO.getRoleId(), operationScopeFormDTO.getOperationKey()); + return new Result>().ok(scopes); + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java new file mode 100644 index 0000000000..8e9778734b --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/RoleController.java @@ -0,0 +1,33 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.service.RoleOperationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("role") +public class RoleController { + + @Autowired + private RoleOperationService roleOperationService; + + /** + * 查询角色对应的操作列表 + * @param roleId + * @return + */ + @PostMapping("operations/{roleId}") + public Result> listOperationsByRoleId(@PathVariable("roleId") String roleId) { + List roleOperationResultDTOS = roleOperationService.listOperationsByRoleId(roleId); + return new Result>().ok(roleOperationResultDTOS); + } + + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java new file mode 100644 index 0000000000..438f105eab --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java @@ -0,0 +1,17 @@ +package com.epmet.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("test") +public class TestController { + + @GetMapping("test") + public void test() { + System.out.println(666); + } + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDao.java new file mode 100644 index 0000000000..4ac02b7f91 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/OperationScopeDao.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.entity.OperationScopeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.context.annotation.Scope; + +import java.util.List; +import java.util.Set; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Mapper +public interface OperationScopeDao extends BaseDao { + + /** + * 查询角色的操作key对应操作范围列表 + * @param roleId 角色id + * @param operationKey 操作key + * @return + */ + Set listOperationScopesByRoleId(@Param("roleId") String roleId, + @Param("operationKey") String operationKey); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDao.java new file mode 100644 index 0000000000..a1b408ba7a --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleOperationDao.java @@ -0,0 +1,38 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.entity.RoleOperationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Mapper +public interface RoleOperationDao extends BaseDao { + + List listOperationsByRoleId(@Param("roleId") String roleId); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleScopeDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleScopeDao.java new file mode 100644 index 0000000000..60982f5528 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleScopeDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.RoleScopeEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Mapper +public interface RoleScopeDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeEntity.java new file mode 100644 index 0000000000..2fd6b18361 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeEntity.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("operation_scope") +public class OperationScopeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationEntity.java new file mode 100644 index 0000000000..96f70de1be --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleOperationEntity.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("role_operation") +public class RoleOperationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleScopeEntity.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleScopeEntity.java new file mode 100644 index 0000000000..2c3c6f21dc --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/RoleScopeEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("role_scope") +public class RoleScopeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围Key + */ + private String scopeKey; + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/excel/RoleOperationExcel.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/excel/RoleOperationExcel.java new file mode 100644 index 0000000000..4b0c4ee373 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/excel/RoleOperationExcel.java @@ -0,0 +1,62 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class RoleOperationExcel { + + @Excel(name = "") + private String id; + + @Excel(name = "角色ID") + private String roleId; + + @Excel(name = "操作key") + private String operationKey; + + @Excel(name = "是否删除,0:未删除,1:已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建者id") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新者id") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleOpeScopeRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleOpeScopeRedis.java new file mode 100644 index 0000000000..cd929c692d --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleOpeScopeRedis.java @@ -0,0 +1,43 @@ +package com.epmet.redis; + +import cn.hutool.core.bean.BeanUtil; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Set; + +/** + * 角色的操作权限对应的操作范围Redis + */ +@Component +public class RoleOpeScopeRedis { + + @Autowired + private RedisUtils redisUtils; + + /** + * 缓存角色操作范围 + * @param roleId + * @param opeKey + * @param scopes + */ + public void setRoleOpeScopes(String roleId, String opeKey, Set scopes) { + String roleOpeScopesKey = RedisKeys.getRoleOpeScopesKey(roleId, opeKey); + redisUtils.set(roleOpeScopesKey, scopes); + } + + /** + * 查询角色操作范围 + * @param roleId + * @param opeKey + * @return + */ + public Set getRoleOpeScopes(String roleId, String opeKey) { + String roleOpeScopesKey = RedisKeys.getRoleOpeScopesKey(roleId, opeKey); + return (Set)redisUtils.get(roleOpeScopesKey); + } + +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java new file mode 100644 index 0000000000..df16e1e9df --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java @@ -0,0 +1,31 @@ +package com.epmet.service; + +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.entity.OperationScopeEntity; + +import java.util.List; +import java.util.Set; + +public interface AccessService { + /** + * 更新权限缓存 + * @param staffId + * @param permissions + */ + void updatePermissionCache(String staffId, String app, String client, Set permissions, Set roleIdList, String orgIdPath); + + /** + * 查询用户当前权限列表 + * @return + */ + GovTokenDto listStaffCurrPermissions(String app, String client, String staffId); + + /** + * 查询角色的操作key对应操作范围列表 + * @param roleId + * @param operationKey + * @return + */ + Set listOperationScopesByRoleId(String roleId, String operationKey); +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationScopeService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationScopeService.java new file mode 100644 index 0000000000..cb24b913c0 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationScopeService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperationScopeDTO; +import com.epmet.entity.OperationScopeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +public interface OperationScopeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-24 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-24 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperationScopeDTO + * @author generator + * @date 2020-04-24 + */ + OperationScopeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void save(OperationScopeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void update(OperationScopeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-24 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/RoleOperationService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/RoleOperationService.java new file mode 100644 index 0000000000..ebc000a36b --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/RoleOperationService.java @@ -0,0 +1,103 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.RoleOperationDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.entity.RoleOperationEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +public interface RoleOperationService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-22 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-22 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return RoleOperationDTO + * @author generator + * @date 2020-04-22 + */ + RoleOperationDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void save(RoleOperationDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void update(RoleOperationDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-22 + */ + void delete(String[] ids); + + /** + * 查询角色对应的操作列表 + * @param roleId + * @return + */ + List listOperationsByRoleId(String roleId); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/RoleScopeService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/RoleScopeService.java new file mode 100644 index 0000000000..34cdd6e07f --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/RoleScopeService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.RoleScopeDTO; +import com.epmet.entity.RoleScopeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +public interface RoleScopeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-24 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-24 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return RoleScopeDTO + * @author generator + * @date 2020-04-24 + */ + RoleScopeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void save(RoleScopeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void update(RoleScopeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-24 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java new file mode 100644 index 0000000000..34e458ec6a --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -0,0 +1,80 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.dao.OperationScopeDao; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.redis.RoleOpeScopeRedis; +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.Set; + +@Service +public class AccessServiceImpl implements AccessService { + + private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); + + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + + @Autowired + private OperationScopeDao operationScopeDao; + + @Autowired + private RoleOpeScopeRedis roleOpeScopeRedis; + + /** + * 更新权限缓存 + * @param staffId + * @param permissions + */ + @Override + public void updatePermissionCache(String staffId, String app, String client, Set permissions, Set roleIdList, String orgIdPath) { + GovTokenDto govTokenDto = cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); + if (govTokenDto == null) { + logger.warn("更新[{}]用户缓存:Redis中不存在该用户TokenDto缓存信息", staffId); + return ; + } + // 将权限,角色列表,和当前组织ID存入TokenDto + govTokenDto.setPermissions(permissions); + govTokenDto.setRoleIdList(roleIdList); + govTokenDto.setOrgIdPath(orgIdPath); + + // 将新的TokenDto更新到redis中 + long expire = cpUserDetailRedis.getExpire(app, client, staffId); + cpUserDetailRedis.set(govTokenDto, expire); + logger.warn("更新[{}]用户缓存成功。", staffId); + } + + @Override + public GovTokenDto listStaffCurrPermissions(String app, String client, String staffId) { + return cpUserDetailRedis.get(app, client, staffId, GovTokenDto.class); + } + + /** + * 查询角色的操作key对应操作范围列表 + * @param roleId + * @param operationKey + * @return + */ + public Set listOperationScopesByRoleId(String roleId, String operationKey) { + Set roleOpeScopes = roleOpeScopeRedis.getRoleOpeScopes(roleId, operationKey); + if (roleOpeScopes != null) { + return roleOpeScopes; + } + Set scopes = operationScopeDao.listOperationScopesByRoleId(roleId, operationKey); + try { + roleOpeScopeRedis.setRoleOpeScopes(roleId, operationKey, scopes); + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + logger.error("GovAccess:查询角色的操作范围:缓存范围出错:{}", errorStackTrace); + } + return scopes; + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationScopeServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationScopeServiceImpl.java new file mode 100644 index 0000000000..e582395fe2 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationScopeServiceImpl.java @@ -0,0 +1,101 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.OperationScopeDao; +import com.epmet.dto.OperationScopeDTO; +import com.epmet.entity.OperationScopeEntity; +import com.epmet.service.OperationScopeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Service +public class OperationScopeServiceImpl extends BaseServiceImpl implements OperationScopeService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperationScopeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperationScopeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperationScopeDTO get(String id) { + OperationScopeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperationScopeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperationScopeDTO dto) { + OperationScopeEntity entity = ConvertUtils.sourceToTarget(dto, OperationScopeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperationScopeDTO dto) { + OperationScopeEntity entity = ConvertUtils.sourceToTarget(dto, OperationScopeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java new file mode 100644 index 0000000000..a690363b33 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java @@ -0,0 +1,106 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.RoleOperationDao; +import com.epmet.dto.RoleOperationDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.entity.RoleOperationEntity; +import com.epmet.service.RoleOperationService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Service +public class RoleOperationServiceImpl extends BaseServiceImpl implements RoleOperationService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, RoleOperationDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, RoleOperationDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public RoleOperationDTO get(String id) { + RoleOperationEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, RoleOperationDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(RoleOperationDTO dto) { + RoleOperationEntity entity = ConvertUtils.sourceToTarget(dto, RoleOperationEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(RoleOperationDTO dto) { + RoleOperationEntity entity = ConvertUtils.sourceToTarget(dto, RoleOperationEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List listOperationsByRoleId(String roleId) { + return baseDao.listOperationsByRoleId(roleId); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleScopeServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleScopeServiceImpl.java new file mode 100644 index 0000000000..bff52f8d64 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/RoleScopeServiceImpl.java @@ -0,0 +1,100 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.RoleScopeDao; +import com.epmet.dto.RoleScopeDTO; +import com.epmet.entity.RoleScopeEntity; +import com.epmet.service.RoleScopeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Service +public class RoleScopeServiceImpl extends BaseServiceImpl implements RoleScopeService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, RoleScopeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, RoleScopeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public RoleScopeDTO get(String id) { + RoleScopeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, RoleScopeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(RoleScopeDTO dto) { + RoleScopeEntity entity = ConvertUtils.sourceToTarget(dto, RoleScopeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(RoleScopeDTO dto) { + RoleScopeEntity entity = ConvertUtils.sourceToTarget(dto, RoleScopeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml b/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000..cf118b769a --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml @@ -0,0 +1,103 @@ +server: + port: @server.port@ + servlet: + context-path: /gov/access + +spring: + main: + allow-bean-definition-overriding: true + application: + name: gov-access-server + #环境 dev|test|prod + profiles: + active: dev + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + redis: + database: @spring.redis.index@ + host: @spring.redis.host@ + port: @spring.redis.port@ + password: @spring.redis.password@ + timeout: 30s + datasource: + druid: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: @spring.datasource.druid.url@ + username: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ + cloud: + nacos: + discovery: + server-addr: @nacos.server-addr@ + #nacos的命名空间ID,默认是public + namespace: @nacos.discovery.namespace@ + #不把自己注册到注册中心的地址 + register-enabled: @nacos.register-enabled@ + ip: @nacos.ip@ + config: + enabled: @nacos.config-enabled@ + server-addr: @nacos.server-addr@ + namespace: @nacos.config.namespace@ + group: @nacos.config.group@ + file-extension: yaml + #指定共享配置,且支持动态刷新 +# ext-config: +# - data-id: datasource.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true +# - data-id: common.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true +management: + endpoints: + web: + exposure: + include: "*" + endpoint: + health: + show-details: ALWAYS + +mybatis-plus: + mapper-locations: classpath:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.epmet.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: ID_WORKER + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: NOT_NULL + #驼峰下划线转换 + column-underline: true + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + +feign: + hystrix: + enabled: true + client: + config: + default: + loggerLevel: BASIC + httpclient: + enabled: true + +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds: 60000 #缺省为1000 + +ribbon: + ReadTimeout: 300000 + ConnectTimeout: 300000 diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql b/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql new file mode 100644 index 0000000000..93d8c2a148 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql @@ -0,0 +1,76 @@ +/* + Date: 22/04/2020 12:13:38 +*/ + +-- SET NAMES utf8mb4; +-- #SET FOREIGN_KEY_CHECKS = 0; + +-- DROP TABLE IF EXISTS `permission_scope`; +CREATE TABLE `operation_scope` ( + `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'id', + `SCOPE_KEY` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围key', + `SCOPE_NAME` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围名称', + `SCOPE_INDEX` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '范围序号', + `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', + `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者id', + `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '权限范围表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for resource_ope +-- ---------------------------- +-- DROP TABLE IF EXISTS `operation`; +CREATE TABLE `operation` ( + `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `OPERATION_KEY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `OPERATION_NAME` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `BRIEF` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作简介', + `DEL_FLAG` tinyint(1) NULL DEFAULT NULL, + `REVISION` int(10) NULL DEFAULT NULL, + `CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CREATED_TIME` datetime(0) NULL DEFAULT NULL, + `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `UPDATED_TIME` datetime(0) NULL DEFAULT NULL, + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作类型表' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for role_operation +-- ---------------------------- +-- DROP TABLE IF EXISTS `role_operation`; +CREATE TABLE `role_operation` ( + `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', + `OPERATION_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', + `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者id', + `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色能进行那些操作' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for role_scope +-- ---------------------------- +-- DROP TABLE IF EXISTS `role_scope`; +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', + `OPERATION_KEY` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作Key', + `SCOPE_KEY` varchar(30) 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', + `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者id', + `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色能操作哪些范围' ROW_FORMAT = Dynamic; + +-- SET FOREIGN_KEY_CHECKS = 1; diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..e43fd0e845 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + ${log.path}/error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml new file mode 100644 index 0000000000..ab6839e941 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDao.xml new file mode 100644 index 0000000000..0845fc5202 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleOperationDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleScopeDao.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleScopeDao.xml new file mode 100644 index 0000000000..fdca928212 --- /dev/null +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleScopeDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-access/pom.xml b/epmet-module/gov-access/pom.xml new file mode 100644 index 0000000000..b81b68f895 --- /dev/null +++ b/epmet-module/gov-access/pom.xml @@ -0,0 +1,21 @@ + + + + epmet-module + com.epmet + 2.0.0 + + 4.0.0 + + gov-access + pom + + + gov-access-client + gov-access-server + + + + \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-client/pom.xml b/epmet-module/gov-mine/gov-mine-client/pom.xml new file mode 100644 index 0000000000..7dd4b864f7 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-client/pom.xml @@ -0,0 +1,35 @@ + + + + com.epmet + gov-mine + 2.0.0 + + 4.0.0 + + gov-mine-client + + + + com.epmet + epmet-commons-tools + 2.0.0 + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + + + + + ${project.artifactId} + + + + \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffOperationDTO.java b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffOperationDTO.java new file mode 100644 index 0000000000..220f1f4a8f --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffOperationDTO.java @@ -0,0 +1,13 @@ +package com.epmet.dto.form; + +import lombok.Data; + +@Data +public class StaffOperationDTO { + + //@NotBlank(message = "角色所属组织ID不能为空") + private String agencyId; + + //@NotBlank(message = "角色所属网格ID不能为空") + private String gridId; +} diff --git a/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java new file mode 100644 index 0000000000..48938483bb --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java @@ -0,0 +1,9 @@ +package com.epmet.dto.form; + +import lombok.Data; + +@Data +public class StaffRoleFormDTO { + private String staffId; + private String orgId; +} diff --git a/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/SwitchGridFormDTO.java b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/SwitchGridFormDTO.java new file mode 100644 index 0000000000..ab0a44d2e6 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-client/src/main/java/com/epmet/dto/form/SwitchGridFormDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 切换网格入参 + * @Author yinzuomei + * @Date 2020/4/23 10:41 + */ +@Data +public class SwitchGridFormDTO implements Serializable { + private static final long serialVersionUID = -2898130727929596798L; + + /** + * customerId + */ + @NotBlank(message = "customerId不能为空") + private String customerId; + + /** + * gridId + */ + @NotBlank(message = "gridId不能为空") + private String gridId; + + /** + * staffId从tokenTto获取 + */ + @NotBlank(message = "staffId不能为空") + private String staffId; +} + diff --git a/epmet-module/gov-mine/gov-mine-server/pom.xml b/epmet-module/gov-mine/gov-mine-server/pom.xml new file mode 100644 index 0000000000..b06d8fc331 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/pom.xml @@ -0,0 +1,181 @@ + + + 0.3.0 + + com.epmet + gov-mine + 2.0.0 + + 4.0.0 + + gov-mine-server + + + + com.epmet + gov-mine-client + 2.0.0 + + + com.epmet + oper-customize-client + 2.0.0 + + + com.epmet + epmet-commons-tools + 2.0.0 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-actuator + + + de.codecentric + spring-boot-admin-starter-client + ${spring.boot.admin.version} + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + io.github.openfeign + feign-httpclient + 10.3.0 + + + com.epmet + gov-org-client + 2.0.0 + compile + + + com.epmet + epmet-user-client + 2.0.0 + compile + + + com.epmet + gov-access-client + 2.0.0 + compile + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + + + + + + dev-local + + true + + + 8098 + dev + + + 0 + 192.168.1.130 + 6379 + 123456 + + false + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + dev + + + 8098 + dev + + + 0 + r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com + 6379 + EpmEtrEdIs!q@w + + true + 192.168.10.150:8848 + 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae + + + false + + + + + test + + + 8098 + test + + + 0 + 10.10.10.248 + 6379 + 123456 + + true + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java new file mode 100644 index 0000000000..f804c3926e --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java @@ -0,0 +1,17 @@ +package com.epmet; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +public class GovMineApplication { + + public static void main(String[] args) { + SpringApplication.run(GovMineApplication.class, args); + } + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/config/.gitkeep similarity index 100% rename from epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/.gitkeep rename to epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/config/.gitkeep diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/config/ModuleConfigImpl.java new file mode 100644 index 0000000000..8ccca90cd1 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/config/ModuleConfigImpl.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.config; + +import com.epmet.commons.tools.config.ModuleConfig; +import org.springframework.stereotype.Service; + +/** + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Service +public class ModuleConfigImpl implements ModuleConfig { + @Override + public String getName() { + return "govmine"; + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/constant/StaffAgencyConstant.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/constant/StaffAgencyConstant.java new file mode 100644 index 0000000000..b6a2591152 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/constant/StaffAgencyConstant.java @@ -0,0 +1,12 @@ +package com.epmet.constant; + +/** + * @Description 机构员工的常量 + * @IntefaceName StaffAgencyConstant + * @Author wangc + * @date 2020.04.23 11:25 + */ +public interface StaffAgencyConstant { + + String QUERY_LATEST_GRID_INFO_FAILED = "查询上一次登录的网格信息失败"; +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java new file mode 100644 index 0000000000..61944d3939 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AccessController.java @@ -0,0 +1,49 @@ +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.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.StaffOperationDTO; +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.List; +import java.util.Set; + +/** + * @return + * 我的权限相关 + * @Author wxz + * @Description + * @Date 2020/4/22 22:18 + **/ +@RestController +@RequestMapping("access") +public class AccessController { + + @Autowired + private AccessService accessService; + + /** + * 查询用户可操作功能列表(同时更新缓存) + * @param tokenDto + * @param staffOperationDTO + * @return + */ + @PostMapping("getstaffoperations") + public Result> getStaffOperations(@LoginUser TokenDto tokenDto, @RequestBody StaffOperationDTO staffOperationDTO) { + //public Result> getStaffOperations(@RequestBody StaffOperationDTO staffOperationDTO) { + String agencyId = staffOperationDTO.getAgencyId(); + String gridId = staffOperationDTO.getGridId(); + String staffId = tokenDto.getUserId(); + String app = tokenDto.getApp(); + String client = tokenDto.getClient(); + Set opeKeys = accessService.listOpeKeysByStaffId(app, client, staffId,agencyId, gridId); + return new Result>().ok(opeKeys); + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AppController.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AppController.java new file mode 100644 index 0000000000..93fef03372 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/AppController.java @@ -0,0 +1,37 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerFootBarDTO; +import com.epmet.dto.form.CustomerFootBarFormDTO; +import com.epmet.feign.OperCustomizeFeignClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +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; + +@RestController +@RequestMapping("app") +public class AppController { + + @Autowired + private OperCustomizeFeignClient operCustomizeFeign; + + /** + * 查询 + * @param formDTO + * @return + */ + @PostMapping("getcustomerfootbars") + public Result> getCustomerFootBars(@RequestBody CustomerFootBarFormDTO formDTO) { + Result> result = operCustomizeFeign.getCustomerfootbars(formDTO); + if (CollectionUtils.isEmpty(result.getData())) { + formDTO.setCustomerId("default"); + result = operCustomizeFeign.getCustomerfootbars(formDTO); + } + return result; + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java new file mode 100644 index 0000000000..7cde40d997 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/controller/StaffAgencyController.java @@ -0,0 +1,99 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.form.SwitchGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.service.StaffAgencyService; +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 javax.validation.Valid; +import java.util.List; + +/** + * 机关单位信息表 + * + * @author generator generator@elink-cn.com + */ +@RestController +@RequestMapping("agency") +public class StaffAgencyController { + + @Autowired + private StaffAgencyService staffAgencyService; + + /** + * @param tokenDTO + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + @PostMapping("getmygrids") + public Result> getMyGrids(@LoginUser TokenDto tokenDTO) { + return staffAgencyService.getMyGrids(tokenDTO); + } + + /** + * 获取最近一次登录的客户信息 + * + * @param tokenDTO + * @return + */ + @PostMapping("getlatestcustomer") + public Result getLatestCustomer(@LoginUser TokenDto tokenDTO) { + return staffAgencyService.getLatestCustomer(tokenDTO); + } + + /** + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 切换网格 + * @Date 2020/4/23 10:34 + **/ + @PostMapping("switchgrid") + public Result switchGrid(@LoginUser TokenDto tokenDto, @RequestBody @Valid SwitchGridFormDTO switchGridFormDTO) { + switchGridFormDTO.setStaffId(tokenDto.getUserId()); + return staffAgencyService.switchGrid(switchGridFormDTO); + } + /** + * @Description 得到工作人员最后一次登录的网格 + * @Param TokenDto -> userId/staffId + * @Param LatestGridFormDTO -> customerId + * @return Result + * @Author wangc + * @Date 2020.04.23 11:16 + **/ + @PostMapping("getlatestgrid") + public Result getLatestGrid(@LoginUser TokenDto tokenDto, @RequestBody LatestGridFormDTO latestGridFormDTO){ + latestGridFormDTO.setStaffId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(latestGridFormDTO); + return staffAgencyService.getLatestGrid(latestGridFormDTO); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/dao/.gitkeep b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/dao/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/entity/.gitkeep b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/entity/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/excel/.gitkeep b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/excel/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java new file mode 100644 index 0000000000..287da51fec --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -0,0 +1,63 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.feign.fallback.EpmetUserFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +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; + + +/** + * @Description + * @Author sun + */ +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallback.class) +public interface EpmetUserFeignClient { + /** + * 获取最近一次登录的客户信息 + * + * @param userId + * @return + */ + @GetMapping("/epmetuser/staffagencyvisited/getlatestcustomer/{userId}") + Result getLatestCustomer(@PathVariable("userId") String userId); + + /** + * @Description 查询工作人员上次登录的网格 + * @Param customerId ; staffId + * @return Result + * @Author wangc + * @Date 2020.04.23 10:44 + **/ + @PostMapping(value = "/epmetuser/staffgridvisited/getstafflatestgrid") + Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO); + + /** + * @param staffGridVisitedFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存网格访问记录 + * @Date 2020/4/23 13:27 + **/ + @PostMapping(value = "/epmetuser/staffgridvisited/savestaffgridvisitedrecord", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result saveStaffGridVisitedRecord(@RequestBody StaffGridVisitedFormDTO staffGridVisitedFormDTO); + /** + * 查询工作人员的角色 + * @return + */ + @PostMapping("/epmetuser/staffrole/staffroles") + Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO); +} + diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java new file mode 100644 index 0000000000..b41a5e59ca --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java @@ -0,0 +1,37 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffPermCacheFormDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.feign.fallback.GovAccessFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @Description + * @Author sun + */ +@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallback.class, url = "localhost:8099") +public interface GovAccessFeignClient { + + /** + * 根据角色ID查询角色权限列表 + * @param roleId + * @return + */ + @PostMapping("/gov/access/role/operations/{roleId}") + Result> listOperationsByRoleId(@PathVariable("roleId") String roleId); + + /** + * 刷新用户权限缓存 + * @param staffPermCacheFormDTO + * @return + */ + @PostMapping("/gov/access/access/updatepermissioncache") + Result updatePermissionCache(@RequestBody StaffPermCacheFormDTO staffPermCacheFormDTO); +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java new file mode 100644 index 0000000000..8c03d28764 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -0,0 +1,60 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +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; + +/** + * @Description + * @Author sun + */ +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) +public interface GovOrgFeignClient { + + /** + * @param userId + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + @GetMapping(value = "/gov/org/customergrid/getmygrids/{userId}") + Result> getMyGrids(@PathVariable("userId") String userId); + + /** + * 获取最近一次登录的客户信息 + * + * @param userId + * @return + */ + @GetMapping("/gov/org/customerstaffagency/getlatestcustomer/{userId}") + Result getLatestCustomer(@PathVariable("userId") String userId); + + /** + * @Description 查询指定客户下一个用户所在的网格,调用gov-org + * @Param LatestGridFormDTO -> customerId ; staffId + * @return Result + * @Author wangc + * @Date 2020.04.23 10:53 + **/ + @PostMapping(value = "/gov/org/customerstaffgrid/getstaffgrid") + Result getStaffGrid(@RequestBody LatestGridFormDTO latestGridFormDTO); + + /** + * 根据Id查询agency + * @param agencyId + * @return + */ + @PostMapping("/gov/org/agency/{agencyId}") + Result getAgencyById(@PathVariable("agencyId") String agencyId); +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java new file mode 100644 index 0000000000..a645d0d44b --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/OperCustomizeFeignClient.java @@ -0,0 +1,21 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerFootBarDTO; +import com.epmet.dto.form.CustomerFootBarFormDTO; +import com.epmet.feign.fallback.OperCustomizeFeignClientFallBack; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeFeignClientFallBack.class) +public interface OperCustomizeFeignClient { + + @PostMapping(value = "/oper/customize/customerfootbar/customerfootbars", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result> getCustomerfootbars(@RequestBody CustomerFootBarFormDTO formDTO); + +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java new file mode 100644 index 0000000000..fba1ee780a --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java @@ -0,0 +1,42 @@ +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.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.feign.EpmetUserFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Description + * @Author sun + */ +@Component +public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { + + @Override + public Result getLatestCustomer(String userId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getLatestCustomer", userId); + } + + @Override + public Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff"); + } + @Override + public Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffLatestGrid",latestGridFormDTO); + } + @Override + public Result saveStaffGridVisitedRecord(StaffGridVisitedFormDTO staffGridVisitedFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffGridVisitedRecord", staffGridVisitedFormDTO); + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java new file mode 100644 index 0000000000..3e9fc8e415 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java @@ -0,0 +1,35 @@ +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.form.StaffPermCacheFormDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.feign.GovAccessFeignClient; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @Description + * @Author sun + */ +@Component +public class GovAccessFeignClientFallback implements GovAccessFeignClient { + + @Override + public Result> 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"); + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java new file mode 100644 index 0000000000..128f81bd50 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -0,0 +1,41 @@ +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.CustomerAgencyDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.feign.GovOrgFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Description + * @Author sun + */ +@Component +public class GovOrgFeignClientFallBack implements GovOrgFeignClient { + + @Override + public Result> getMyGrids(String userId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getMyGrids", userId); + } + + @Override + public Result getStaffGrid(LatestGridFormDTO latestGridFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffGrid",latestGridFormDTO); + } + + @Override + public Result getAgencyById(String agencyId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyById", agencyId); + } + + @Override + public Result getLatestCustomer(String userId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getLatestCustomer", userId); + } +} \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/OperCustomizeFeignClientFallBack.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/OperCustomizeFeignClientFallBack.java new file mode 100644 index 0000000000..6f343f3857 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/OperCustomizeFeignClientFallBack.java @@ -0,0 +1,22 @@ +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.CustomerFootBarDTO; +import com.epmet.dto.form.CustomerFootBarFormDTO; +import com.epmet.dto.form.CustomerHomeFormDTO; +import com.epmet.dto.result.HomeDesignByCustomerResultDTO; +import com.epmet.feign.OperCustomizeFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class OperCustomizeFeignClientFallBack implements OperCustomizeFeignClient { + + @Override + public Result> getCustomerfootbars(CustomerFootBarFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "getCustomerfootbars",formDTO); + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/redis/StaffAgencyRedis.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/redis/StaffAgencyRedis.java new file mode 100644 index 0000000000..73608057c8 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/redis/StaffAgencyRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 机关单位信息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-20 + */ +@Component +public class StaffAgencyRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java new file mode 100644 index 0000000000..9866ea9ffd --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/AccessService.java @@ -0,0 +1,18 @@ +package com.epmet.service; + +import java.util.List; +import java.util.Set; + +/** + * 权限service + * @Author wxz + * @Description + * @Date 2020/4/22 23:29 + **/ +public interface AccessService { + /** + * 根据staffId查询角色Key列表 + * @return + */ + Set listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId); +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/StaffAgencyService.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/StaffAgencyService.java new file mode 100644 index 0000000000..2530c956a4 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/StaffAgencyService.java @@ -0,0 +1,69 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.form.SwitchGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; + +import java.util.List; + +/** + * 机关单位信息表 + * + * @author generator generator@elink-cn.com + */ +public interface StaffAgencyService { + + /** + * @param tokenDTO + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + Result> getMyGrids(TokenDto tokenDTO); + + /** + * 获取最近一次登录的客户信息 + * + * @param tokenDTO + * @return + */ + Result getLatestCustomer(TokenDto tokenDTO); + + /** + * @param switchGridFormDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 切换网格 + * @Date 2020/4/23 10:49 + **/ + Result switchGrid(SwitchGridFormDTO switchGridFormDTO); + + /** + * @Description 得到工作人员最后一次登录的网格 + * @Param LatestGridFormDTO -> staffId ; customerId + * @return Result + * @Author wangc + * @Date 2020.04.23 11:14 + **/ + Result getLatestGrid(LatestGridFormDTO latestGridFormDTO); +} \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java new file mode 100644 index 0000000000..d76e2e2f34 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -0,0 +1,106 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.StaffPermCacheFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.GovAccessFeignClient; +import com.epmet.feign.GovOrgFeignClient; +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.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Service +public class AccessServiceImpl implements AccessService { + + private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); + + @Autowired + private EpmetUserFeignClient userFeignClient; + + @Autowired + private GovAccessFeignClient govAccessFeignClient; + + @Autowired + private GovOrgFeignClient govOrgFeignClient; + + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + + @Override + public Set listOpeKeysByStaffId(String app, String client, String staffId, String agencyId, String gridId) { + List roleDTOS = new ArrayList<>(); + // 查询机关单位权限 + StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); + formDTO.setStaffId(staffId); + formDTO.setOrgId(agencyId); + Result> agencyResult = userFeignClient.getRolesOfStaff(formDTO); + if (!CollectionUtils.isEmpty(agencyResult.getData())) { + roleDTOS.addAll(agencyResult.getData()); + } + // 查询网格权限 + formDTO.setStaffId(staffId); + formDTO.setOrgId(gridId); + Result> gridResult = userFeignClient.getRolesOfStaff(formDTO); + if (!CollectionUtils.isEmpty(gridResult.getData())) { + roleDTOS.addAll(gridResult.getData()); + } + + // 拼装操作key列表 + Set opeKeys = new HashSet<>(); + // 角色ID列表 + Set roleIds = new HashSet<>(); + roleDTOS.forEach(roleDto -> { + String roleId = roleDto.getId(); + Result> result = govAccessFeignClient.listOperationsByRoleId(roleId); + if (result.getCode() != 0) { + // 获取operation异常 + logger.error("调用GovAccess,根据RoleId查询Operation列表失败:{}", result.getMsg()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + List roleOperations = result.getData(); + // 角色id + roleIds.add(roleDto.getId()); + if (!CollectionUtils.isEmpty(roleOperations)) { + roleOperations.forEach(roleOpe -> { + if (roleOpe != null) { + opeKeys.add(roleOpe.getOperationKey()); + } + }); + } + }); + + // 查询该直属机关的orgIdPath + Result agencyById = govOrgFeignClient.getAgencyById(agencyId); + if (agencyById.getCode() != 0 || agencyById.getData() == null) { + logger.error("根据当前机构id[{}]查询pids失败:{}", agencyId, agencyById.getMsg()); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + // 将最新权限缓存到redis,为了尽量统一操作入口,调用gov-access接口实现 + StaffPermCacheFormDTO staffPermCacheFormDTO = new StaffPermCacheFormDTO(); + staffPermCacheFormDTO.setApp(app); + staffPermCacheFormDTO.setClient(client); + staffPermCacheFormDTO.setStaffId(staffId); + staffPermCacheFormDTO.setPermissions(opeKeys); + staffPermCacheFormDTO.setRoleIdList(roleIds); + // 拼接orgIdPath + staffPermCacheFormDTO.setOrgIdPath(String.format("%s:%s", agencyById.getData().getPids(), agencyId)); + govAccessFeignClient.updatePermissionCache(staffPermCacheFormDTO); + return opeKeys; + } +} diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/StaffAgencyServiceImpl.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/StaffAgencyServiceImpl.java new file mode 100644 index 0000000000..adc8807690 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/StaffAgencyServiceImpl.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +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.constant.StaffAgencyConstant; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.dto.form.SwitchGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.GovOrgFeignClient; +import com.epmet.service.AccessService; +import com.epmet.service.StaffAgencyService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 机关单位信息表 + * + * @author generator generator@elink-cn.com + */ +@Service +public class StaffAgencyServiceImpl implements StaffAgencyService { + private static Logger logger = LoggerFactory.getLogger(StaffAgencyServiceImpl.class); + @Autowired + private GovOrgFeignClient govOrgFeignClient; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private AccessService accessService; + /** + * @param tokenDTO + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + @Override + public Result> getMyGrids(TokenDto tokenDTO) { + return govOrgFeignClient.getMyGrids(tokenDTO.getUserId()); + } + + @Override + public Result getLatestCustomer(TokenDto tokenDTO) { + return govOrgFeignClient.getLatestCustomer(tokenDTO.getUserId()); + } + + /** + * @Description 得到工作人员最后一次登录的网格 + * @Param LatestGridFormDTO -> staffId ; customerId + * @return Result + * @Author wangc + * @Date 2020.04.23 11:14 + **/ + @Override + public Result getLatestGrid(LatestGridFormDTO latestGridFormDTO) { + Result latestGridResult = + epmetUserFeignClient.getStaffLatestGrid(latestGridFormDTO); + if(latestGridResult.success() && null != latestGridResult.getData() && StringUtils.isNotBlank(latestGridResult.getData().getGridId())){ + return latestGridResult; + }else{ + Result staffGridResult = + govOrgFeignClient.getStaffGrid(latestGridFormDTO); + if(staffGridResult.success() && null != staffGridResult.getData() && StringUtils.isNotBlank(staffGridResult.getData().getGridId())){ + return staffGridResult; + } + } + return new Result().error(StaffAgencyConstant.QUERY_LATEST_GRID_INFO_FAILED); + } + + + @Override + public Result switchGrid(SwitchGridFormDTO switchGridFormDTO) { + //记录网格访问记录 + StaffGridVisitedFormDTO staffGridVisitedFormDTO = ConvertUtils.sourceToTarget(switchGridFormDTO, StaffGridVisitedFormDTO.class); + Result saveStaffGridVisitedRecord = epmetUserFeignClient.saveStaffGridVisitedRecord(staffGridVisitedFormDTO); + if (!saveStaffGridVisitedRecord.success()) { + logger.error("保存网格访问记录失败"); + } + /* //查询网格的权限 + Set opeKeys = accessService.listOpeKeysByStaffId(switchGridFormDTO.getStaffId(), null, switchGridFormDTO.getGridId()); + return new Result>().ok(opeKeys);*/ + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml b/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000..372d057000 --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/resources/bootstrap.yml @@ -0,0 +1,96 @@ +server: + port: @server.port@ + servlet: + context-path: /gov/mine + +spring: + main: + allow-bean-definition-overriding: true + application: + name: gov-mine-server + #环境 dev|test|prod + profiles: + active: dev + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + redis: + database: @spring.redis.index@ + host: @spring.redis.host@ + port: @spring.redis.port@ + password: @spring.redis.password@ + timeout: 30s + cloud: + nacos: + discovery: + server-addr: @nacos.server-addr@ + #nacos的命名空间ID,默认是public + namespace: @nacos.discovery.namespace@ + #不把自己注册到注册中心的地址 + register-enabled: @nacos.register-enabled@ + ip: @nacos.ip@ + config: + enabled: @nacos.config-enabled@ + server-addr: @nacos.server-addr@ + namespace: @nacos.config.namespace@ + group: @nacos.config.group@ + file-extension: yaml + #指定共享配置,且支持动态刷新 +# ext-config: +# - data-id: datasource.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true +# - data-id: common.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true +management: + endpoints: + web: + exposure: + include: "*" + endpoint: + health: + show-details: ALWAYS + +mybatis-plus: + mapper-locations: classpath:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.epmet.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: ID_WORKER + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: NOT_NULL + #驼峰下划线转换 + column-underline: true + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + +feign: + hystrix: + enabled: true + client: + config: + default: + loggerLevel: BASIC + httpclient: + enabled: true + +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds: 60000 #缺省为1000 + +ribbon: + ReadTimeout: 300000 + ConnectTimeout: 300000 diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/resources/logback-spring.xml b/epmet-module/gov-mine/gov-mine-server/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..e12ce1b94a --- /dev/null +++ b/epmet-module/gov-mine/gov-mine-server/src/main/resources/logback-spring.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + ${log.path}/error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-module/gov-mine/pom.xml b/epmet-module/gov-mine/pom.xml new file mode 100644 index 0000000000..2aa523997f --- /dev/null +++ b/epmet-module/gov-mine/pom.xml @@ -0,0 +1,20 @@ + + + + epmet-module + com.epmet + 2.0.0 + + 4.0.0 + pom + + gov-mine + + + gov-mine-client + gov-mine-server + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java index 9523753483..7b9abc9de6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java @@ -112,4 +112,19 @@ public class CustomerAgencyDTO implements Serializable { */ private Integer totalUser; + /** + * 省份 + */ + private String province; + + /** + * 城市 + */ + private String city; + + /** + * 区县 + */ + private String district; + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerDepartmentDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerDepartmentDTO.java index 0248ff77e2..3c97da56b3 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerDepartmentDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerDepartmentDTO.java @@ -17,9 +17,10 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -44,9 +45,9 @@ public class CustomerDepartmentDTO implements Serializable { private String customerId; /** - * 所属组织机构ID(customer_organization.id) + * 所属组织机构ID(customer_organization.id)AGENCY_ID */ - private String orgId; + private String agencyId; /** * 部门名称 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerIdDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerIdDTO.java new file mode 100644 index 0000000000..d18a182d1e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerIdDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 根据userId查询customerId 的DTO + * @Auther zxc + * @Create 2020-04-24 15:57 + */ +@Data +public class CustomerIdDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * userId 用户id + */ + private String userId; + + /** + * customerId 客户id + */ + private String customerId; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/GridStaffCountDTO.java new file mode 100644 index 0000000000..fcdbe3ed04 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java new file mode 100644 index 0000000000..263405df0c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto; + +import lombok.Data; + +/** + * @Auther zxc + * @Create 2020-04-23 10:38 + */ +@Data +public class StaffGridListDTO { + + private static final long serialVersionUID = 1L; + + /** + * 用户id + */ + private String staffId; + + /** + * 用户姓名 + */ + private String staffName; + + /** + * 用户头像 + */ + private String staffHeadPhoto; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 性别 + */ + private String gender; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/UserIdDTO.java new file mode 100644 index 0000000000..65ed41cab6 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java new file mode 100644 index 0000000000..7cb0a69b27 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java @@ -0,0 +1,78 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 添加组织-接口入参 + * + * @author sun + */ +@Data +public class AddAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 上级机关组织Id(当前机关组织添加下级组织) + */ + @NotBlank(message = "上级机关组织ID不能为空") + private String pid; + + /** + * 机构组织名称 + */ + @NotBlank(message = "组织名称不能为空") + private String agencyName; + + /** + * 机关级别(社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) + */ + private String level; + + /** + * 地区编码 + */ + private Integer areaCode; + + /** + * 国家 + */ + private String district; + + /** + * 省份 + */ + private String province; + + /** + * 城市 + */ + private String city; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java new file mode 100644 index 0000000000..57680d2ecd --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java @@ -0,0 +1,51 @@ +package com.epmet.dto.form; +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 添加部门-接口入参 + * + * @author sun + */ +@Data +public class AddDepartmentFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 所属组织机构ID(customer_agency.id) + */ + @NotBlank(message = "组织机构Id不能为空") + private String agencyId; + + /** + * 部门名称 + */ + private String departmentName; + + /** + * 部门职责 + */ + private String departmentDuty; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentStaffFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentStaffFormDTO.java new file mode 100644 index 0000000000..96503be98e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentStaffFormDTO.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; + +/** + * 添加部门人员DTO + * @Auther zxc + * @Create 2020-04-24 14:51 + */ +@Data +public class AddDepartmentStaffFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + *部门id + */ + @NotBlank(message = "部门id不能为空") + private String departmentId; + + /** + * 选中人员id + */ + @NotBlank(message = "选中人员不能为空") + private List selectedList; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java new file mode 100644 index 0000000000..95df5fca15 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyListFormDTO.java new file mode 100644 index 0000000000..1a05afb589 --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencydetailFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencydetailFormDTO.java new file mode 100644 index 0000000000..0f3b999026 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencydetailFormDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 组织首页-获取组织机构信息接口入参 + * + * @author sun + */ +@Data +public class AgencydetailFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "机关组织ID不能为空") + private String agencyId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DeleteGridFormDTO.java new file mode 100644 index 0000000000..ed266210ba --- /dev/null +++ b/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; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentInAgencyFormDTO.java new file mode 100644 index 0000000000..bb70330a2c --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentListFormDTO.java new file mode 100644 index 0000000000..a651dad1c3 --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentdetailFormDTO.java new file mode 100644 index 0000000000..8e01785bf2 --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java new file mode 100644 index 0000000000..e4a410120e --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java @@ -0,0 +1,48 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 组织名称编辑-接口入参 + * + * @author sun + */ +@Data +public class EditAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "机关组织ID不能为空") + private String agencyId; + + /** + * 机关组织名称 + */ + @NotBlank(message = "机关组织名称不能为空") + private String agencyName; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java new file mode 100644 index 0000000000..949ac45ace --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java new file mode 100644 index 0000000000..2c5556f7a3 --- /dev/null +++ b/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; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/LatestGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/LatestGridFormDTO.java new file mode 100644 index 0000000000..7642a7ae0b --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/LatestGridFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author: wangc + * @description: + * @date: Created in 2020-04-22 18:19 + */ +@Data +public class LatestGridFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 客户Id + * */ + @NotBlank(message = "客户Id不能为空") + private String customerId; + + /** + * 工作人员Id + * */ + @NotBlank(message = "工作人员Id不能为空") + private String staffId; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java new file mode 100644 index 0000000000..5caaec7ea5 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java @@ -0,0 +1,42 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 删除组织机关-接口入参 + * + * @author sun + */ +@Data +public class RemoveAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "机关组织ID不能为空") + private String agencyId; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveDepartmentFormDTO.java new file mode 100644 index 0000000000..749a157deb --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffInfoFromDTO.java new file mode 100644 index 0000000000..503164633d --- /dev/null +++ b/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; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffOrgFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffOrgFormDTO.java new file mode 100644 index 0000000000..a506bc28c1 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffOrgFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 根据客户id查询组织结构信息入参 + * @Author yinzuomei + * @Date 2020/4/20 21:42 + */ +@Data +public class StaffOrgFormDTO implements Serializable { + private static final long serialVersionUID = 2514896455028592288L; + + /** + * 用户绑定的客户列表 + * */ + private List customerIdList; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffSubmitFromDTO.java new file mode 100644 index 0000000000..87ffa6f26b --- /dev/null +++ b/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 roles; + /** + * 来源app(政府端:gov、居民端:resi、运营端:oper) + */ + private String app; + /** + * 来源client(PC端:web、微信小程序:wxmp) + */ + private String client; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffsInAgencyFromDTO.java new file mode 100644 index 0000000000..6eb0ee85ad --- /dev/null +++ b/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 staffList; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/SubAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/SubAgencyFormDTO.java new file mode 100644 index 0000000000..6cdf21a193 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/SubAgencyFormDTO.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 组织首页-下级机关列表-接口入参 + * + * @author sun + */ +@Data +public class SubAgencyFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + @NotBlank(message = "机关组织ID不能为空") + private String agencyId; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java new file mode 100644 index 0000000000..01f072752a --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 添加组织-接口返参 + * + * @author sun + */ +@Data +public class AddAgencyResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + private String agencyId; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddDepartmentResultDTO.java new file mode 100644 index 0000000000..b6206d0c6d --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddGridResultDTO.java new file mode 100644 index 0000000000..eedf5c895a --- /dev/null +++ b/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; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyListResultDTO.java new file mode 100644 index 0000000000..9673700fcc --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java new file mode 100644 index 0000000000..e372d86d8d --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java @@ -0,0 +1,79 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +/** + * 添加组织-接口返参 + * + * @author sun + */ +@Data +public class AgencysResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + private String agencyId; + + /** + * 组织名称 + */ + private String agencyName; + + /** + * 机关级别(社区级:community, + * 乡(镇、街道)级:street, + * 区县级: district, + * 市级: city + * 省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) + */ + private String level; + + /** + * 地区编码 + */ + private Integer areaCode; + + /** + * 国家 + */ + private String country; + + /** + * 省份 + */ + private String province; + + /** + * 城市 + */ + private String city; + + /** + * 本机关的所有上级机关 + */ + private List parentList; +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridByUserIdResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridByUserIdResultDTO.java new file mode 100644 index 0000000000..b0b04da974 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridByUserIdResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 根据userId查询该用户涉及的所有网格返回结果 + * @ClassName CustomerGridByUserIdResultDTO + * @Author sun + */ +@Data +public class CustomerGridByUserIdResultDTO implements Serializable { + private static final long serialVersionUID = -1L; + + /** + * 网格直属组织ID + */ + private String agencyId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 网格名称 + */ + private String gridName; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartInStaffListResultDTO.java new file mode 100644 index 0000000000..e63020a209 --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java new file mode 100644 index 0000000000..d36a4222ee --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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 staffList; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentInAgencyResultDTO.java new file mode 100644 index 0000000000..33880e5c1b --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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 departmentList; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentListResultDTO.java new file mode 100644 index 0000000000..7fafa0238d --- /dev/null +++ b/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 + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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; +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java new file mode 100644 index 0000000000..f822ea7773 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridDetailResultDTO.java @@ -0,0 +1,68 @@ +package com.epmet.dto.result; + +import com.epmet.dto.StaffGridListDTO; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Auther zxc + * @Create 2020-04-23 10:28 + */ +@Data +public class GridDetailResultDTO implements Serializable { + + private static final long serialVersionUID = -1L; + + /** + * 网格id + */ + private String grid; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 中心位置经度 + */ + private String longitude; + + /** + * 中心位置维度 + */ + private String latitude; + + /** + * 所属地区码(所属组织地区码) + */ + private String areaCode; + + /** + * 管辖区域 + */ + private String manageDistrict; + + /** + * 当前网格总人数 + */ + private Integer totalUser; + + /** + * 所属组织机构ID(customer_agencys.id) + */ + private String agencyId; + + /** + * 所有上级组织ID + */ + private String pIds; + + /** + * 网格用户信息集合 + */ + private List staffGridList; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/LatestCustomerResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/LatestCustomerResultDTO.java new file mode 100644 index 0000000000..8a5249c6ae --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/LatestCustomerResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/22 9:59 + */ +@Data +public class LatestCustomerResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + /** + * 客户名称 + */ + private String customerName; + /** + * 用户所属组织id(任意一条) + */ + private String agencyId; + /** + * 工作人员头像 + */ + private String staffHeadPhoto; + /** + * 性别0未知1男2女 + */ + private Integer gender; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java new file mode 100644 index 0000000000..73608b1943 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 组织首页-获取组织机构信息接口-本机关的所有上级机关信息 + * + * @author sun + */ +@Data +public class ParentListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + private String id; + /** + * 机关组织名称 + */ + private String name; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffDetailResultDTO.java new file mode 100644 index 0000000000..c6cf9ea90e --- /dev/null +++ b/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 roles; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInfoResultDTO.java new file mode 100644 index 0000000000..2859c1171a --- /dev/null +++ b/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; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffInitResultDTO.java new file mode 100644 index 0000000000..393dd91771 --- /dev/null +++ b/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 roleList; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffOrgsResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffOrgsResultDTO.java new file mode 100644 index 0000000000..e929739841 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffOrgsResultDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 政府端工作人员获取我的组织 + * @Author yinzuomei + * @Date 2020/4/20 18:45 + */ +@Data +public class StaffOrgsResultDTO implements Serializable { + private static final long serialVersionUID = -9148184731135509803L; + + /** + * 根级根级组织id + */ + private String rootAgencyId; + + /** + * 根级组织名称 + */ + private String rootAgencyName; + + /** + * 客户id + */ + private String customerId; + + /** + * 客户名称 + */ + private String customerName; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffRoleResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffRoleResultDTO.java new file mode 100644 index 0000000000..eea1e50dbe --- /dev/null +++ b/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; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffsInAgencyResultDTO.java new file mode 100644 index 0000000000..4c9352466b --- /dev/null +++ b/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 staffList; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubAgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubAgencyResultDTO.java new file mode 100644 index 0000000000..ea9810c94c --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubAgencyResultDTO.java @@ -0,0 +1,48 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + + +/** + * 组织首页-下级机关列表-接口返参 + * + * @author sun + */ +@Data +public class SubAgencyResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 下级机关总数 + */ + private Integer subAgencyCount; + + /** + * 下级机关总数 + */ + private List agencyList; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubListResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubListResultDTO.java new file mode 100644 index 0000000000..57ab12c3df --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubListResultDTO.java @@ -0,0 +1,45 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 组织首页-下级机关列表-查询本机关的直属下一级机关 + * + * @author sun + */ +@Data +public class SubListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 机关组织Id + */ + private String agencyId; + /** + * 机关组织名称 + */ + private String agencyName; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index deb18a6168..a9bd2b6ba3 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -58,12 +58,19 @@ com.epmet - gov-org-client + resi-partymember-client 2.0.0 + compile com.epmet - resi-partymember-client + oper-crm-client + 2.0.0 + compile + + + com.epmet + epmet-user-client 2.0.0 compile diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java new file mode 100644 index 0000000000..3c28f465f9 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java @@ -0,0 +1,21 @@ +package com.epmet.constant; + +/** + * @author sun + * @dscription + */ +public interface CustomerAgencyConstant { + + /** + * 组织名称编辑修改失败 + */ + String UPDATE_EXCEPTION = "组织机构信息更新失败"; + /** + * 添加组织失败 + */ + String SAVE_EXCEPTION = "组织机构新增失败"; + /** + * 组织删除失败 + */ + String DEL_EXCEPTION = "组织删除失败"; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerDepartmentConstant.java new file mode 100644 index 0000000000..2a530cba0b --- /dev/null +++ b/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 = "查询部门人员角色失败"; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java new file mode 100644 index 0000000000..2ddc8f3c98 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java @@ -0,0 +1,132 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.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.CustomerAgencyDTO; +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.entity.CustomerAgencyEntity; +import com.epmet.service.AgencyService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +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 addAgency(@LoginUser TokenDto tokenDTO, @RequestBody AddAgencyFormDTO formDTO) { + return agencyService.addAgency(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织名称编辑 + */ + @PostMapping("editagency") + public Result editAgency(@LoginUser TokenDto tokenDTO, @RequestBody EditAgencyFormDTO formDTO) { + return agencyService.editAgency(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除组织机关 + */ + @PostMapping("removeagency") + public Result removeAgency(@LoginUser TokenDto tokenDTO, @RequestBody RemoveAgencyFormDTO formDTO) { + return agencyService.removeAgency(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取组织机构信息 + */ + @PostMapping("agencydetail") + public Result agencyDetail(@LoginUser TokenDto tokenDTO, @RequestBody AgencydetailFormDTO formDTO) { + return agencyService.agencyDetail(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + @PostMapping("subagencylist") + public Result subAgencyList(@LoginUser TokenDto tokenDTO, @RequestBody SubAgencyFormDTO formDTO) { + return agencyService.subAgencyList(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取组织列表 + */ + @PostMapping("agencylist") + public Result> agencyList(@LoginUser TokenDto tokenDTO, @RequestBody AgencyListFormDTO formDTO) { + return agencyService.agencyList(formDTO); + } + + /** + * 根据Id查询agency + * @param agencyId + * @return + */ + @PostMapping("{agencyId}") + public Result getAgencyById(@PathVariable("agencyId") String agencyId) { + CustomerAgencyEntity agency = agencyService.getAgencyById(agencyId); + CustomerAgencyDTO customerAgencyDTO = new CustomerAgencyDTO(); + if (agency != null) { + BeanUtils.copyProperties(agency, customerAgencyDTO); + return new Result().ok(customerAgencyDTO); + } + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 550cdb1832..9de0e27f8e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -23,9 +23,11 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; 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.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.StaffOrgFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.excel.CustomerAgencyExcel; import com.epmet.service.CustomerAgencyService; import org.springframework.beans.factory.annotation.Autowired; @@ -45,24 +47,24 @@ import java.util.Map; @RestController @RequestMapping("customeragency") public class CustomerAgencyController { - + @Autowired private CustomerAgencyService customerAgencyService; @GetMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = customerAgencyService.page(params); return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ + public Result get(@PathVariable("id") String id) { CustomerAgencyDTO data = customerAgencyService.get(id); return new Result().ok(data); } @PostMapping - public Result save(@RequestBody CustomerAgencyDTO dto){ + public Result save(@RequestBody CustomerAgencyDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); customerAgencyService.save(dto); @@ -70,7 +72,7 @@ public class CustomerAgencyController { } @PutMapping - public Result update(@RequestBody CustomerAgencyDTO dto){ + public Result update(@RequestBody CustomerAgencyDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); customerAgencyService.update(dto); @@ -78,7 +80,7 @@ public class CustomerAgencyController { } @DeleteMapping - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); customerAgencyService.delete(ids); @@ -91,4 +93,15 @@ public class CustomerAgencyController { ExcelUtils.exportExcelToTarget(response, null, list, CustomerAgencyExcel.class); } + /** + * @param staffOrgsFormDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 登录-获取工作人员所有组织 + * @Date 2020/4/20 21:59 + **/ + @PostMapping("getStaffOrgList") + public Result> getStaffOrgList(@RequestBody StaffOrgFormDTO staffOrgsFormDTO) { + return customerAgencyService.getStaffOrgList(staffOrgsFormDTO); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java index ed7db2c1c7..6daed0e8a4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java @@ -23,12 +23,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; 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.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; -import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.excel.CustomerGridExcel; import com.epmet.service.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -124,4 +125,15 @@ public class CustomerGridController { CustomerGridDTO data = customerGridService.get(id); return new Result().ok(data); } + + /** + * @param userId + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + @GetMapping("getmygrids/{userId}") + public Result> getMyGrids(@PathVariable("userId") String userId) { + return customerGridService.getMyGrids(userId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java index 58219da027..3bfc887aec 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffAgencyController.java @@ -26,6 +26,9 @@ 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.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; @@ -91,4 +94,19 @@ public class CustomerStaffAgencyController { ExcelUtils.exportExcelToTarget(response, null, list, CustomerStaffAgencyExcel.class); } + /** + * 获取最近一次登录的客户信息 + * + * @param userId 参数 + * @return Result + * @author zhaoqifeng + */ + @GetMapping("getlatestcustomer/{userId}") + public Result getLatestCustomer(@PathVariable("userId") String userId) { + return customerStaffAgencyService.getLatestCustomer(userId); + } + + + + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffGridController.java index b5e68ade89..de20bc5b13 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerStaffGridController.java @@ -26,6 +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.CustomerStaffGridDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.excel.CustomerStaffGridExcel; import com.epmet.service.CustomerStaffGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -37,7 +39,7 @@ import java.util.Map; /** - * 网格人员关系表 + * 网格人员关系表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-04-20 @@ -45,7 +47,7 @@ import java.util.Map; @RestController @RequestMapping("customerstaffgrid") public class CustomerStaffGridController { - + @Autowired private CustomerStaffGridService customerStaffGridService; @@ -91,4 +93,16 @@ public class CustomerStaffGridController { ExcelUtils.exportExcelToTarget(response, null, list, CustomerStaffGridExcel.class); } + /** + * @Description 查询指定客户下一个用户所在的网格,调用gov-org + * @Param LatestGridFormDTO -> customerId ; staffId + * @return Result + * @Author wangc + * @Date 2020.04.23 10:53 + **/ + @PostMapping("getstaffgrid") + public Result getStaffGrid(@RequestBody LatestGridFormDTO latestGridFormDTO){ + ValidatorUtils.validateEntity(latestGridFormDTO); + return customerStaffGridService.getStaffGridOrderByGridName(latestGridFormDTO); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java new file mode 100644 index 0000000000..4d627ebaac --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -0,0 +1,108 @@ +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; + + /** + * 添加部门人员 + * @param tokenDto + * @param addDepartmentStaffFormDTO + * @return + */ + @PostMapping(value = "adddepartmentstaff") + public Result addDepartmentStaff(@LoginUser TokenDto tokenDto, @RequestBody AddDepartmentStaffFormDTO addDepartmentStaffFormDTO){ + return departmentService.addDepartmentStaff(tokenDto,addDepartmentStaffFormDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加部门 + */ + @PostMapping("adddepartment") + public Result addDepartment(@LoginUser TokenDto tokenDTO, @RequestBody AddDepartmentFormDTO formDTO) { + return departmentService.addDepartment(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 部门信息修改 + */ + @PostMapping("editdepartment") + public Result editDepartment(@LoginUser TokenDto tokenDTO, @RequestBody EditDepartmentFormDTO formDTO) { + return departmentService.editDepartment(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 删除部门 + */ + @PostMapping("removedepartment") + public Result removeDepartment(@LoginUser TokenDto tokenDTO, @RequestBody RemoveDepartmentFormDTO formDTO) { + return departmentService.removeDepartment(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取部门详情 + */ + @PostMapping("departmentdetail") + public Result departmentDetail(@LoginUser TokenDto tokenDTO, @RequestBody DepartmentdetailFormDTO formDTO) { + return departmentService.departmentDetail(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取机关下部门列表 + */ + @PostMapping("departmentinagencylist") + public Result departmentInAgencyList(@LoginUser TokenDto tokenDTO, @RequestBody DepartmentInAgencyFormDTO formDTO) { + return departmentService.departmentInAgencyList(formDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取机构下部门列表 + */ + @PostMapping("departmentlist") + public Result> departmentList(@LoginUser TokenDto tokenDTO, @RequestBody DepartmentListFormDTO formDTO) { + return departmentService.departmentList(formDTO); + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java new file mode 100644 index 0000000000..f3b19c5027 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -0,0 +1,67 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AddGridFormDTO; +import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.DeleteGridFormDTO; +import com.epmet.dto.form.EditGridFormDTO; +import com.epmet.dto.result.AddGridResultDTO; +import com.epmet.dto.result.GridDetailResultDTO; +import com.epmet.service.CustomerGridService; +import org.springframework.beans.factory.annotation.Autowired; +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; + +/** + * @Auther zxc + * @Create 2020-04-23 9:50 + */ +@RestController +@RequestMapping("grid") +public class GridController { + + @Autowired + private CustomerGridService customerGridService; + + /** + * 获取网格详情 + * @param customerGridFormDTO + * @return + */ + @PostMapping("griddetail") + public Result gridDetail(@LoginUser TokenDto tokenDto,@RequestBody CustomerGridFormDTO customerGridFormDTO){ + Result griddetail = customerGridService.griddetail(customerGridFormDTO); + return griddetail; + } + + /** + * 新建当前机关下的所属网格 + */ + @PostMapping("addgrid") + public Result 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") + public Result deleteGrid(@LoginUser TokenDto tokenDto, @RequestBody DeleteGridFormDTO deleteGridFormDTO){ + return customerGridService.deleteGrid(tokenDto,deleteGridFormDTO); + } + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffController.java new file mode 100644 index 0000000000..6964cffec3 --- /dev/null +++ b/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 getStaffInfoForHome(@RequestBody StaffsInAgencyFromDTO fromDTO) { + return staffService.getStaffInfoForHome(fromDTO); + } + + /** + * 查看人员列表 + * + * @param fromDTO 参数 + * @return Result + * @author zhaoqifeng + */ + @PostMapping("stafflist") + public Result> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO){ + return staffService.getStaffList(fromDTO); + } + + + /** + * 人员添加页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("rolelist") + public Result addStaffInit(@RequestBody StaffInfoFromDTO fromDTO){ + return staffService.addStaffInit(fromDTO); + } + + /** + * 人员编辑页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("editstaffinit") + public Result 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 + */ + @PostMapping("staffdetail") + public Result getStaffDetail(@RequestBody StaffInfoFromDTO fromDTO){ + return staffService.getStaffDetail(fromDTO); + } + + /** + * 人员禁用 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("disabledstaff") + public Result disabledStaff(@RequestBody StaffInfoFromDTO fromDTO){ + return staffService.disabledStaff(fromDTO); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 185d2d33a1..8a4c14548b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -18,8 +18,15 @@ 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; import com.epmet.entity.CustomerAgencyEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 机关单位信息表 @@ -29,5 +36,36 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerAgencyDao extends BaseDao { - + /** + * @param customerIdList + * @return java.util.List + * @Author yinzuomei + * @Description 查询客户对应的根级组织 + * @Date 2020/4/20 21:48 + **/ + List selectStaffOrgList(@Param("customerIdList") List customerIdList); + + /** + * @param listStr + * @return + * @Author sun + * @Description 查询当前机关的所有上级组织信息 + **/ + List selectPAgencyById(@Param("listStr") List listStr); + + /** + * @param pId + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + **/ + List selectSubAgencyById(@Param("pId") String pId); + + /** + * @param pId + * @return + * @Author sun + * @Description 获取组织列表 + **/ + List selectAgencyList(@Param("pId") String pId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java index bd188f8351..b7569a1396 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java @@ -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 { - + + /** + * @param agencyId + * @return + * @Author sun + * @Description 根据当前机关Id查询该机关下的直属部门列表,只查询前十条 + **/ + List selectDepartmentListByAgencyId(@Param("agencyId") String agencyId); + /** + * @param agencyId + * @return + * @Author sun + * @Description 根据当前机关Id查询该机关下的直属部门列表 + **/ + List selectDepartmentList(@Param("agencyId") String agencyId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index a0b7899e9c..d15a7c7032 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -18,10 +18,16 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.form.ListCustomerGridFormDTO; -import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.CustomerStaffGridDTO; import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.DeleteGridFormDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.AddGridResultDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.entity.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -61,4 +67,61 @@ public interface CustomerGridDao extends BaseDao { List selectRestGridWithoutGivenAreaCode(Map paramsMap); CustomerGridDTO getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO); + + /** + * @param userId + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + List getMyGrids(String userId); + + /** + * 根据gridId获取网格详情 + * @param customerGridFormDTO + * @return + */ + GridDetailResultDTO griddetail(CustomerGridFormDTO customerGridFormDTO); + + /** + * 根据gridId查询uerId + * @param customerGridFormDTO + * @return + */ + List 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); + + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java index 8ac905edcb..533c97b2a5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffAgencyDao.java @@ -18,9 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.entity.CustomerStaffAgencyEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 人员-机关单位关系表 * @@ -29,5 +32,19 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerStaffAgencyDao extends BaseDao { + + /** + * 获取最近一次登录的客户信息 + * @param userId + * @return + */ + CustomerStaffAgencyDTO selectLatestCustomerByStaff(String userId); + + /** + * 获取机关下的工作人员 + * @param agencyId + * @return + */ + List selectCustomerStaffAgencyList(String agencyId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java index 8a79a0dd2e..2f103d1daf 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffDepartmentDao.java +++ b/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,20 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerStaffDepartmentDao extends BaseDao { - + + /** + * + * @param departmentId + * @return + * * @Author sun + * @Description 查询部门下工作人员的用户Id集合 + */ + List selectUserIdByDepartmentId(@Param("departmentId") String departmentId); + + /** + * 修改部门人数 + * @param + * @auther zxc + */ + void updateDepartmentStaffCount(@Param("addCount")Integer addCount,@Param("departmentId")String departmentId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java index 01dc0c2721..dc61c9039f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java @@ -18,6 +18,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.form.LatestGridFormDTO; import com.epmet.entity.CustomerStaffGridEntity; import org.apache.ibatis.annotations.Mapper; @@ -29,5 +31,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerStaffGridDao extends BaseDao { - + + /** + * @Description 查询指定客户下一个用户所在的网格,按照网格名称升序排序,取第一个 + * @Param LatestGridFormDTO -> customerId ; userId + * @return CustomerGridDTO + * @Author wangc + * @Date 2020.04.23 01:09 + **/ + CustomerGridDTO selectStaffGridOrderByGridName(LatestGridFormDTO latestGridFormDTO); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java index b06e833347..5549845d66 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java @@ -82,4 +82,19 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { */ private Integer totalUser; + /** + * 省份 + */ + private String province; + + /** + * 城市 + */ + private String city; + + /** + * 区县 + */ + private String district; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java index b34f814bc1..ba9b1ddcd5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java @@ -18,13 +18,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 客户部门表 * @@ -44,9 +41,9 @@ public class CustomerDepartmentEntity extends BaseEpmetEntity { private String customerId; /** - * 所属组织机构ID(customer_organization.id) + * 所属组织机构ID(customer_agency.id) */ - private String orgId; + private String agencyId; /** * 部门名称 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java index 27422f3157..346963be94 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/CustomerAgencyExcel.java @@ -76,5 +76,12 @@ public class CustomerAgencyExcel { @Excel(name = "总人数") private Integer totalUser; + @Excel(name = "省份") + private String province; + @Excel(name = "城市") + private String city; + + @Excel(name = "区县") + private String district; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java new file mode 100644 index 0000000000..8eb86517de --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -0,0 +1,145 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.AddDepartmentStaffFormDTO; +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.feign.fallback.EpmetUserFeignClientFallBack; +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 + * @date 2020/3/19 9:32 + */ +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallBack.class) +public interface EpmetUserFeignClient { + /** + * 根据用户ID获取工作人员基本信息 + * + * @param formDTO + * @return Result + * @author zhaoqifeng + * @date 2020/4/22 10:05 + **/ + @PostMapping(value = "/epmetuser/customerstaff/getstaffinfobyuserid") + Result getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO); + + /** + * 获取网格下人员具体信息(头像、名字...) + * @param customerStaffGridDTOS + * @return + */ + @PostMapping("/epmetuser/customerstaff/selectstaffgridlistbyuserid") + Result> getStaffGridList(@RequestBody List customerStaffGridDTOS); + + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("/epmetuser/customerstaff/staffsinagency") + Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + + /** + * 获取网格下未禁用的人员数量 + * @param userIdDTO + * @return + */ + @PostMapping(value = "/epmetuser/customerstaff/selectgridstaffcountbyuserid") + Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO); + + /** + * 工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("/epmetuser/customerstaff/stafflist") + Result> getStaffList(@RequestBody StaffsInAgencyFromDTO fromDTO); + /** + * 人员添加页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/rolelist") + Result addStaffInit(@RequestBody StaffInfoFromDTO fromDTO); + + /** + * 人员编辑页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + @PostMapping("/epmetuser/customerstaff/editstaffinit") + Result 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 + */ + @PostMapping("/epmetuser/customerstaff/staffdetail") + Result 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> getDepartmentStaffList(DepartmentInStaffFormDTO departmentInStaffFormDTO); + + /** + * 根据userId查询customerId + * @param addDepartmentStaffFormDTO + * @auther zxc + */ + @PostMapping("/epmetuser/customerstaff/selectcustomeridbyuserid") + Result> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO); + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java new file mode 100644 index 0000000000..fe0bf224ab --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java @@ -0,0 +1,38 @@ +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 + * @date 2020/4/22 10:41 + */ +@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmFeignClientFallBack.class) +public interface OperCrmFeignClient { + /** + * 获取客户信息 + * @param dto + * @return + */ + @PostMapping("/oper/crm/customer/getcostomerInfo") + Result getCustomerInfo(@RequestBody CustomerDTO dto); + + /** + * @param customerFormDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:07 + **/ + @PostMapping("/oper/crm/customer/queryCustomerList") + Result> queryCustomerList(CustomerFormDTO customerFormDTO); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java new file mode 100644 index 0000000000..1284fb622b --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -0,0 +1,94 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.AddDepartmentStaffFormDTO; +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.feign.EpmetUserFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Auther zxc + * @Create 2020-04-23 14:10 + */ +@Component +public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { + @Override + public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByUserId", formDTO); + } + @Override + public Result> getStaffGridList(List customerStaffGridDTOS) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffGridList", customerStaffGridDTOS); + } + + @Override + public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffInfoForHome", fromDTO); + } + + @Override + public Result selectGridStaffCountByUserId(UserIdDTO userIdDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectGridStaffCountByUserId", userIdDTO); + } + + @Override + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO departmentInStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getDepartmentStaffList", departmentInStaffFormDTO); + } + + + @Override + public Result> getStaffList(StaffsInAgencyFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "StaffsInAgencyFromDTO", fromDTO); + } + + @Override + public Result addStaffInit(StaffInfoFromDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "addStaffInit", fromDTO); + } + + @Override + public Result 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 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> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectCustomerIdByUserId", addDepartmentStaffFormDTO); + } + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java new file mode 100644 index 0000000000..9f405caca4 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java @@ -0,0 +1,29 @@ +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.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; +import com.epmet.feign.OperCrmFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/22 10:43 + */ +@Component +public class OperCrmFeignClientFallBack implements OperCrmFeignClient { + @Override + public Result getCustomerInfo(CustomerDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto); + } + + @Override + public Result> queryCustomerList(CustomerFormDTO customerFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "queryCustomerList", customerFormDTO); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java new file mode 100644 index 0000000000..d09e56ba05 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import 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.entity.CustomerAgencyEntity; + +import java.util.List; + +/** + * 机关单位信息 + * + * @author generator generator@elink-cn.com + */ +public interface AgencyService { + + /** + * @param formDTO + * @return + * @Author sun + * @Description 添加组织 + */ + Result 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 agencyDetail(AgencydetailFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + Result subAgencyList(SubAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取组织列表 + */ + Result> agencyList(AgencyListFormDTO formDTO); + + /** + * 根据Id查询 + * @param agencyId + * @return + */ + CustomerAgencyEntity getAgencyById(String agencyId); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 319e26890f..62892b4576 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -19,7 +19,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.StaffOrgFormDTO; +import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.entity.CustomerAgencyEntity; import java.util.List; @@ -92,4 +95,13 @@ public interface CustomerAgencyService extends BaseService * @date 2020-04-20 */ void delete(String[] ids); + + /** + * @param staffOrgsFormDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 根据客户id查询组织名称 + * @Date 2020/4/20 21:45 + **/ + Result> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index 3da56bc4d2..41390fe5e5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -18,13 +18,18 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AddGridResultDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.entity.CustomerGridEntity; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.Map; @@ -113,4 +118,39 @@ public interface CustomerGridService extends BaseService { * @date 2020-03-17 */ Result getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO); + + /** + * @param userId + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + Result> getMyGrids(String userId); + + /** + * 根据gridId获取网格详情 + * @param customerGridFormDTO + * @return + */ + Result griddetail(CustomerGridFormDTO customerGridFormDTO); + + /** + * 新建当前机关下的所属网格 + */ + Result 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); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java index 9ba776f271..c713dbde52 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffAgencyService.java @@ -19,7 +19,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffAgencyDTO; +import com.epmet.dto.form.StaffsInAgencyFromDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; import com.epmet.entity.CustomerStaffAgencyEntity; import java.util.List; @@ -33,63 +36,80 @@ import java.util.Map; */ public interface CustomerStaffAgencyService extends BaseService { - /** - * 默认分页 - * - * @param params - * @return PageData - * @author generator - * @date 2020-04-20 - */ - PageData page(Map params); + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-20 + */ + PageData page(Map params); - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2020-04-20 - */ - List list(Map params); + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-20 + */ + List list(Map params); - /** - * 单条查询 - * - * @param id - * @return CustomerStaffAgencyDTO - * @author generator - * @date 2020-04-20 - */ - CustomerStaffAgencyDTO get(String id); + /** + * 单条查询 + * + * @param id + * @return CustomerStaffAgencyDTO + * @author generator + * @date 2020-04-20 + */ + CustomerStaffAgencyDTO get(String id); - /** - * 默认保存 - * - * @param dto - * @return void - * @author generator - * @date 2020-04-20 - */ - void save(CustomerStaffAgencyDTO dto); + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-20 + */ + void save(CustomerStaffAgencyDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-20 + */ + void update(CustomerStaffAgencyDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-20 + */ + void delete(String[] ids); + + /** + * 获取最近一次登录的客户信息 + * + * @param userId + * @return + */ + Result getLatestCustomer(String userId); + + /** + * 获取组织下关联人员 + * @param fromDTO + * @return + */ + Result> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO); - /** - * 默认更新 - * - * @param dto - * @return void - * @author generator - * @date 2020-04-20 - */ - void update(CustomerStaffAgencyDTO dto); - /** - * 批量删除 - * - * @param ids - * @return void - * @author generator - * @date 2020-04-20 - */ - void delete(String[] ids); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java index 712a45deff..1bc16f7299 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerStaffGridService.java @@ -19,7 +19,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.entity.CustomerStaffGridEntity; import java.util.List; @@ -93,4 +96,13 @@ public interface CustomerStaffGridService extends BaseService customerId ; staffId + * @return CustomerGridDTO + * @Author wangc + * @Date 2020.04.23 09:11 + **/ + Result getStaffGridOrderByGridName(LatestGridFormDTO latestGridFormDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java new file mode 100644 index 0000000000..2d49860de2 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/DepartmentService.java @@ -0,0 +1,89 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerIdDTO; +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 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 departmentDetail(DepartmentdetailFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取机关下部门列表 + */ + Result departmentInAgencyList(DepartmentInAgencyFormDTO formDTO); + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取机构下部门列表 + */ + Result> departmentList(DepartmentListFormDTO formDTO); + + /** + * 添加部门人员 + * @param addDepartmentStaffFormDTO + * @return + */ + Result addDepartmentStaff(TokenDto tokenDto,AddDepartmentStaffFormDTO addDepartmentStaffFormDTO); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java new file mode 100644 index 0000000000..e11e8edecb --- /dev/null +++ b/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 + * @author zhaoqifeng + */ + Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + + /** + * 查看人员列表 + * + * @param fromDTO 参数 + * @return Result + * @author zhaoqifeng + */ + Result> getStaffList(StaffsInAgencyFromDTO fromDTO); + + /** + * 人员添加页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + Result addStaffInit(StaffInfoFromDTO fromDTO); + + /** + * 人员编辑页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + Result 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 + */ + Result getStaffDetail(StaffInfoFromDTO fromDTO); + + /** + * 人员禁用 + * + * @param fromDTO 参数 + * @return Result + */ + Result disabledStaff(StaffInfoFromDTO fromDTO); + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java new file mode 100644 index 0000000000..7177d64d7e --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -0,0 +1,192 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.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 addAgency(AddAgencyFormDTO formDTO) { + Result result = new Result(); + 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 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 agencyDetail(AgencydetailFormDTO formDTO) { + AgencysResultDTO agencysResultDTO = new AgencysResultDTO(); + //1:查询本机关详细信息 + CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId()); + if (null == entity) { + return new Result().ok(agencysResultDTO); + } + agencysResultDTO = ConvertUtils.sourceToTarget(entity, AgencysResultDTO.class); + agencysResultDTO.setAgencyId(entity.getId()); + agencysResultDTO.setAgencyName(entity.getOrganizationName()); + //2:查询本机关的所有上级机关,按自上而下层级顺序 + if (null == entity.getPids()) { + return new Result().ok(agencysResultDTO); + } + List listStr = Arrays.asList(entity.getPids().split(":")); + List parentList = customerAgencyDao.selectPAgencyById(listStr); + agencysResultDTO.setParentList(parentList); + return new Result().ok(agencysResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-下级机关列表 + */ + @Override + public Result subAgencyList(SubAgencyFormDTO formDTO) { + SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO(); + //1:根据当前机关Id查询直属下一级机关列表 + List agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId()); + subAgencyResultDTO.setAgencyList(agencyList); + //2:统计下一级机关数 + subAgencyResultDTO.setSubAgencyCount(agencyList.size()); + return new Result().ok(subAgencyResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取组织列表 + */ + @Override + public Result> agencyList(AgencyListFormDTO formDTO) { + List agencyList = customerAgencyDao.selectAgencyList(formDTO.getAgencyId()); + return new Result>().ok(agencyList); + } + + @Override + public CustomerAgencyEntity getAgencyById(String agencyId) { + return customerAgencyDao.selectById(agencyId); + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index fa513326e4..06f83a0d25 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -20,15 +20,26 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +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.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.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; +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; @@ -46,9 +57,11 @@ import java.util.Map; @Service public class CustomerAgencyServiceImpl extends BaseServiceImpl implements CustomerAgencyService { + private static final Logger logger = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class); @Autowired private CustomerAgencyRedis customerAgencyRedis; - + @Autowired + private OperCrmFeignClient operCrmFeignClient; @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -65,8 +78,8 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -101,4 +114,28 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO) { + if (null == staffOrgsFormDTO || staffOrgsFormDTO.getCustomerIdList().size() == 0) { + return new Result<>(); + } + List list = baseDao.selectStaffOrgList(staffOrgsFormDTO.getCustomerIdList()); + CustomerFormDTO customerFormDTO = new CustomerFormDTO(); + customerFormDTO.setCustomerIdList(staffOrgsFormDTO.getCustomerIdList()); + Result> customerDTOResult = operCrmFeignClient.queryCustomerList(customerFormDTO); + List 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 { + logger.error("获取客户名称失败"); + } + return new Result>().ok(list); + } } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index ea8bc48c65..075799dfb8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -20,17 +20,23 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.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.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerGridDao; -import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.form.CustomerGridFormDTO; -import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.*; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AddGridResultDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.entity.CustomerGridEntity; - +import com.epmet.feign.EpmetUserFeignClient; import com.epmet.redis.CustomerGridRedis; import com.epmet.service.CustomerGridService; import com.epmet.util.ModuleConstant; @@ -39,10 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 客户网格表 @@ -55,6 +58,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl page(Map params) { @@ -150,6 +155,84 @@ public class CustomerGridServiceImpl extends BaseServiceImpl getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO) { return new Result().ok(baseDao.getCustomerGridByGridId(customerGridFormDTO)); -} + } + + /** + * @param userId + * @return + * @Description 根据userId查询该用户涉及的所有网格列表 + * @Author sun + */ + @Override + public Result> getMyGrids(String userId) { + return new Result>().ok(baseDao.getMyGrids(userId)); + } + + /** + * 查询网格详情 + * @param customerGridFormDTO + * @return + */ + @Override + public Result griddetail(CustomerGridFormDTO customerGridFormDTO) { + GridDetailResultDTO griddetail = baseDao.griddetail(customerGridFormDTO); + List customerStaffGridDTOS = baseDao.selectUserIdByGridId(customerGridFormDTO); + //获取人员具体信息(头像、名字...) + Result> staffGridList = epmetUserFeignClient.getStaffGridList(customerStaffGridDTOS); + griddetail.setStaffGridList(staffGridList.getData()); + return new Result().ok(griddetail); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result 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().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 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(); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java index f1786860da..77292f2710 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java @@ -23,10 +23,21 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.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.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; @@ -36,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 人员-机关单位关系表 @@ -48,6 +60,12 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl page(Map params) { @@ -101,4 +119,33 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl getLatestCustomer(String userId) { + LatestCustomerResultDTO resultDTO = new LatestCustomerResultDTO(); + CustomerStaffAgencyDTO customerStaffAgencyDTO = baseDao.selectLatestCustomerByStaff(userId); + + resultDTO.setAgencyId(customerStaffAgencyDTO.getAgencyId()); + resultDTO.setCustomerId(customerStaffAgencyDTO.getCustomerId()); + //获取工作人员头像 + CustomerStaffDTO customerStaffParam = new CustomerStaffDTO(); + customerStaffParam.setUserId(userId); + Result staffInfo = epmetUserFeignClient.getCustomerStaffInfoByUserId(customerStaffParam); + resultDTO.setStaffHeadPhoto(staffInfo.getData().getHeadPhoto()); + resultDTO.setGender(staffInfo.getData().getGender()); + //获取客户名称 + CustomerDTO customerDTO = new CustomerDTO(); + customerDTO.setId(customerStaffAgencyDTO.getCustomerId()); + Result customerResult = operCrmFeignClient.getCustomerInfo(customerDTO); + resultDTO.setCustomerName(customerResult.getData().getCustomerName()); + return new Result().ok(resultDTO); + } + + @Override + public Result> getCustomerStaffAgencyList(StaffsInAgencyFromDTO fromDTO) { + + List customerStaffAgencyList = baseDao.selectCustomerStaffAgencyList(fromDTO.getAgencyId()); + + return new Result>().ok(customerStaffAgencyList); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java index 57afe3df39..2622f14529 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffGridServiceImpl.java @@ -23,8 +23,13 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerStaffGridDao; +import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; import com.epmet.entity.CustomerStaffGridEntity; import com.epmet.redis.CustomerStaffGridRedis; import com.epmet.service.CustomerStaffGridService; @@ -101,4 +106,14 @@ public class CustomerStaffGridServiceImpl extends BaseServiceImpl getStaffGridOrderByGridName(LatestGridFormDTO latestGridFormDTO) { + CustomerGridDTO grid = baseDao.selectStaffGridOrderByGridName(latestGridFormDTO); + CustomerGridByUserIdResultDTO result = new CustomerGridByUserIdResultDTO(); + result.setGridName(grid.getGridName()); + result.setGridId(grid.getId()); + result.setAgencyId(grid.getPid()); + return new Result().ok(result); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java new file mode 100644 index 0000000000..dda0d02ae7 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java @@ -0,0 +1,229 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.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.security.dto.TokenDto; +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.CustomerIdDTO; +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.entity.CustomerStaffDepartmentEntity; +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 addDepartment(AddDepartmentFormDTO formDTO) { + Result result = new Result(); + 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 departmentDetail(DepartmentdetailFormDTO formDTO) { + Result result = new Result(); + 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 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> resultList = epmetUserFeignClient.getDepartmentStaffList(departmentInStaffFormDTO); + if (!resultList.success() || null == resultList.getData()) { + log.error(CustomerDepartmentConstant.SELECT_STAFFINFO_EXCEPTION); + throw new RenException(CustomerDepartmentConstant.SELECT_STAFFINFO_EXCEPTION); + } + //部门下所有工作人员基本信息 + List staffList = resultList.getData(); + departmentDetailResultDTO.setStaffList(staffList); + return new Result().ok(departmentDetailResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 组织首页-获取机关下部门列表 + */ + @Override + public Result departmentInAgencyList(DepartmentInAgencyFormDTO formDTO) { + DepartmentInAgencyResultDTO departmentInAgencyResultDTO = new DepartmentInAgencyResultDTO(); + //1:根据当前机关Id查询该机关下的直属部门列表 + List departmentList = customerDepartmentDao.selectDepartmentListByAgencyId(formDTO.getAgencyId()); + departmentInAgencyResultDTO.setDepartmentList(departmentList); + //2:统计下一级机关数 + departmentInAgencyResultDTO.setDepartmentCount(departmentList.size()); + return new Result().ok(departmentInAgencyResultDTO); + } + + /** + * @param formDTO + * @return + * @Author sun + * @Description 获取机构下部门列表 + */ + @Override + public Result> departmentList(DepartmentListFormDTO formDTO) { + List departmentList = customerDepartmentDao.selectDepartmentList(formDTO.getAgencyId()); + return new Result>().ok(departmentList); + } + + /** + * 添加部门人员 + * @param tokenDto + * @param addDepartmentStaffFormDTO + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Result addDepartmentStaff(TokenDto tokenDto,AddDepartmentStaffFormDTO addDepartmentStaffFormDTO) { + CustomerStaffDepartmentEntity customerStaffDepartmentEntity = new CustomerStaffDepartmentEntity(); + Result> listResult = epmetUserFeignClient.selectCustomerIdByUserId(addDepartmentStaffFormDTO); + List data = listResult.getData(); + customerStaffDepartmentEntity.setDepartmentId(addDepartmentStaffFormDTO.getDepartmentId()); + customerStaffDepartmentEntity.setCreatedBy(tokenDto.getUserId()); + customerStaffDepartmentEntity.setUpdatedBy(tokenDto.getUserId()); + customerStaffDepartmentEntity.setDelFlag("0"); + customerStaffDepartmentEntity.setRevision(0); + for (CustomerIdDTO customerIdDTO : data) { + customerStaffDepartmentEntity.setUserId(customerIdDTO.getUserId()); + customerStaffDepartmentEntity.setCustomerId(customerIdDTO.getCustomerId()); + customerStaffDepartmentDao.insert(customerStaffDepartmentEntity); + } + customerStaffDepartmentDao.updateDepartmentStaffCount(data.size(),addDepartmentStaffFormDTO.getDepartmentId()); + return new Result(); + } +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java new file mode 100644 index 0000000000..db4e263508 --- /dev/null +++ b/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 getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + StaffsInAgencyResultDTO resultDTO = new StaffsInAgencyResultDTO(); + //获取机关所在客户ID和人员总数 + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + resultDTO.setStaffCount(customerAgencyEntity.getTotalUser()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + List customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData(); + if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) { + return new Result().ok(null); + } + //提取所有userID + List staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); + fromDTO.setStaffList(staffIds); + //获取用户信息 + Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); + resultDTO.setStaffList(staffInfoListResult.getData()); + return new Result().ok(resultDTO); + } + + @Override + public Result> getStaffList(StaffsInAgencyFromDTO fromDTO) { + //获取机关所在客户ID + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + List customerStaffAgencyList = customerStaffAgencyService.getCustomerStaffAgencyList(fromDTO).getData(); + if (null == customerStaffAgencyList || customerStaffAgencyList.size() == 0) { + return new Result>().ok(null); + } + //提取所有userID + List staffIds = customerStaffAgencyList.stream().map(CustomerStaffAgencyDTO::getUserId).collect(Collectors.toList()); + fromDTO.setStaffList(staffIds); + //获取用户列表 + Result> staffInfoListResult = epmetUserFeignClient.getStaffInfoForHome(fromDTO); + return null; + } + + @Override + public Result addStaffInit(StaffInfoFromDTO fromDTO) { + CustomerAgencyEntity customerAgencyEntity = customerAgencyService.selectById(fromDTO.getAgencyId()); + fromDTO.setCustomerId(customerAgencyEntity.getCustomerId()); + return epmetUserFeignClient.addStaffInit(fromDTO); + } + + @Override + public Result 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 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); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql index c53d7724f0..f4d0e47dc7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/epmet_gov_org.sql @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS `customer_department`; CREATE TABLE `customer_department` ( `ID` varchar(64) NOT NULL COMMENT 'ID 唯一标识', `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', - `ORG_ID` varchar(64) NOT NULL COMMENT '所属组织机构ID(customer_organization.id)', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '所属机关ID(customer_agency.id)', `DEPARTMENT_NAME` varchar(128) NOT NULL COMMENT '部门名称', `DEPARTMENT_DUTY` varchar(255) NOT NULL COMMENT '部门职责', `TOTAL_USER` int(11) NOT NULL COMMENT '总人数', @@ -12,19 +12,19 @@ CREATE TABLE `customer_department` ( `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', - PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户部门表 '; + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='客户部门表 '; -- ----------------------------------------------------------------------- -- ----------------------------------------------------------------------- -DROP TABLE IF EXISTS `customer_organization`; -CREATE TABLE `customer_organization` ( +DROP TABLE IF EXISTS `customer_agency`; +CREATE TABLE `customer_agency` ( `ID` varchar(64) NOT NULL COMMENT 'ID', `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', `PID` varchar(64) NOT NULL COMMENT '上级组织机构ID', `PIDS` varchar(1024) NOT NULL COMMENT '所有上级组织机构ID(以英文:隔开)', `ALL_PARENT_NAME` varchar(1024) DEFAULT NULL COMMENT '所有上级名称,以-连接', `ORGANIZATION_NAME` varchar(64) NOT NULL COMMENT '组织名称', - `LEVEL` int(10) NOT NULL COMMENT '机关级别(社区级:community,\r\n乡(镇、街道)级:street,\r\n区县级: district,\r\n市级: city\r\n省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province)', + `LEVEL` varchar(30) NOT NULL COMMENT '机关级别(社区级:community,\r\n乡(镇、街道)级:street,\r\n区县级: district,\r\n市级: city\r\n省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province)', `AREA_CODE` int(10) NOT NULL COMMENT '地区编码', `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标识', `REVISION` int(10) NOT NULL COMMENT '乐观锁', @@ -33,8 +33,8 @@ CREATE TABLE `customer_organization` ( `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', `TOTAL_USER` int(11) DEFAULT NULL COMMENT '总人数', - PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='组织机构表 '; + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='机关单位信息表'; -- ----------------------------------------------------------------------- -- ----------------------------------------------------------------------- DROP TABLE IF EXISTS `customer_staff_department`; @@ -49,8 +49,8 @@ CREATE TABLE `customer_staff_department` ( `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', - PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='部门人员关系表 '; + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='部门人员关系表 '; -- ----------------------------------------------------------------------- -- ----------------------------------------------------------------------- @@ -66,24 +66,24 @@ CREATE TABLE `customer_staff_grid` ( `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', - PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='网格人员关系表 '; + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='网格人员关系表 '; -- ----------------------------------------------------------------------- -- ----------------------------------------------------------------------- -DROP TABLE IF EXISTS `customer_staff_organization`; -CREATE TABLE `customer_staff_organization` ( +DROP TABLE IF EXISTS `customer_staff_agency`; +CREATE TABLE `customer_staff_agency` ( `ID` varchar(64) NOT NULL COMMENT 'ID', `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', `USER_ID` varchar(64) NOT NULL COMMENT '用户ID', - `ORG_ID` varchar(64) NOT NULL COMMENT '组织机构ID customer_organization.id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '组织机构ID customer_agency.id', `DEL_FLAG` int(10) NOT NULL COMMENT '删除标识', `REVISION` int(10) NOT NULL COMMENT '乐观锁', `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', - PRIMARY KEY (`ID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='组织人员关系表 '; + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='人员-机关单位关系表'; -- ----------------------------------------------------------------------- -- ----------------------------------------------------------------------- @@ -106,3 +106,8 @@ alter table customer_grid drop column SORT; alter table customer_grid add column ORG_ID varchar(64) NOT NULL COMMENT '所属组织机构ID(customer_organization.id)'; alter table customer_grid add column MANAGE_DISTRICT varchar(255) DEFAULT "" NOT NULL COMMENT '管辖区域'; alter table customer_grid add column TOTAL_USER INT(11) DEFAULT 0 NOT NULL COMMENT '当前网格总人数'; +ALTER TABLE customer_agency ADD ( + PROVINCE VARCHAR (32) DEFAULT NULL COMMENT '省份', + CITY VARCHAR (32) DEFAULT NULL COMMENT '城市', + DISTRICT VARCHAR (32) DEFAULT NULL COMMENT '区县' +); \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 18bb63b7b9..90b926b729 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -21,5 +21,54 @@ + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml index 9f595da2fe..7543fe31f6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml @@ -6,7 +6,7 @@ - + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 7c35a3e1c5..c7a54db7b9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -92,4 +92,106 @@ LIMIT #{pageNo}, #{pageSize} + + + + + + + + + + + + + + + + + + + + + update + customer_grid + set + grid_name = #{gridName}, + manage_district = #{manageDistrict}, + updated_by = #{updatedBy} + where + id = #{id} + + + + + update + customer_grid + set + updated_by = #{userId}, + del_flag = 1 + where + id = #{gridId} + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml index ff15e2a912..a9b8baea0d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml @@ -15,6 +15,28 @@ - + + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml index 5ab8b90e9c..6f13998784 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffDepartmentDao.xml @@ -3,18 +3,26 @@ - - - - - - - - - - - - + + + + + UPDATE + customer_department + SET + total_user = total_user + #{addCount} + WHERE + id = #{departmentId} + \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml index 13dbdb25ce..47a9de4a33 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml @@ -17,4 +17,28 @@ + + + \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java new file mode 100644 index 0000000000..b4fbbeff49 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 根据客户id查询客户信息 + * @Author yinzuomei + * @Date 2020/4/24 9:09 + */ +@Data +public class CustomerFormDTO implements Serializable { + /** + * 客户id集合 + * */ + private List customerIdList; +} + diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index 4a9bbd1119..1605fd6c80 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -17,18 +17,16 @@ package com.epmet.controller; -import com.alibaba.fastjson.JSON; -import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; 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.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.CustomerExcel; import com.epmet.service.CustomerService; @@ -133,8 +131,29 @@ public class CustomerController { * @Date 2020/3/11 21:58 **/ @GetMapping("getvalidcustomerlist") - public Result> getValidCustomerList(@LoginUser TokenDto tokenDTO) { - logger.info("getvalidcustomerlist:"+ JSON.toJSONString(tokenDTO)); + public Result> getValidCustomerList() { return customerService.getValidCustomerList(); } + + /** + * 获取客户信息 + * @param dto + * @return + */ + @PostMapping("getcostomerInfo") + public Result getCustomerInfo(@RequestBody CustomerDTO dto) { + return customerService.getCustomerInfo(dto); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:13 + **/ + @PostMapping("queryCustomerList") + public Result> queryCustomerList(@RequestBody CustomerFormDTO formDTO) { + return customerService.queryCustomerList(formDTO); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java index 661cc151c4..6a958cc6d2 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerDao.java @@ -18,9 +18,11 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -40,4 +42,13 @@ public interface CustomerDao extends BaseDao { * @date 2020-03-11 */ List selectListValidCustomerResultDTO(); + + /** + * @return java.util.List + * @param customerIdList + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:21 + **/ + List selectListByIds(@Param("customerIdList") List customerIdList); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java index 1ef60f3762..a50c87a138 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.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.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; @@ -113,4 +114,20 @@ public interface CustomerService extends BaseService { * @Date 2020/3/18 9:44 **/ Result saveCustomerInfo(CustomerDTO dto); + + /** + * 获取客户信息 + * @param dto + * @return + */ + Result getCustomerInfo(CustomerDTO dto); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据客户id查询客户信息 + * @Date 2020/4/24 9:13 + **/ + Result> queryCustomerList(CustomerFormDTO formDTO); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index 512eb55d40..89bab2936a 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerDao; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.CustomerEntity; import com.epmet.redis.CustomerRedis; @@ -129,4 +130,16 @@ public class CustomerServiceImpl extends BaseServiceImpl().ok(entity.getId()); } + @Override + public Result getCustomerInfo(CustomerDTO dto) { + CustomerEntity entity = baseDao.selectById(dto.getId()); + return new Result().ok(ConvertUtils.sourceToTarget(entity, CustomerDTO.class)); + } + + @Override + public Result> queryCustomerList(CustomerFormDTO formDTO) { + List customerDTOList = baseDao.selectListByIds(formDTO.getCustomerIdList()); + return new Result>().ok(customerDTOList); + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml index 2a7e3c22ab..340883f472 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerDao.xml @@ -34,4 +34,18 @@ ORDER BY CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC + + + diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/CustomerFootBarDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/CustomerFootBarDTO.java new file mode 100644 index 0000000000..2cc9b89b0e --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/CustomerFootBarDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class CustomerFootBarDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 唯一标识 + */ + private String id; + + /** + * bar名称 + */ + private String barName; + + /** + * KEY + */ + private String barKey; + + /** + * 页面标题 + */ + private String pageTitle; + + /** + * 图标路径 + */ + private String iconPath; + + /** + * 选中页面图标路径 + */ + private String selectedIconPath; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFootBarFormDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFootBarFormDTO.java new file mode 100644 index 0000000000..73b4c7b500 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/CustomerFootBarFormDTO.java @@ -0,0 +1,13 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class CustomerFootBarFormDTO { + + //@NotBlank(message = "客户ID不能为空") + private String customerId; + +} diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFootBarResultDTO.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFootBarResultDTO.java new file mode 100644 index 0000000000..832e06944c --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFootBarResultDTO.java @@ -0,0 +1,97 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class CustomerFootBarResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 唯一标识 + */ + private String id; + + /** + * bar名称 + */ + private String barName; + + /** + * KEY + */ + private String barKey; + + /** + * 页面标题 + */ + private String pageTitle; + + /** + * 图标路径 + */ + private String iconPath; + + /** + * 选中页面图标路径 + */ + private String selectedIconPath; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java new file mode 100644 index 0000000000..a0bd33d16c --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java @@ -0,0 +1,117 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +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.CustomerFootBarDTO; +import com.epmet.dto.form.CustomerFootBarFormDTO; +import com.epmet.entity.CustomerFootBarEntity; +import com.epmet.excel.CustomerFootBarExcel; +import com.epmet.service.CustomerFootBarService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@RestController +@RequestMapping("customerfootbar") +public class CustomerFootBarController { + + @Autowired + private CustomerFootBarService customerFootBarService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = customerFootBarService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + CustomerFootBarDTO data = customerFootBarService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody CustomerFootBarDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + customerFootBarService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody CustomerFootBarDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + customerFootBarService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + customerFootBarService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = customerFootBarService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, CustomerFootBarExcel.class); + } + + /** + * 查询客户的APP footbar + * @param formDTO + * @return + */ + @PostMapping("customerfootbars") + public Result> getCustomerfootbars(@RequestBody CustomerFootBarFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + String customerId = formDTO.getCustomerId(); + + List footbars = customerFootBarService.listCustomerFootBars(customerId); + List barDTOS = new LinkedList<>(); + footbars.forEach(barEntity -> { + CustomerFootBarDTO barDTO = new CustomerFootBarDTO(); + BeanUtils.copyProperties(barEntity, barDTO); + barDTOS.add(barDTO); + }); + return new Result>().ok(barDTOS); + } +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java new file mode 100644 index 0000000000..f22bc917ad --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/CustomerFootBarDao.java @@ -0,0 +1,37 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.CustomerFootBarEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Mapper +public interface CustomerFootBarDao extends BaseDao { + + List listCustomerFootBars(@Param("customerId") String customerId); +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/CustomerFootBarEntity.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/CustomerFootBarEntity.java new file mode 100644 index 0000000000..8bfc92afb1 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/entity/CustomerFootBarEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_foot_bar") +public class CustomerFootBarEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * bar名称 + */ + private String barName; + + /** + * KEY + */ + private String barKey; + + /** + * 页面标题 + */ + private String pageTitle; + + /** + * 图标路径 + */ + private String iconPath; + + /** + * 选中页面图标路径 + */ + private String selectedIconPath; + +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/CustomerFootBarExcel.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/CustomerFootBarExcel.java new file mode 100644 index 0000000000..d282380f8f --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/excel/CustomerFootBarExcel.java @@ -0,0 +1,71 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class CustomerFootBarExcel { + + @Excel(name = "唯一标识") + private String id; + + @Excel(name = "bar名称") + private String barName; + + @Excel(name = "KEY") + private String key; + + @Excel(name = "页面标题") + private String pageTitle; + + @Excel(name = "图标路径") + private String iconPath; + + @Excel(name = "选中页面图标路径") + private String selectedIconPath; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java new file mode 100644 index 0000000000..1d120429d8 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/redis/CustomerFootBarRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Component +public class CustomerFootBarRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java new file mode 100644 index 0000000000..f3a793793d --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/CustomerFootBarService.java @@ -0,0 +1,97 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CustomerFootBarDTO; +import com.epmet.entity.CustomerFootBarEntity; + +import java.util.List; +import java.util.Map; + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +public interface CustomerFootBarService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-22 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-22 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CustomerFootBarDTO + * @author generator + * @date 2020-04-22 + */ + CustomerFootBarDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void save(CustomerFootBarDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void update(CustomerFootBarDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-22 + */ + void delete(String[] ids); + + List listCustomerFootBars(String customerId); +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFootBarServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFootBarServiceImpl.java new file mode 100644 index 0000000000..15336d92fc --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFootBarServiceImpl.java @@ -0,0 +1,109 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.CustomerFootBarDao; +import com.epmet.dto.CustomerFootBarDTO; +import com.epmet.entity.CustomerFootBarEntity; +import com.epmet.redis.CustomerFootBarRedis; +import com.epmet.service.CustomerFootBarService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * APP底部菜单栏信息 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Service +public class CustomerFootBarServiceImpl extends BaseServiceImpl implements CustomerFootBarService { + + @Autowired + private CustomerFootBarRedis customerFootBarRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerFootBarDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CustomerFootBarDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public CustomerFootBarDTO get(String id) { + CustomerFootBarEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CustomerFootBarDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CustomerFootBarDTO dto) { + CustomerFootBarEntity entity = ConvertUtils.sourceToTarget(dto, CustomerFootBarEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CustomerFootBarDTO dto) { + CustomerFootBarEntity entity = ConvertUtils.sourceToTarget(dto, CustomerFootBarEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List listCustomerFootBars(String customerId) { + return baseDao.listCustomerFootBars(customerId); + } + +} \ No newline at end of file diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/db.migration/customer_foot_bar.sql b/epmet-module/oper-customize/oper-customize-server/src/main/resources/db.migration/customer_foot_bar.sql new file mode 100644 index 0000000000..dc9eebc971 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/db.migration/customer_foot_bar.sql @@ -0,0 +1,37 @@ +/* + Date: 22/04/2020 12:21:32 wxz +*/ + +-- SET NAMES utf8mb4; +-- SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for customer_foot_bar +-- ---------------------------- +DROP TABLE IF EXISTS `customer_foot_bar`; +CREATE TABLE `customer_foot_bar` ( + `ID` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '客户ID', + `BAR_NAME` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'bar名称', + `BAR_KEY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'KEY', + `PAGE_TITLE` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '页面标题', + `ICON_PATH` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标路径', + `SELECTED_ICON_PATH` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '选中页面图标路径', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime(0) NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime(0) NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'APP底部菜单栏信息' ROW_FORMAT = Compact; + +-- ---------------------------- +-- Records of customer_foot_bar +-- ---------------------------- +INSERT INTO `customer_foot_bar` VALUES ('1', '工作', 'work', '党群e事通-政府端', NULL, NULL, 0, 0, 'wxz', '2020-04-22 10:53:22', 'wxz', '2020-04-22 10:53:26'); +INSERT INTO `customer_foot_bar` VALUES ('2', '组织', 'org', '组织机构', NULL, NULL, 0, 0, 'wxz', '2020-04-22 10:53:56', 'wxz', '2020-04-22 10:54:00'); +INSERT INTO `customer_foot_bar` VALUES ('3', '数据', 'data', '数据', NULL, NULL, 0, 0, 'wxz', '2020-04-22 11:20:54', 'wxz', '2020-04-22 11:20:58'); +INSERT INTO `customer_foot_bar` VALUES ('4', '发现', 'find', '发现', NULL, NULL, 0, 0, 'wxz', '2020-04-22 11:21:48', 'wxz', '2020-04-22 11:21:53'); + +-- SET FOREIGN_KEY_CHECKS = 1; diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml new file mode 100644 index 0000000000..a11df38ba6 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/CustomerFootBarDao.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/pom.xml b/epmet-module/pom.xml index 81243917bf..48ae687bb5 100644 --- a/epmet-module/pom.xml +++ b/epmet-module/pom.xml @@ -29,5 +29,8 @@ resi-partymember gov-grid + gov-access + gov-mine + diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/comment/controller/ResiCommentController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/comment/controller/ResiCommentController.java index 4b37c30352..321069290b 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/comment/controller/ResiCommentController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/comment/controller/ResiCommentController.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.modules.topic.service.ResiTopicCommentService; -import com.epmet.modules.utils.ModuleConstant; import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO; import com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO; import com.epmet.resi.group.dto.topic.form.ResiPublishCommentFormDTO; @@ -53,7 +52,7 @@ public class ResiCommentController { * @Date 2020.04.01 23:49 **/ @PostMapping("getcommentlistoftopic") - public Result> getCommentListOfTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiQueryCommentFormDTO queryCommentFormDTO){ + public Result> getCommentListOfTopic(@LoginUser TokenDto tokenDto, @RequestBody ResiQueryCommentFormDTO queryCommentFormDTO){ ValidatorUtils.validateEntity(queryCommentFormDTO); return commentService.getCommentList(tokenDto,queryCommentFormDTO); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java index 0dfa43e4bd..8d1e757349 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java @@ -78,7 +78,7 @@ public class ResiGroupController { **/ @PostMapping("getrecommendgroup") public Result> getRecommendGroup(@LoginUser TokenDto tokenDto, - @RequestBody RecommendGroupFormDTO recommendGroupFormDTO) { + @RequestBody RecommendGroupFormDTO recommendGroupFormDTO) { recommendGroupFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(recommendGroupFormDTO); return resiGroupService.getRecommendGroup(recommendGroupFormDTO); @@ -94,7 +94,7 @@ public class ResiGroupController { **/ @PostMapping("getcreated") public Result> getCreated(@LoginUser TokenDto tokenDto, - @RequestBody CreatedFormDTO createdFormDTO) { + @RequestBody CreatedFormDTO createdFormDTO) { createdFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(createdFormDTO); return resiGroupService.getCreated(createdFormDTO); @@ -125,7 +125,7 @@ public class ResiGroupController { **/ @PostMapping("getgroupsummarize") public Result getGroupSummarize(@LoginUser TokenDto tokenDto, - @RequestBody GroupSummarizeFormDTO groupSummarizeFormDTO) { + @RequestBody GroupSummarizeFormDTO groupSummarizeFormDTO) { groupSummarizeFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(groupSummarizeFormDTO); return resiGroupService.getGroupSummarize(groupSummarizeFormDTO); @@ -141,7 +141,7 @@ public class ResiGroupController { **/ @PostMapping("applycreategroup") public Result applyCreateGroup(@LoginUser TokenDto tokenDto, - @RequestBody ApplyCreateGroupFormDTO applyCreateGroupFormDTO) { + @RequestBody ApplyCreateGroupFormDTO applyCreateGroupFormDTO) { applyCreateGroupFormDTO.setUserId(tokenDto.getUserId()); applyCreateGroupFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(applyCreateGroupFormDTO); @@ -158,7 +158,7 @@ public class ResiGroupController { **/ @PostMapping("initapplygroup") public Result initApplyGroup(@LoginUser TokenDto tokenDto, - @RequestBody InitApplyGroupFormDTO initApplyGroupFormDTO) { + @RequestBody InitApplyGroupFormDTO initApplyGroupFormDTO) { if (null == tokenDto) { logger.error(ModuleConstant.USER_NOT_NULL); throw new RenException(ModuleConstant.USER_NOT_NULL); @@ -178,7 +178,7 @@ public class ResiGroupController { **/ @PostMapping("initapplycreategroup") public Result initApplyCreatedGroup(@LoginUser TokenDto tokenDto, - @RequestBody InitApplyCreatedGroupFormDTO initApplyCreatedGroupFormDTO) { + @RequestBody InitApplyCreatedGroupFormDTO initApplyCreatedGroupFormDTO) { if (null == tokenDto) { logger.error(ModuleConstant.USER_NOT_NULL); throw new RenException(ModuleConstant.USER_NOT_NULL); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/controller/GroupInvitationController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/controller/GroupInvitationController.java index 62a9bbd452..1364dcbba8 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/controller/GroupInvitationController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/controller/GroupInvitationController.java @@ -57,7 +57,7 @@ public class GroupInvitationController { **/ @PostMapping("creategroupinvitation") public Result createGroupInvitation(@LoginUser TokenDto tokenDto, - @RequestBody CreateGroupInvitationFormDTO formDTO) { + @RequestBody CreateGroupInvitationFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO); return groupInvitationService.createGroupInvitation(formDTO); @@ -72,7 +72,7 @@ public class GroupInvitationController { **/ @PostMapping("getlinkgroupinfo") public Result getLinkGroupInfo(@LoginUser TokenDto tokenDto, - @RequestBody LinkGroupInfoFormDTO formDTO) { + @RequestBody LinkGroupInfoFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO); return groupInvitationService.getLinkGroupInfo(formDTO); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java index 0ddb15285e..75489585f9 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java @@ -26,7 +26,10 @@ import com.epmet.resi.group.dto.member.form.*; import com.epmet.resi.group.dto.member.result.ApplyingMemberResultDTO; import com.epmet.resi.group.dto.member.result.GroupMemberListResultDTO; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +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; @@ -53,7 +56,7 @@ public class ResiGroupMemberController { **/ @PostMapping("applyjoingroup") public Result applyJoinGroup(@LoginUser TokenDto tokenDto, - @RequestBody ApplyJoinGroupFormDTO applyJoinGroupFormDTO) { + @RequestBody ApplyJoinGroupFormDTO applyJoinGroupFormDTO) { applyJoinGroupFormDTO.setUserId(tokenDto.getUserId()); applyJoinGroupFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(applyJoinGroupFormDTO); @@ -70,7 +73,7 @@ public class ResiGroupMemberController { **/ @PostMapping("getgroupmember") public Result> getGroupMemberList(@LoginUser TokenDto tokenDto, - @RequestBody GroupMemberListFormDTO groupMemberListFormDTO) { + @RequestBody GroupMemberListFormDTO groupMemberListFormDTO) { ValidatorUtils.validateEntity(groupMemberListFormDTO); return resiGroupMemberService.getGroupMemberList(groupMemberListFormDTO); } @@ -85,7 +88,7 @@ public class ResiGroupMemberController { **/ @PostMapping("getapplyingmember") public Result> getApplyingMember(@LoginUser TokenDto tokenDto, - @RequestBody ApplyingMemberFormDTO applyingMemberFormDTO) { + @RequestBody ApplyingMemberFormDTO applyingMemberFormDTO) { ValidatorUtils.validateEntity(applyingMemberFormDTO); return resiGroupMemberService.getApplyingMember(applyingMemberFormDTO); } @@ -100,7 +103,7 @@ public class ResiGroupMemberController { **/ @PostMapping("agreeapply") public Result agreeApply(@LoginUser TokenDto tokenDto, - @RequestBody AgreeApplyFormDTO agreeApplyFormDTO) { + @RequestBody AgreeApplyFormDTO agreeApplyFormDTO) { agreeApplyFormDTO.setUserId(tokenDto.getUserId()); agreeApplyFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(agreeApplyFormDTO); @@ -117,7 +120,7 @@ public class ResiGroupMemberController { **/ @PostMapping("disagreeapply") public Result disAgreeApply(@LoginUser TokenDto tokenDto, - @RequestBody DisagreeApplyFormDTO disagreeApplyFormDTO) { + @RequestBody DisagreeApplyFormDTO disagreeApplyFormDTO) { disagreeApplyFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(disagreeApplyFormDTO); return resiGroupMemberService.disAgreeApply(disagreeApplyFormDTO); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java index 9415d59760..b8dba5abcc 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java @@ -9,7 +9,10 @@ import com.epmet.resi.group.dto.topic.form.*; import com.epmet.resi.group.dto.topic.result.ResiTopicDetailResultDTO; import com.epmet.resi.group.dto.topic.result.ResiTopicInfoResultDTO; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +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; @@ -79,7 +82,7 @@ public class ResiTopicController { * @Date 2020.04.02 00:01 **/ @PostMapping("getlatesttopics") - Result> getLatestTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){ + Result> getLatestTopics(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){ ValidatorUtils.validateEntity(topicDefaultPageFormDTO); return topicService.getLatestTopics(tokenDto,topicDefaultPageFormDTO.getGroupId()); } @@ -93,7 +96,7 @@ public class ResiTopicController { * @Date 2020.04.01 12:38 **/ @RequestMapping("hidetopic") - Result hideTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicOperationFormDTO hiddenFormDTO){ + Result hideTopic(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicOperationFormDTO hiddenFormDTO){ ValidatorUtils.validateEntity(hiddenFormDTO); return topicService.hideTopic(tokenDto,hiddenFormDTO); } @@ -107,7 +110,7 @@ public class ResiTopicController { * @Date 2020.04.01 16:45 **/ @PostMapping("gethiddentopic") - Result> getHiddenTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicPageFormDTO topicPageFormDTO){ + Result> getHiddenTopic(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicPageFormDTO topicPageFormDTO){ ValidatorUtils.validateEntity(topicPageFormDTO); return topicService.getHiddenTopics(tokenDto,topicPageFormDTO); } @@ -121,7 +124,7 @@ public class ResiTopicController { * @Date 2020.04.01 14:17 **/ @PostMapping("cancelhiddentopics") - Result cancelHiddenTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicCancelHiddenFormDTO cancelHiddenFormDTO){ + Result cancelHiddenTopics(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicCancelHiddenFormDTO cancelHiddenFormDTO){ return topicService.cancelHiddenTopics(tokenDto,cancelHiddenFormDTO.getTopicIds()); } @@ -134,7 +137,7 @@ public class ResiTopicController { * @Date 2020.04.01 15:37 **/ @PostMapping("closetopic") - Result closeTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicOperationFormDTO closeFormDTO){ + Result closeTopic(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicOperationFormDTO closeFormDTO){ ValidatorUtils.validateEntity(closeFormDTO); return topicService.closeTopic(tokenDto,closeFormDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java index 7c3b78194f..875d4badd0 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java @@ -54,7 +54,7 @@ public class StrangerResiGuideController { * @Date 2020/3/16 **/ @PostMapping("getgridhome") - public Result getGridHome( @LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception { + public Result getGridHome(@LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception { return strangerAccessRecordService.getGridHome(tokenDTO, strangerFormDTO); } diff --git a/epmet-module/resi-mine/resi-mine-server/pom.xml b/epmet-module/resi-mine/resi-mine-server/pom.xml index 18d3fdbc41..77cc559c92 100644 --- a/epmet-module/resi-mine/resi-mine-server/pom.xml +++ b/epmet-module/resi-mine/resi-mine-server/pom.xml @@ -12,11 +12,6 @@ jar - - com.epmet - resi-mine-client - 2.0.0 - com.epmet epmet-commons-tools diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java index 2af9dfb554..e7d2ed2bf2 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java @@ -30,42 +30,39 @@ public class UserMessageController { /** * @param * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei + * @Author zhaoqifeng * @Description 查询我的消息 * @Date 2020/3/29 20:53 **/ @PostMapping("getmymessage") public Result> getMyMessage(@LoginUser TokenDto tokenDto, - @RequestBody MymessageFormDTO mymessageFormDTO) { + @RequestBody MymessageFormDTO mymessageFormDTO) { mymessageFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(mymessageFormDTO); - //逻辑待实现 return userMessageService.getMessageList(tokenDto, mymessageFormDTO); } /** * @param fromDTO * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei + * @Author zhaoqifeng * @Description 单条消息标记为已读 * @Date 2020/3/29 21:05 **/ @PostMapping("readmsg") - public Result readMessage(@RequestBody ReadMessageFromDTO fromDTO) { - //逻辑待实现 + public Result readMessage(@LoginUser TokenDto tokenDto,@RequestBody ReadMessageFromDTO fromDTO) { return userMessageService.readMessage(fromDTO.getMessageId()); } /** * @param tokenDto * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei + * @Author zhaoqifeng * @Description 全部已读 * @Date 2020/3/29 21:06 **/ @PostMapping("readallmsg") public Result readAllMessage(@LoginUser TokenDto tokenDto, @RequestBody UserMessageDTO userMessageDTO) { - //逻辑待实现 return userMessageService.readAllMessage(tokenDto, userMessageDTO); } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java index 6fbd80dd49..a247d4e450 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/CustomerStaffDTO.java @@ -128,4 +128,9 @@ public class CustomerStaffDTO implements Serializable { * 客户id */ private String customerId; + + /** + * 角色名称 + */ + private String roleName; } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/GovStaffRoleDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/GovStaffRoleDTO.java new file mode 100644 index 0000000000..9bc2f4c4de --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/GovStaffRoleDTO.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 政府端角色字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class GovStaffRoleDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。 + */ + private String customerId; + + /** + * 角色key + */ + private String roleKey; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 角色所属体系类型:agency,department,grid + */ + private String orgType; + + /** + * + */ + private Integer delFlag; + + /** + * + */ + private Integer revision; + + /** + * + */ + private String createdBy; + + /** + * + */ + private Date createdTime; + + /** + * + */ + private String updatedBy; + + /** + * + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffAgencyVisitedDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffAgencyVisitedDTO.java new file mode 100644 index 0000000000..45c5c443a8 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffAgencyVisitedDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 工作人员进入组织日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Data +public class StaffAgencyVisitedDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 唯一标识 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * customer_staff.userId + */ + private String staffId; + + /** + * 微信openId + */ + private String wxOpenId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 机关单位id来源于customer_agency.id + */ + private String agencyId; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间,登录时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffGridVisitedDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffGridVisitedDTO.java new file mode 100644 index 0000000000..328aafad2e --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffGridVisitedDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 工作人员进入网格日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Data +public class StaffGridVisitedDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 唯一标识 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格ID + */ + private String gridId; + + /** + * customer_staff.userId + */ + private String staffId; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间,登录时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffRoleDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffRoleDTO.java new file mode 100644 index 0000000000..59d649f970 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffRoleDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class StaffRoleDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 用户ID + */ + private String staffId; + + /** + * 角色ID + */ + private String roleId; + + /** + * 角色所属类型的ID。例如,机关的角色,那该字段就是所属机关的ID;部门的角色,该字段就是所属部门的ID;网格的角色,该字段就是所属网格ID + */ + private String orgId; + + /** + * + */ + private Integer delFlag; + + /** + * + */ + private Integer revision; + + /** + * + */ + private String createdBy; + + /** + * + */ + private Date createdTime; + + /** + * + */ + private String updatedBy; + + /** + * + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java new file mode 100644 index 0000000000..43acb11d1c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Author yinzuomei + * @Date 2020/4/20 14:02 + */ +@Data +public class CustomerStaffFormDTO implements Serializable { + private static final long serialVersionUID = 7619815083427853431L; + @NotBlank(message = "手机号不能为空") + private String mobile; + @NotBlank(message = "客户id不能为空") + private String customerId; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java new file mode 100644 index 0000000000..5810659515 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DepartmentInStaffFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 根据客户Id和用户Id查询用户基本信息 + * @Author sun + */ +@Data +public class DepartmentInStaffFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 部门Id + */ + private String departmentId; + + /** + * 客户Id CUSTOMER.id + */ + private String customerId; + + /** + * 用户Id集合 + */ + private List userIdList; + +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffGridVisitedFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffGridVisitedFormDTO.java new file mode 100644 index 0000000000..bdf88528a1 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffGridVisitedFormDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 保存网格访问记录入参 + * @Author yinzuomei + * @Date 2020/4/23 11:01 + */ +@Data +public class StaffGridVisitedFormDTO implements Serializable { + private static final long serialVersionUID = 4932900259489068815L; + /** + * 客户ID + */ + @NotBlank(message = "客户id") + private String customerId; + + /** + * 网格ID + */ + @NotBlank(message = "网格id不能为空") + private String gridId; + + /** + * customer_staff.userId + */ + @NotBlank(message = "staffId不能为空") + private String staffId; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffLoginAgencyRecordFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffLoginAgencyRecordFormDTO.java new file mode 100644 index 0000000000..6bfb38de7b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffLoginAgencyRecordFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 保存工作人员登录日志 + * @Author yinzuomei + * @Date 2020/4/20 14:26 + */ +@Data +public class StaffLoginAgencyRecordFormDTO implements Serializable { + /** + * 客户ID + */ + private String customerId; + + /** + * customer_staff.userId + */ + private String staffId; + + /** + * 微信openId + */ + private String wxOpenId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 组织机构id + */ + private String agencyId; + +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java new file mode 100644 index 0000000000..02ffc22867 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffRoleFormDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class StaffRoleFormDTO { + + /**===========校验分组开始============*/ + + // 查询工作人员角色列表group + public interface GetRolesOfStaff {} + + // 查询某角色下的人员列表group + public interface GetStaffsInRole {} + + /**===========校验分组结束============*/ + + @NotBlank(message = "工作人员ID不能为空", groups = {GetRolesOfStaff.class}) + private String staffId; + + /** + * 组织id,可以是agencyId,DeptId,GridId + */ + @NotBlank(message = "工作人员所属组织ID不能为空", groups = {GetRolesOfStaff.class, GetStaffsInRole.class}) + private String orgId; + + /** + * 角色key + */ + @NotBlank(message = "角色Key不能为空", groups = {GetStaffsInRole.class}) + private String roleKey; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java new file mode 100644 index 0000000000..6123f16677 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovStaffRoleResultDTO.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class GovStaffRoleResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 人员id + */ + private String staffId; + + /** + * 角色key + */ + private String roleKey; + + /** + * 角色名称 + */ + private String roleName; +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffLatestAgencyResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffLatestAgencyResultDTO.java new file mode 100644 index 0000000000..45dcef0416 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffLatestAgencyResultDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 当前微信上次登录的账号信息返参DTO + * @Author yinzuomei + * @Date 2020/4/20 12:23 + */ +@Data +public class StaffLatestAgencyResultDTO implements Serializable { + private static final long serialVersionUID = -7088774184276785902L; + + /** + * 客户ID + */ + private String customerId; + + /** + * customer_staff.userId + */ + private String staffId; + + /** + * 微信openId + */ + private String wxOpenId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 组织机构id + */ + private String agencyId; +} + diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index adc3bba016..761a0299a9 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -70,6 +70,12 @@ 2.0.0 compile + + com.epmet + oper-crm-client + 2.0.0 + compile + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java new file mode 100644 index 0000000000..f823247843 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/CustomerStaffConstant.java @@ -0,0 +1,34 @@ +package com.epmet.constant; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/24 15:42 + */ +public interface CustomerStaffConstant { + + /** + * 专职 + */ + String FULL_TIME ="fulltime"; + /** + * 兼职 + */ + String PART_TIME ="parttime"; + /** + * 已激活 + */ + String INACTIVE ="inactive"; + /** + * 未激活 + */ + String ACTIVE ="active"; + /** + * 已禁用 + */ + String DISABLED ="disabled"; + /** + * 未禁用 + */ + String ENABLE ="enable"; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java index 640d5079ea..16fb79e8fd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserConstant.java @@ -57,4 +57,14 @@ public interface UserConstant { * 未禁用enable,已禁用diabled */ String DISABLED="disabled"; + + /** + * inactive未激活,active已激活 + */ + String INACTIVE="inactive"; + + /** + * inactive未激活,active已激活 + */ + String ACTIVE="active"; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java index ce710319bd..48b3e77940 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRoleConstant.java @@ -11,4 +11,10 @@ public interface UserRoleConstant { * 角色表对应的是居民角色时grid_id的默认值 */ String DEFAULT_GRID_ID = "all"; + + /** + * 部门领导角色值 + */ + String DEPT_LEADER = "dept_leader"; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index f097f86d5e..748252137b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -23,9 +23,18 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; 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.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.*; +import com.epmet.dto.form.*; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.form.*; +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.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; import org.springframework.beans.factory.annotation.Autowired; @@ -45,24 +54,24 @@ import java.util.Map; @RestController @RequestMapping("customerstaff") public class CustomerStaffController { - + @Autowired private CustomerStaffService customerStaffService; @GetMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = customerStaffService.page(params); return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ + public Result get(@PathVariable("id") String id) { CustomerStaffDTO data = customerStaffService.get(id); return new Result().ok(data); } @PostMapping - public Result save(@RequestBody CustomerStaffDTO dto){ + public Result save(@RequestBody CustomerStaffDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); customerStaffService.save(dto); @@ -70,7 +79,7 @@ public class CustomerStaffController { } @PutMapping - public Result update(@RequestBody CustomerStaffDTO dto){ + public Result update(@RequestBody CustomerStaffDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); customerStaffService.update(dto); @@ -78,7 +87,7 @@ public class CustomerStaffController { } @DeleteMapping - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); customerStaffService.delete(ids); @@ -92,14 +101,97 @@ public class CustomerStaffController { } /** - * @param phone 手机号 + * @param mobile 手机号 * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 根据手机号查询政府端工作人员基本信息,校验用户是否存在 * @Date 2020/4/18 14:07 **/ - @GetMapping(value = "getcustsomerstaffbyphone/{phone}") - public Result getCustsomerStaffByPhone(@PathVariable("phone") String phone) { - return customerStaffService.getCustsomerStaffByPhone(phone); + @GetMapping(value = "getcustsomerstaffbyphone/{mobile}") + public Result> getCustsomerStaffByPhone(@PathVariable("mobile") String mobile) { + return customerStaffService.getCustsomerStaffByPhone(mobile); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:04 + **/ + @PostMapping(value = "getcustomerstaffinfo") + public Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return customerStaffService.getCustomerStaffInfo(formDTO); + } + + /** + * 根据userId查询网格下用户信息 + * @param customerStaffGridDTOS + * @return + */ + @PostMapping(value = "selectstaffgridlistbyuserid") + public Result> selectStaffGridListByUserId(@RequestBody List customerStaffGridDTOS){ + Result> listResult = customerStaffService.selectStaffGridListByUserId(customerStaffGridDTOS); + return listResult; + } + + /** + * 根据用户ID获取工作人员基本信息 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/4/22 10:05 + **/ + @PostMapping(value = "getstaffinfobyuserid") + public Result getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO) { + return customerStaffService.getCustomerStaffInfoByUserId(formDTO); + } + + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("staffsinagency") + public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + return customerStaffService.getStaffInfoForHome(fromDTO); + } + + /** + * 工作人员列表 + * @param fromDTO + * @return + */ + @PostMapping("stafflist") + public Result> getStaffList(StaffsInAgencyFromDTO fromDTO) { + return customerStaffService.getStaffList(fromDTO); + } + + /** + * 查询网格下未被禁用人员 + * @param userIdDTO + * @auther zxc + */ + @PostMapping(value = "selectgridstaffcountbyuserid") + public Result selectGridStaffCountByUserId(@RequestBody UserIdDTO userIdDTO){ + return customerStaffService.selectGridStaffCountByUserId(userIdDTO); + } + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + @PostMapping("getdepartmentstafflist") + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO fromDTO) { + return customerStaffService.getDepartmentStaffList(fromDTO); + } + + @PostMapping(value = "selectcustomeridbyuserid") + public Result> selectCustomerIdByUserId(@RequestBody AddDepartmentStaffFormDTO addDepartmentStaffFormDTO){ + return customerStaffService.selectCustomerIdByUserId(addDepartmentStaffFormDTO); } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java index f9d88ddd6a..acc2bb9e9f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java @@ -26,8 +26,8 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; 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.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.OperUserDTO; import com.epmet.dto.result.QueryOperUserResultDto; import com.epmet.excel.OperUserExcel; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffAgencyVisitedController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffAgencyVisitedController.java new file mode 100644 index 0000000000..488a103ef0 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffAgencyVisitedController.java @@ -0,0 +1,65 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffLoginAgencyRecordFormDTO; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; +import com.epmet.service.StaffAgencyVisitedService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + + +/** + * 工作人员进入组织日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@RestController +@RequestMapping("staffagencyvisited") +public class StaffAgencyVisitedController { + + @Autowired + private StaffAgencyVisitedService staffAgencyVisitedService; + + /** + * @param openId + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 获取当前微信上次登录的账号信息 + * @Date 2020/4/20 12:42 + **/ + @GetMapping(value = "getlatest/{openId}") + public Result getLatestStaffWechatLoginRecord(@PathVariable("openId") String openId) { + return staffAgencyVisitedService.getLatestStaffWechatLoginRecord(openId); + } + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存登录日志 + * @Date 2020/4/20 14:29 + **/ + @PostMapping(value = "saveStaffLoginRecord") + public Result saveStaffLoginRecord(@RequestBody StaffLoginAgencyRecordFormDTO formDTO) { + return staffAgencyVisitedService.saveStaffLoginRecord(formDTO); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffGridVisitedController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffGridVisitedController.java new file mode 100644 index 0000000000..2e8dc01c3f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffGridVisitedController.java @@ -0,0 +1,73 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.service.StaffGridVisitedService; +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 javax.validation.Valid; + + +/** + * 工作人员进入网格日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@RestController +@RequestMapping("staffgridvisited") +public class StaffGridVisitedController { + + @Autowired + private StaffGridVisitedService staffGridVisitedService; + + /** + * @Description 查询工作人员上次登录的网格 + * @Param LatestGridFormDTO -> customerId ; staffId + * @return Result + * @Author wangc + * @Date 2020.04.23 10:05 + **/ + @PostMapping("getstafflatestgrid") + Result getStaffLatestGrid(@RequestBody LatestGridFormDTO latestGridFormDTO){ + ValidatorUtils.validateEntity(latestGridFormDTO); + return staffGridVisitedService.getStaffLatestGrid(latestGridFormDTO); + } + + /** + * @param staffGridVisitedFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存网格访问记录 + * @Date 2020/4/23 11:19 + **/ + @PostMapping("savestaffgridvisitedrecord") + public Result saveStaffGridVisitedRecord(@RequestBody @Valid StaffGridVisitedFormDTO staffGridVisitedFormDTO) { + return staffGridVisitedService.saveStaffGridVisitedRecord(staffGridVisitedFormDTO); + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java new file mode 100644 index 0000000000..c3fc1b9f24 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffRoleController.java @@ -0,0 +1,74 @@ +package com.epmet.controller; + +import com.epmet.commons.mybatis.entity.DataScope; +import com.epmet.commons.tools.annotation.RequirePermission; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.entity.GovStaffRoleEntity; +import com.epmet.service.GovStaffRoleService; +import com.epmet.service.StaffRoleService; +import org.springframework.beans.BeanUtils; +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.ArrayList; +import java.util.List; + +/** + * @return + * 工作人员相关api + * @Author wxz + * @Description + * @Date 2020/4/22 22:44 + **/ +@RestController +@RequestMapping("staffrole") +public class StaffRoleController { + + @Autowired + private GovStaffRoleService govStaffRoleService; + + @Autowired + private StaffRoleService staffRoleService; + + /** + * 查询工作人员具有的角色列表 + * @return + */ + @PostMapping("staffroles") + public Result> getRolesOfStaff(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { + ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetRolesOfStaff.class); + String staffId = staffRoleFormDTO.getStaffId(); + String orgId = staffRoleFormDTO.getOrgId(); + List staffRoleEntities = govStaffRoleService.listRolesByStaffId(staffId, orgId); + List staffRoleDTOS = new ArrayList<>(); + staffRoleEntities.forEach(role -> { + GovStaffRoleDTO dto = new GovStaffRoleDTO(); + BeanUtils.copyProperties(role, dto); + staffRoleDTOS.add(dto); + }); + return new Result>().ok(staffRoleDTOS); + } + + /** + * 查询拥有指定角色的用户列表 + * @param staffRoleFormDTO + * @return + */ + @PostMapping("staffsinrole") + //@RequirePermission(key = "org_staff_list") + public Result> getStaffsInRole(@RequestBody StaffRoleFormDTO staffRoleFormDTO) { + ValidatorUtils.validateEntity(staffRoleFormDTO, StaffRoleFormDTO.GetStaffsInRole.class); + String roleKey = staffRoleFormDTO.getRoleKey(); + String orgId = staffRoleFormDTO.getOrgId(); + List staffRoleDTOS = staffRoleService.listStaffsInRole(roleKey, orgId , DataScope.getDefault()); + return new Result>().ok(staffRoleDTOS); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index 89f2754a38..6c4cab6dc7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -18,9 +18,16 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; +import com.epmet.dto.form.*; +import com.epmet.dto.result.DepartInStaffListResultDTO; +import com.epmet.dto.result.StaffInfoResultDTO; import com.epmet.entity.CustomerStaffEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 政府工作人员表 * @@ -29,5 +36,87 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CustomerStaffDao extends BaseDao { - + + /** + * @param mobile + * @return java.util.List + * @Author yinzuomei + * @Description 根据手机号查询工作人员信息 + * @Date 2020/4/20 13:17 + **/ + List selectListCustomerStaffDTO(String mobile); + + /** + * @param formDTO + * @return com.epmet.dto.CustomerStaffDTO + * @Author yinzuomei + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:08 + **/ + CustomerStaffDTO selectListCustomerStaffInfo(CustomerStaffFormDTO formDTO); + + CustomerStaffDTO selectStaffInfoByUserId(CustomerStaffDTO formDTO); + + /** + * 根据userId查询网格下未被禁用的人员数量 + * @param userIdDTO + * @return + */ + GridStaffCountDTO selectGridStaffCountByUserId(UserIdDTO userIdDTO); + /** + * 根据userId查询查询网格下的用户信息 + * + * @param customerStaffGridDTOS + * @return + */ + List selectStaffGridListByUserId(List customerStaffGridDTOS); + + /** + * 根据用户ID列表获取用户信息 + * + * @param fromDTO + * @return + */ + List selectCustomerStaffList(StaffsInAgencyFromDTO fromDTO); + + /** + * @return com.epmet.entity.CustomerStaffEntity + * @param userId + * @Author yinzuomei + * @Description 根据staffid查询用户基本信息 + * @Date 2020/4/23 16:46 + **/ + CustomerStaffEntity selectByUserId(String userId); + + /** + * 工作人员列表 + * + * @param fromDTO + * @return + */ + List selectStaffList(StaffsInAgencyFromDTO fromDTO); + + /** + * 获取工作人员详情 + * @param fromDTO + * @return + */ + CustomerStaffDTO selectStaffInfo(StaffInfoFromDTO fromDTO); + + + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + List selectDepartmentStaffList(DepartmentInStaffFormDTO fromDTO); + + /** + * + * @param departmentStaffFormDTO + * @auther zxc + */ + List selectCustomerIdByUserId(AddDepartmentStaffFormDTO departmentStaffFormDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java new file mode 100644 index 0000000000..3220c70604 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.entity.GovStaffRoleEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Mapper +public interface GovStaffRoleDao extends BaseDao { + + /** + * 根据staffId查询具有的角色列表 + * @param staffId + * @param orgId + * @return + */ + List listRolesByStaffId(@Param("staffId") String staffId, @Param("orgId") String orgId); + + /** + * 获取客户机关角色列表 + * @param params + * @return + */ + List selectGovStaffRoleList(GovStaffRoleDTO params); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffAgencyVisitedDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffAgencyVisitedDao.java new file mode 100644 index 0000000000..4e55a5e731 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffAgencyVisitedDao.java @@ -0,0 +1,44 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; +import com.epmet.entity.StaffAgencyVisitedEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工作人员进入组织日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Mapper +public interface StaffAgencyVisitedDao extends BaseDao { + /** + * @param openId + * @return com.epmet.dto.result.LatestStaffWechatLoginDTO + * @Author yinzuomei + * @Description 获取当前微信上次登录的账号信息 + * @Date 2020/4/20 12:45 + **/ + StaffLatestAgencyResultDTO selectLatestStaffWechatLoginRecord(String openId); + + + StaffLatestAgencyResultDTO selectLatestCustomer(String userId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffGridVisitedDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffGridVisitedDao.java new file mode 100644 index 0000000000..6869f1a5bf --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffGridVisitedDao.java @@ -0,0 +1,44 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.StaffGridVisitedDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.entity.StaffGridVisitedEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工作人员进入网格日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Mapper +public interface StaffGridVisitedDao extends BaseDao { + + /** + * @Description 通过staffId和customerId查询当前用户上一次登录的网格信息 + * @Param LatestGridFormDTO + * @return gridId + * @Author wangc + * @Date 2020.04.23 00:40 + **/ + String selectStaffLatestGrid(LatestGridFormDTO latestGridFormDTO); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java new file mode 100644 index 0000000000..6d65865681 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java @@ -0,0 +1,52 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.entity.StaffRoleEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Mapper +public interface StaffRoleDao extends BaseDao { + /** + * 查询具有某角色的staff列表 + * @param roleKey + * @param orgId + * @return + */ + List listStaffIdsByRoleKeyAndOrgId(@Param("roleKey") String roleKey, @Param("orgId") String orgId); + + /** + * 删除工作人员权限 + * @param dto + * @return + */ + boolean delStaffRoles(StaffRoleDTO dto); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleEntity.java new file mode 100644 index 0000000000..80ee011dcd --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/GovStaffRoleEntity.java @@ -0,0 +1,61 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_staff_role") +public class GovStaffRoleEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。 + */ + private String customerId; + + /** + * 角色key + */ + private String roleKey; + + /** + * 角色名称 + */ + private String roleName; + + /** + * 角色所属体系类型:agency,department,grid + */ + private String orgType; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffAgencyVisitedEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffAgencyVisitedEntity.java new file mode 100644 index 0000000000..44c0ab2f51 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffAgencyVisitedEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 工作人员进入组织日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("staff_agency_visited") +public class StaffAgencyVisitedEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * customer_staff.userId + */ + private String staffId; + + /** + * 微信openId + */ + private String wxOpenId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 机关单位id来源于customer_agency.id + */ + private String agencyId; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffGridVisitedEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffGridVisitedEntity.java new file mode 100644 index 0000000000..9c6ffe281e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffGridVisitedEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 工作人员进入网格日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("staff_grid_visited") +public class StaffGridVisitedEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格ID + */ + private String gridId; + + /** + * customer_staff.userId + */ + private String staffId; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffRoleEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffRoleEntity.java new file mode 100644 index 0000000000..20f828a52d --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffRoleEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("staff_role") +public class StaffRoleEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + private String staffId; + + /** + * 角色ID + */ + private String roleId; + + /** + * 角色所属类型的ID。例如,机关的角色,那该字段就是所属机关的ID;部门的角色,该字段就是所属部门的ID;网格的角色,该字段就是所属网格ID + */ + private String orgId; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/GovStaffRoleExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/GovStaffRoleExcel.java new file mode 100644 index 0000000000..3448b75a7e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/GovStaffRoleExcel.java @@ -0,0 +1,68 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class GovStaffRoleExcel { + + @Excel(name = "ID") + private String id; + + @Excel(name = "客户ID。如果该角色由客户定制,其下的机关和部门都不再各自定制自己的角色,这个字段会比较有用。包括通用角色以及客户定制角色。") + private String customerId; + + @Excel(name = "角色key") + private String roleKey; + + @Excel(name = "角色名称") + private String roleName; + + @Excel(name = "角色所属体系类型:agency,department,grid") + private String orgType; + + @Excel(name = "") + private Integer delFlag; + + @Excel(name = "") + private Integer revision; + + @Excel(name = "") + private String createdBy; + + @Excel(name = "") + private Date createdTime; + + @Excel(name = "") + private String updatedBy; + + @Excel(name = "") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/StaffRoleExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/StaffRoleExcel.java new file mode 100644 index 0000000000..78def4343b --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/StaffRoleExcel.java @@ -0,0 +1,65 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class StaffRoleExcel { + + @Excel(name = "") + private String id; + + @Excel(name = "用户ID") + private String staffId; + + @Excel(name = "角色ID") + private String roleId; + + @Excel(name = "角色所属类型的ID。例如,机关的角色,那该字段就是所属机关的ID;部门的角色,该字段就是所属部门的ID;网格的角色,该字段就是所属网格ID") + private String orgId; + + @Excel(name = "") + private Integer delFlag; + + @Excel(name = "") + private Integer revision; + + @Excel(name = "") + private String createdBy; + + @Excel(name = "") + private Date createdTime; + + @Excel(name = "") + private String updatedBy; + + @Excel(name = "") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java new file mode 100644 index 0000000000..9cd6369f4f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/OperCrmFeignClient.java @@ -0,0 +1,25 @@ +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.feign.fallback.OperCrmFeignClientFallBack; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/22 10:41 + */ +@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmFeignClientFallBack.class) +public interface OperCrmFeignClient { + /** + * 获取客户信息 + * @param dto + * @return + */ + @PostMapping("/oper/crm/customer/getcostomerInfo") + Result getCustomerInfo(@RequestBody CustomerDTO dto); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java new file mode 100644 index 0000000000..d40619a04c --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/OperCrmFeignClientFallBack.java @@ -0,0 +1,21 @@ +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.CustomerDTO; +import com.epmet.feign.OperCrmFeignClient; +import org.springframework.stereotype.Component; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/4/22 10:43 + */ +@Component +public class OperCrmFeignClientFallBack implements OperCrmFeignClient { + @Override + public Result getCustomerInfo(CustomerDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getCustomerInfo", dto); + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/GovStaffRoleRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/GovStaffRoleRedis.java new file mode 100644 index 0000000000..2ad77b306a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/GovStaffRoleRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Component +public class GovStaffRoleRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java new file mode 100644 index 0000000000..47714034af --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/StaffRoleRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Component +public class StaffRoleRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index ef5d1559b9..abd130c21c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -20,7 +20,15 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.*; +import com.epmet.dto.form.*; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.result.StaffDetailResultDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; +import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.entity.CustomerStaffEntity; import java.util.List; @@ -34,72 +42,182 @@ import java.util.Map; */ public interface CustomerStaffService extends BaseService { - /** - * 默认分页 - * - * @param params - * @return PageData - * @author generator - * @date 2020-04-18 - */ - PageData page(Map params); - - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2020-04-18 - */ - List list(Map params); - - /** - * 单条查询 - * - * @param id - * @return CustomerStaffDTO - * @author generator - * @date 2020-04-18 - */ - CustomerStaffDTO get(String id); - - /** - * 默认保存 - * - * @param dto - * @return void - * @author generator - * @date 2020-04-18 - */ - void save(CustomerStaffDTO dto); - - /** - * 默认更新 - * - * @param dto - * @return void - * @author generator - * @date 2020-04-18 - */ - void update(CustomerStaffDTO dto); - - /** - * 批量删除 - * - * @param ids - * @return void - * @author generator - * @date 2020-04-18 - */ - void delete(String[] ids); - - /** - * @param phone 手机号 - * @return com.epmet.commons.tools.utils.Result - * @Author yinzuomei - * @Description 根据手机号查询政府端工作人员基本信息,校验用户是否存在 - * @Date 2020/4/18 14:07 - **/ - Result getCustsomerStaffByPhone(String phone); + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CustomerStaffDTO + * @author generator + * @date 2020-04-18 + */ + CustomerStaffDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-18 + */ + void save(CustomerStaffDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-18 + */ + void update(CustomerStaffDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-18 + */ + void delete(String[] ids); + + /** + * @param mobile 手机号 + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据手机号查询政府端工作人员基本信息,校验用户是否存在 + * @Date 2020/4/18 14:07 + **/ + Result> getCustsomerStaffByPhone(String mobile); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 根据手机号+客户id获取工作人员基本信息 + * @Date 2020/4/20 14:05 + **/ + Result getCustomerStaffInfo(CustomerStaffFormDTO formDTO); + + /** + * 根据用户ID获取工作人员基本信息 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/4/22 10:05 + **/ + Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO); + + /** + * 根据guidId查询网格下的用户信息 + * @param customerStaffGridDTOS + * @return + */ + Result> selectStaffGridListByUserId(List customerStaffGridDTOS); + + /** + * 组织首页-工作人员列表 + * @param fromDTO + * @return + */ + Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO); + + /** + * 工作人员列表 + * @param fromDTO + * @return + */ + Result> getStaffList(StaffsInAgencyFromDTO fromDTO); + + /** + * 人员添加页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + Result addStaffInit(StaffInfoFromDTO fromDTO); + + /** + * 人员编辑页面初始化 + * + * @param fromDTO 参数 + * @return Result + */ + Result editStaffInit(StaffInfoFromDTO fromDTO); + + /** + * 人员添加 + * + * @param fromDTO 参数 + * @return Result + */ + Result addStaff(StaffSubmitFromDTO fromDTO); + + /** + * 人员编辑 + * + * @param fromDTO 参数 + * @return Result + */ + Result editStaff(StaffSubmitFromDTO fromDTO); + + /** + * 人员详情 + * + * @param fromDTO 参数 + * @return Result + */ + Result getStaffDetail(StaffInfoFromDTO fromDTO); + + /** + * 人员禁用 + * + * @param fromDTO 参数 + * @return Result + */ + Result disabledStaff(StaffInfoFromDTO fromDTO); + + /** + * 根据userId查询网格下未被禁用的人员数量 + * @param userIdDTO + * @return + */ + Result selectGridStaffCountByUserId(UserIdDTO userIdDTO); + + /** + * @param fromDTO + * @return + * @Author sun + * @Description 根据客户Id及userId集合查询用户基本信息 + */ + Result> getDepartmentStaffList(DepartmentInStaffFormDTO fromDTO); + + /** + * 根据userId查询customerId + * @param: addDepartmentStaffFormDTO + * @auther: zxc + */ + Result> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java new file mode 100644 index 0000000000..80b04fa5a6 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GovStaffRoleService.java @@ -0,0 +1,109 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.entity.GovStaffRoleEntity; + +import java.util.List; +import java.util.Map; + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +public interface GovStaffRoleService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-22 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-22 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovStaffRoleDTO + * @author generator + * @date 2020-04-22 + */ + GovStaffRoleDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void save(GovStaffRoleDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void update(GovStaffRoleDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-22 + */ + void delete(String[] ids); + + /** + * 根据staffId查询具有的角色列表 + * @param staffId + * @return + */ + List listRolesByStaffId(String staffId, String orgId); + + /** + * 获取当前机关下的角色列表 + * @param dto + * @return + */ + List getGovStaffRoleList(GovStaffRoleDTO dto); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffAgencyVisitedService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffAgencyVisitedService.java new file mode 100644 index 0000000000..71622dfa4a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffAgencyVisitedService.java @@ -0,0 +1,117 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StaffAgencyVisitedDTO; +import com.epmet.dto.form.StaffLoginAgencyRecordFormDTO; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; +import com.epmet.entity.StaffAgencyVisitedEntity; + +import java.util.List; +import java.util.Map; + +/** + * 工作人员进入组织日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +public interface StaffAgencyVisitedService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-21 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-21 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return StaffAgencyVisitedDTO + * @author generator + * @date 2020-04-21 + */ + StaffAgencyVisitedDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-21 + */ + void save(StaffAgencyVisitedDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-21 + */ + void update(StaffAgencyVisitedDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-21 + */ + void delete(String[] ids); + + /** + * @param openId + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 获取当前微信上次登录的账号信息 + * @Date 2020/4/20 12:43 + **/ + Result getLatestStaffWechatLoginRecord(String openId); + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存登录日志 + * @Date 2020/4/20 14:33 + **/ + Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO formDTO); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffGridVisitedService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffGridVisitedService.java new file mode 100644 index 0000000000..e7989a7de1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffGridVisitedService.java @@ -0,0 +1,117 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.StaffGridVisitedDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.entity.StaffGridVisitedEntity; + +import java.util.List; +import java.util.Map; + +/** + * 工作人员进入网格日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +public interface StaffGridVisitedService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-21 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-21 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return StaffGridVisitedDTO + * @author generator + * @date 2020-04-21 + */ + StaffGridVisitedDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-21 + */ + void save(StaffGridVisitedDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-21 + */ + void update(StaffGridVisitedDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-21 + */ + void delete(String[] ids); + + /** + * @Description 得到工作人员上次登录的网格 + * @Param LatestGridFormDTO -> staffId ; customerId + * @return Result + * @Author wangc + * @Date 2020.04.23 00:28 + **/ + Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO); + + /** + * @param staffGridVisitedFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存网格访问记录 + * @Date 2020/4/23 11:20 + **/ + Result saveStaffGridVisitedRecord(StaffGridVisitedFormDTO staffGridVisitedFormDTO); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java new file mode 100644 index 0000000000..9c6af5321e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffRoleService.java @@ -0,0 +1,111 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.entity.DataScope; +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.entity.StaffRoleEntity; + +import java.util.List; +import java.util.Map; + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +public interface StaffRoleService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-22 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-22 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return StaffRoleDTO + * @author generator + * @date 2020-04-22 + */ + StaffRoleDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void save(StaffRoleDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void update(StaffRoleDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-22 + */ + void delete(String[] ids); + + /** + * 查询具有某角色的staff列表 + * @param roleKey + * @param orgId + * @return + */ + List listStaffsInRole(String roleKey, String orgId, DataScope dataScope); + + /** + * 清空工作人员权限 + * @param dto + */ + void clearStaffRoles(StaffRoleDTO dto); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiRegisterVisitService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiRegisterVisitService.java index 579cb1e1c3..414706ee2c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiRegisterVisitService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserResiRegisterVisitService.java @@ -19,12 +19,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; 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.UserResiInfoDTO; import com.epmet.dto.UserResiRegisterVisitDTO; import com.epmet.dto.form.ResiRegisterFormDTO; -import com.epmet.dto.form.UserResiInfoFormDTO; import com.epmet.dto.form.VerificationCodeFormDTO; import com.epmet.dto.result.ResiRegisterResultDTO; import com.epmet.entity.UserResiRegisterVisitEntity; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 7470edc96d..f5a2d154b1 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -19,18 +19,41 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.entity.DataScope; 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.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerStaffConstant; import com.epmet.constant.UserConstant; +import com.epmet.constant.UserRoleConstant; import com.epmet.dao.CustomerStaffDao; +import com.epmet.dto.*; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.dto.form.*; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.StaffGridListDTO; +import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.StaffDetailResultDTO; +import com.epmet.dto.result.DepartInStaffListResultDTO; +import com.epmet.dto.result.StaffInfoResultDTO; +import com.epmet.dto.result.StaffInitResultDTO; +import com.epmet.dto.result.StaffRoleResultDTO; import com.epmet.entity.CustomerStaffEntity; +import com.epmet.entity.GovStaffRoleEntity; +import com.epmet.entity.StaffRoleEntity; +import com.epmet.entity.UserEntity; import com.epmet.redis.CustomerStaffRedis; import com.epmet.service.CustomerStaffService; +import com.epmet.service.GovStaffRoleService; +import com.epmet.service.StaffRoleService; +import com.epmet.service.UserService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,6 +64,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 政府工作人员表 @@ -48,82 +72,306 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-04-18 */ +@Slf4j @Service public class CustomerStaffServiceImpl extends BaseServiceImpl implements CustomerStaffService { - private Logger logger = LogManager.getLogger(getClass()); - @Autowired - private CustomerStaffRedis customerStaffRedis; + private Logger logger = LogManager.getLogger(getClass()); + @Autowired + private CustomerStaffRedis customerStaffRedis; + @Autowired + private GovStaffRoleService govStaffRoleService; + @Autowired + private UserService userService; + @Autowired + private StaffRoleService staffRoleService; + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerStaffDTO.class); + } - @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, CustomerStaffDTO.class); - } + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); + return ConvertUtils.sourceToTarget(entityList, CustomerStaffDTO.class); + } - return ConvertUtils.sourceToTarget(entityList, CustomerStaffDTO.class); - } + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + return wrapper; + } - return wrapper; - } + @Override + public CustomerStaffDTO get(String id) { + CustomerStaffEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CustomerStaffDTO.class); + } - @Override - public CustomerStaffDTO get(String id) { - CustomerStaffEntity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, CustomerStaffDTO.class); - } + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CustomerStaffDTO dto) { + CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); + insert(entity); + } - @Override - @Transactional(rollbackFor = Exception.class) - public void save(CustomerStaffDTO dto) { - CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); - insert(entity); - } + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CustomerStaffDTO dto) { + CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); + updateById(entity); + } - @Override - @Transactional(rollbackFor = Exception.class) - public void update(CustomerStaffDTO dto) { - CustomerStaffEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStaffEntity.class); - updateById(entity); - } + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String[] ids) { - // 逻辑删除(@TableLogic 注解) - baseDao.deleteBatchIds(Arrays.asList(ids)); - } + @Override + public Result> getCustsomerStaffByPhone(String mobile) { + //判断用户是否存在 + List customerStaffDTOList = baseDao.selectListCustomerStaffDTO(mobile); + if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) { + logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", mobile, EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); + return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); + } + return new Result>().ok(customerStaffDTOList); + } + + + @Override + public Result getCustomerStaffInfo(CustomerStaffFormDTO formDTO) { + CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(formDTO); + if (null == customerStaffDTO) { + logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", formDTO.getMobile(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); + return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); + } + //判断用户是否已被禁用 + if (null != customerStaffDTO && UserConstant.DISABLED.equals(customerStaffDTO.getEnableFlag())) { + logger.error(String.format("根据手机号查询用户异常,手机号:[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), EpmetErrorCode.GOV_STAFF_DISABLED.getCode(), EpmetErrorCode.GOV_STAFF_DISABLED.getMsg())); + return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode()); + } + return new Result().ok(customerStaffDTO); + } + + @Override + public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { + CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfoByUserId(formDTO); + return new Result().ok(customerStaffDTO); + } + + @Override + public Result> selectStaffGridListByUserId(List customerStaffGridDTOS) { + List staffGridListDTOS = baseDao.selectStaffGridListByUserId(customerStaffGridDTOS); + return new Result>().ok(staffGridListDTOS); + } + @Override + public Result> getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { + List list = baseDao.selectCustomerStaffList(fromDTO); + return new Result>().ok(list); + } + + @Override + public Result> getStaffList(StaffsInAgencyFromDTO fromDTO) { + List list = baseDao.selectStaffList(fromDTO); + return new Result>().ok(list); + } + + @Override + public Result addStaffInit(StaffInfoFromDTO fromDTO) { + StaffInitResultDTO resultDTO = new StaffInitResultDTO(); + GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO(); + govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId()); + List roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO); + if (null == roleList || roleList.size() == 0) { + return new Result().ok(null); + } + List staffRoleList = roleList.stream().map(p -> { + StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO(); + staffRoleResultDTO.setRoleId(p.getId()); + staffRoleResultDTO.setRoleName(p.getRoleName()); + return staffRoleResultDTO; + }).collect(Collectors.toList()); + resultDTO.setRoleList(staffRoleList); + return new Result().ok(resultDTO); + } + + @Override + public Result editStaffInit(StaffInfoFromDTO fromDTO) { + StaffInitResultDTO resultDTO = new StaffInitResultDTO(); + //获取工作人员信息 + CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO); + if (null == customerStaffDTO) { + log.error("工作人员不存在"); + } + resultDTO.setStaffId(customerStaffDTO.getUserId()); + resultDTO.setName(customerStaffDTO.getRealName()); + resultDTO.setGender(customerStaffDTO.getGender()); + resultDTO.setMobile(customerStaffDTO.getMobile()); + resultDTO.setWorkType(customerStaffDTO.getWorkType()); + //获取角色列表 + GovStaffRoleDTO govStaffRoleDTO = new GovStaffRoleDTO(); + govStaffRoleDTO.setCustomerId(fromDTO.getCustomerId()); + List roleList = govStaffRoleService.getGovStaffRoleList(govStaffRoleDTO); + //获取工作人员角色 + List staffRoles = govStaffRoleService.listRolesByStaffId(fromDTO.getStaffId(), fromDTO.getAgencyId()); + List staffRoleList = roleList.stream().map(p -> { + StaffRoleResultDTO staffRoleResultDTO = new StaffRoleResultDTO(); + staffRoleResultDTO.setRoleId(p.getId()); + staffRoleResultDTO.setRoleName(p.getRoleName()); + staffRoleResultDTO.setSelected(false); + return staffRoleResultDTO; + }).collect(Collectors.toList()); + + staffRoleList.forEach(role -> staffRoles.forEach(staffRole -> { + if (role.getRoleId().equals(staffRole.getId())) { + role.setSelected(true); + } + })); + resultDTO.setRoleList(staffRoleList); + + return new Result().ok(resultDTO); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result addStaff(StaffSubmitFromDTO fromDTO) { + //USER表插入数据 + UserEntity userEntity = new UserEntity(); + userEntity.setFromApp(fromDTO.getApp()); + userEntity.setFromClient(fromDTO.getClient()); + userService.insert(userEntity); + //Customer_Staff表插入数据 + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setUserId(userEntity.getId()); + staffEntity.setRealName(fromDTO.getName()); + staffEntity.setMobile(fromDTO.getMobile()); + staffEntity.setActiveFlag(CustomerStaffConstant.INACTIVE); + staffEntity.setGender(fromDTO.getGender()); + staffEntity.setWorkType(fromDTO.getWorkType()); + staffEntity.setEnableFlag(CustomerStaffConstant.ENABLE); + baseDao.insert(staffEntity); + + //工作人员角色关联表 + fromDTO.getRoles().forEach(role -> { + StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); + staffRoleEntity.setStaffId(userEntity.getId()); + staffRoleEntity.setRoleId(role); + staffRoleEntity.setOrgId(fromDTO.getAgencyId()); + staffRoleService.insert(staffRoleEntity); + }); + + return new Result(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result editStaff(StaffSubmitFromDTO fromDTO) { + CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); + //Customer_Staff表插入数据 + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setId(customerStaffEntity.getId()); + staffEntity.setRealName(fromDTO.getName()); + staffEntity.setMobile(fromDTO.getMobile()); + staffEntity.setGender(fromDTO.getGender()); + staffEntity.setWorkType(fromDTO.getWorkType()); + baseDao.updateById(staffEntity); + + //清空权限关联 + StaffRoleDTO staffRoleDTO = new StaffRoleDTO(); + staffRoleDTO.setStaffId(fromDTO.getStaffId()); + staffRoleDTO.setOrgId(fromDTO.getAgencyId()); + staffRoleService.clearStaffRoles(staffRoleDTO); + //重新添加角色关联 + fromDTO.getRoles().forEach(role -> { + StaffRoleEntity staffRoleEntity = new StaffRoleEntity(); + staffRoleEntity.setStaffId(fromDTO.getStaffId()); + staffRoleEntity.setRoleId(role); + staffRoleEntity.setOrgId(fromDTO.getAgencyId()); + staffRoleService.insert(staffRoleEntity); + }); + return new Result(); + } + + @Override + public Result getStaffDetail(StaffInfoFromDTO fromDTO) { + StaffDetailResultDTO resultDTO = new StaffDetailResultDTO(); + //获取工作人员信息 + CustomerStaffDTO customerStaffDTO = baseDao.selectStaffInfo(fromDTO); + resultDTO.setStaffId(customerStaffDTO.getUserId()); + resultDTO.setName(customerStaffDTO.getRealName()); + resultDTO.setMobile(customerStaffDTO.getMobile()); + resultDTO.setHeadPhoto(customerStaffDTO.getHeadPhoto()); + resultDTO.setGender(customerStaffDTO.getGender()); + resultDTO.setActiveFlag(customerStaffDTO.getActiveFlag()); + resultDTO.setActiveTime(customerStaffDTO.getActiveTime()); + resultDTO.setEnableFlag(customerStaffDTO.getEnableFlag()); + + //获取工作人员角色 + List staffRoles = govStaffRoleService.listRolesByStaffId(fromDTO.getStaffId(), fromDTO.getAgencyId()); + List roles = staffRoles.stream().map(GovStaffRoleEntity::getRoleName).collect(Collectors.toList()); + resultDTO.setRoles(roles); + return new Result().ok(resultDTO); + } + + @Override + public Result disabledStaff(StaffInfoFromDTO fromDTO) { + CustomerStaffEntity customerStaffEntity = baseDao.selectByUserId(fromDTO.getStaffId()); + CustomerStaffEntity staffEntity = new CustomerStaffEntity(); + staffEntity.setId(customerStaffEntity.getId()); + staffEntity.setEnableFlag(CustomerStaffConstant.DISABLED); + baseDao.updateById(staffEntity); + return new Result(); + } + + /** + * 根据userId查询网格下未被禁用的人员数量 + * @param userIdDTO + * @return + */ @Override - public Result getCustsomerStaffByPhone(String phone) { - //判断用户是否存在 - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(phone), FieldConstant.MOBILE, phone); - List customerStaffEntityList = baseDao.selectList(wrapper); - if (null == customerStaffEntityList || customerStaffEntityList.size() == 0) { - logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]",phone,EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(),EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg())); - return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode()); - } - //判断用户是否已被禁用 - CustomerStaffEntity customerStaff = customerStaffEntityList.get(0); - if (UserConstant.DISABLED.equals(customerStaff.getEnableFlag())) { - logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]",phone,EpmetErrorCode.GOV_STAFF_DISABLED.getCode(),EpmetErrorCode.GOV_STAFF_DISABLED.getMsg())); - return new Result().error(EpmetErrorCode.GOV_STAFF_DISABLED.getCode()); - } - CustomerStaffDTO customerStaffDTO=ConvertUtils.sourceToTarget(customerStaff, CustomerStaffDTO.class); - return new Result().ok(customerStaffDTO); + public Result selectGridStaffCountByUserId(UserIdDTO userIdDTO) { + Result gridStaffCountDTOResult = new Result(); + GridStaffCountDTO gridStaffCountDTO = baseDao.selectGridStaffCountByUserId(userIdDTO); + gridStaffCountDTOResult.setData(gridStaffCountDTO); + return gridStaffCountDTOResult; } + @Override + public Result> getDepartmentStaffList(DepartmentInStaffFormDTO formDTO) { + //1:根据userId集合查询人员基本信息 + List staffList = baseDao.selectDepartmentStaffList(formDTO); + //2:根据部门Id查询部门下是领导角色的用户 + StaffRoleFormDTO staffRoleFormDTO = new StaffRoleFormDTO(); + staffRoleFormDTO.setOrgId(formDTO.getDepartmentId()); + staffRoleFormDTO.setRoleKey(UserRoleConstant.DEPT_LEADER); + List staffRoleDTOS = staffRoleService.listStaffsInRole(UserRoleConstant.DEPT_LEADER, formDTO.getDepartmentId(), DataScope.getDefault()); + staffRoleDTOS.forEach(roleDto -> { + staffList.stream().filter(staffDto -> + roleDto.getStaffId().equals(staffDto.getStaffId())).findAny().ifPresent(result -> + result.setRoleName(roleDto.getRoleName())); + }); + return new Result>().ok(staffList); + } + + /** + * + * @param: addDepartmentStaffFormDTO + * @auther: zxc + */ + @Override + public Result> selectCustomerIdByUserId(AddDepartmentStaffFormDTO addDepartmentStaffFormDTO) { + return new Result>().ok(baseDao.selectCustomerIdByUserId(addDepartmentStaffFormDTO)); + } + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java new file mode 100644 index 0000000000..cd26eaa0a4 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java @@ -0,0 +1,118 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.GovStaffRoleDao; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.entity.GovStaffRoleEntity; +import com.epmet.redis.GovStaffRoleRedis; +import com.epmet.service.GovStaffRoleService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 政府端角色表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Service +public class GovStaffRoleServiceImpl extends BaseServiceImpl implements GovStaffRoleService { + + @Autowired + private GovStaffRoleRedis govStaffRoleRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovStaffRoleDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovStaffRoleDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public GovStaffRoleDTO get(String id) { + GovStaffRoleEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, GovStaffRoleDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovStaffRoleDTO dto) { + GovStaffRoleEntity entity = ConvertUtils.sourceToTarget(dto, GovStaffRoleEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovStaffRoleDTO dto) { + GovStaffRoleEntity entity = ConvertUtils.sourceToTarget(dto, GovStaffRoleEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 根据staffId查询具有的角色列表 + * @param staffId + * @return + */ + @Override + public List listRolesByStaffId(String staffId, String orgId) { + return baseDao.listRolesByStaffId(staffId, orgId); + } + + @Override + public List getGovStaffRoleList(GovStaffRoleDTO dto) { + return baseDao.selectGovStaffRoleList(dto); + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java new file mode 100644 index 0000000000..11fb4702ca --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffAgencyVisitedServiceImpl.java @@ -0,0 +1,130 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.StaffAgencyVisitedDao; +import com.epmet.dto.StaffAgencyVisitedDTO; +import com.epmet.dto.form.StaffLoginAgencyRecordFormDTO; +import com.epmet.dto.result.StaffLatestAgencyResultDTO; +import com.epmet.entity.StaffAgencyVisitedEntity; +import com.epmet.feign.OperCrmFeignClient; +import com.epmet.service.CustomerStaffService; +import com.epmet.service.StaffAgencyVisitedService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 工作人员进入组织日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Service +public class StaffAgencyVisitedServiceImpl extends BaseServiceImpl implements StaffAgencyVisitedService { + private static final Logger logger = LoggerFactory.getLogger(StaffAgencyVisitedServiceImpl.class); + + @Autowired + private CustomerStaffService customerStaffService; + @Autowired + private OperCrmFeignClient operCrmFeignClient; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, StaffAgencyVisitedDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, StaffAgencyVisitedDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public StaffAgencyVisitedDTO get(String id) { + StaffAgencyVisitedEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, StaffAgencyVisitedDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(StaffAgencyVisitedDTO dto) { + StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffAgencyVisitedEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(StaffAgencyVisitedDTO dto) { + StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffAgencyVisitedEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public Result getLatestStaffWechatLoginRecord(String openId) { + if (StringUtils.isBlank(openId)) { + logger.error("openId 不能为空"); + return new Result(); + } + StaffLatestAgencyResultDTO latestStaffWechatLoginDTO = baseDao.selectLatestStaffWechatLoginRecord(openId); + return new Result().ok(latestStaffWechatLoginDTO); + } + + @Override + public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO formDTO) { + StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(formDTO, StaffAgencyVisitedEntity.class); + insert(entity); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffGridVisitedServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffGridVisitedServiceImpl.java new file mode 100644 index 0000000000..5b0ab6bf60 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffGridVisitedServiceImpl.java @@ -0,0 +1,147 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.GridVisitedConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.StaffGridVisitedDao; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.StaffGridVisitedDTO; +import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.entity.StaffGridVisitedEntity; +import com.epmet.feign.GovOrgFeignClient; +import com.epmet.service.StaffGridVisitedService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 工作人员进入网格日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-21 + */ +@Service +public class StaffGridVisitedServiceImpl extends BaseServiceImpl implements StaffGridVisitedService { + + private static final Logger logger = LoggerFactory.getLogger(StaffGridVisitedServiceImpl.class); + + @Autowired + private GovOrgFeignClient govOrgFeignClient; + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, StaffGridVisitedDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, StaffGridVisitedDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public StaffGridVisitedDTO get(String id) { + StaffGridVisitedEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, StaffGridVisitedDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(StaffGridVisitedDTO dto) { + StaffGridVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffGridVisitedEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(StaffGridVisitedDTO dto) { + StaffGridVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffGridVisitedEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + + @Override + public Result saveStaffGridVisitedRecord(StaffGridVisitedFormDTO staffGridVisitedFormDTO) { + StaffGridVisitedEntity entity = ConvertUtils.sourceToTarget(staffGridVisitedFormDTO, StaffGridVisitedEntity.class); + insert(entity); + return new Result(); + } + + @Override + public Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO) { + + CustomerGridByUserIdResultDTO gridResult = new CustomerGridByUserIdResultDTO(); + String gridId = baseDao.selectStaffLatestGrid(latestGridFormDTO); + if(StringUtils.isNotBlank(gridId)){ + CustomerGridFormDTO param = new CustomerGridFormDTO(); + param.setGridId(gridId); + Result gridInfoResult = + govOrgFeignClient.getCustomerGridByGridId(param); + if(gridInfoResult.success() && null != gridInfoResult.getData() && StringUtils.isNotBlank(gridInfoResult.getData().getId())){ + gridResult.setAgencyId(gridInfoResult.getData().getPid()); + gridResult.setGridId(gridId); + gridResult.setGridName(gridInfoResult.getData().getGridName()); + }else{ + logger.warn(GridVisitedConstant.QUERY_EXCEPTION); + } + } + + return new Result().ok(gridResult); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java new file mode 100644 index 0000000000..180521ebe3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffRoleServiceImpl.java @@ -0,0 +1,125 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

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

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

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.annotation.DataFilter; +import com.epmet.commons.mybatis.entity.DataScope; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.StaffRoleDao; +import com.epmet.dto.StaffRoleDTO; +import com.epmet.dto.result.GovStaffRoleResultDTO; +import com.epmet.entity.StaffRoleEntity; +import com.epmet.redis.StaffRoleRedis; +import com.epmet.service.StaffRoleService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 工作人员-角色关系表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Service +public class StaffRoleServiceImpl extends BaseServiceImpl implements StaffRoleService { + + @Autowired + private StaffRoleRedis staffRoleRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, StaffRoleDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, StaffRoleDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public StaffRoleDTO get(String id) { + StaffRoleEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, StaffRoleDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(StaffRoleDTO dto) { + StaffRoleEntity entity = ConvertUtils.sourceToTarget(dto, StaffRoleEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(StaffRoleDTO dto) { + StaffRoleEntity entity = ConvertUtils.sourceToTarget(dto, StaffRoleEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 查询具有某角色的staff列表 + * @param roleKey + * @param orgId + * @return + */ + @Override + //@DataFilter + public List listStaffsInRole(String roleKey, String orgId, DataScope dataScope) { + return baseDao.listStaffIdsByRoleKeyAndOrgId(roleKey, orgId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void clearStaffRoles(StaffRoleDTO dto) { + baseDao.delStaffRoles(dto); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java index 04fe972274..b50daab444 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffWechatServiceImpl.java @@ -24,18 +24,23 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.UserConstant; +import com.epmet.dao.CustomerStaffDao; import com.epmet.dao.StaffWechatDao; import com.epmet.dto.StaffWechatDTO; import com.epmet.dto.form.StaffWechatFormDTO; +import com.epmet.entity.CustomerStaffEntity; import com.epmet.entity.StaffWechatEntity; import com.epmet.service.StaffWechatService; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +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.Date; import java.util.List; import java.util.Map; @@ -48,7 +53,8 @@ import java.util.Map; @Service public class StaffWechatServiceImpl extends BaseServiceImpl implements StaffWechatService { private Logger logger = LogManager.getLogger(getClass()); - + @Autowired + private CustomerStaffDao customerStaffDao; @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -119,6 +125,14 @@ public class StaffWechatServiceImpl extends BaseServiceImpl - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml new file mode 100644 index 0000000000..14fe8a45ca --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffAgencyVisitedDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffAgencyVisitedDao.xml new file mode 100644 index 0000000000..82bc2cace3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffAgencyVisitedDao.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffGridVisitedDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffGridVisitedDao.xml new file mode 100644 index 0000000000..73978e23f3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffGridVisitedDao.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml new file mode 100644 index 0000000000..7ad99146cb --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + update + staff_role + set DEL_FLAG = '1' + where STAFF_ID = #{staffId} + and ORG_ID = #{orgId} + and DEL_FLAG = '0' + + + + + + \ No newline at end of file