diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 9d1876810e..be588da1e1 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 + @@ -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..0539be499d --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java @@ -0,0 +1,81 @@ +package com.epmet.controller; + +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.GovWxmpGetOrgsFormDTO; +import com.epmet.dto.form.SendSmsCodeFormDTO; +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; + +/** + * @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(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/getorgs") + public Result getorgs(GovWxmpGetOrgsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return govLoginService.getorgs(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(GovWxmpEnteOrgFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return govLoginService.enterOrg(formDTO); + } + +} + 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..dc876a1ccc 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java @@ -1,15 +1,12 @@ package com.epmet.controller; -import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.security.dto.TokenDto; 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; @@ -95,34 +92,8 @@ public class LoginController { * @Date 2020/3/18 22:43 **/ @PostMapping(value = "logout") - public Result logout(@LoginUser TokenDto tokenDto, HttpServletRequest request) { + public Result logout(TokenDto tokenDto, HttpServletRequest request) { //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..8655268c8e --- /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 orgId; +} + 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..72c43cbfa7 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description 政府端小程序根据wxCode获取上一次登录信息,返回token + * @Author yinzuomei + * @Date 2020/4/20 11:20 + */ +@Data +public class GovWxmpFormDTO extends LoginCommonFormDTO{ + 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/LoginByPhoneFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpGetOrgsFormDTO.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/GovWxmpGetOrgsFormDTO.java index 591e6063b1..b2674f3277 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpGetOrgsFormDTO.java @@ -6,22 +6,18 @@ 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 GovWxmpGetOrgsFormDTO 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/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/feign/EpmetUserFeignClient.java b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 5b339e18ce..45fe847c49 100644 --- a/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -5,9 +5,8 @@ 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.LatestStaffWechatLoginResultDTO; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; import com.epmet.feign.fallback.EpmetUserFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; @@ -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 @@ -76,4 +77,34 @@ public interface EpmetUserFeignClient { **/ @PostMapping(value = "epmetuser/staffwechat/savestaffwechat", consumes = MediaType.APPLICATION_JSON_VALUE) 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/staffloginhistory/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/staffloginhistory/saveStaffLoginRecord", consumes = MediaType.APPLICATION_JSON_VALUE) + Result saveStaffLoginRecord(StaffLoginHistoryFormDTO 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..0d3fe7c566 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -0,0 +1,23 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.StaffGridInfoFormDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; +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 { + @PostMapping(value = "getStaffGridInfo",consumes = MediaType.APPLICATION_JSON_VALUE) + Result> getStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO); +} 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..9126cf63b8 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.LatestStaffWechatLoginResultDTO; import com.epmet.dto.result.PasswordLoginUserInfoResultDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; +import java.util.List; + /** * @Description * @Author yinzuomei @@ -37,7 +38,7 @@ 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); } @@ -46,4 +47,19 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { 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(StaffLoginHistoryFormDTO 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..94a235f3ec --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java @@ -0,0 +1,25 @@ +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.StaffGridInfoFormDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; +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> getStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffGridInfo", staffGridInfoFormDTO); + } +} + 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..0ec9158dae 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,10 @@ 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.GovWxmpGetOrgsFormDTO; import com.epmet.dto.form.SendSmsCodeFormDTO; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -65,7 +66,7 @@ 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); } @@ -77,8 +78,8 @@ public class CaptchaRedis { * @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(GovWxmpGetOrgsFormDTO formDTO) { + String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_GOV, LoginConstant.CLIENT_WXMP, formDTO.getMobile()); 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..b805bbf217 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/service/GovLoginService.java @@ -0,0 +1,51 @@ +package com.epmet.service; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.GovWxmpEnteOrgFormDTO; +import com.epmet.dto.form.GovWxmpFormDTO; +import com.epmet.dto.form.GovWxmpGetOrgsFormDTO; +import com.epmet.dto.form.SendSmsCodeFormDTO; +import com.epmet.dto.result.UserTokenResultDTO; + +/** + * @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 getorgs(GovWxmpGetOrgsFormDTO 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); +} 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..f41e0b81d9 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -0,0 +1,264 @@ +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.security.dto.GovTokenDto; +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.LatestStaffWechatLoginResultDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; +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.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 getorgs(GovWxmpGetOrgsFormDTO 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); + if (!formDTO.getSmsCode().equals(rightSmsCode)) { + return new Result().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + //3、TODO返回组织树 + return new Result(); + } + + @Override + public Result loginByWxCode(GovWxmpFormDTO formDTO) { + //1、解析微信用户 + WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode()); + 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()); + } + LatestStaffWechatLoginResultDTO latestStaffWechatLoginDTO = latestStaffWechat.getData(); + //2、记录staff_wechat + this.savestaffwechat(latestStaffWechatLoginDTO.getStaffId(), wxMaJscode2SessionResult.getOpenid()); + //3、记录登录日志 + this.saveStaffLoginRecord(latestStaffWechatLoginDTO); + //4、获取用户token + String token = this.generateGovWxmpToken(latestStaffWechatLoginDTO.getStaffId()); + //5、保存到redis + this.saveGovTokenDto(latestStaffWechatLoginDTO.getOrgId(), latestStaffWechatLoginDTO.getGridId(), latestStaffWechatLoginDTO.getStaffId(), wxMaJscode2SessionResult, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return new Result().ok(userTokenResultDTO); + } + + //保存登录日志 + private Result saveStaffLoginRecord(LatestStaffWechatLoginResultDTO latestStaffWechatLoginDTO) { + StaffLoginHistoryFormDTO staffLoginHistoryFormDTO = new StaffLoginHistoryFormDTO(); + staffLoginHistoryFormDTO.setCustomerId(latestStaffWechatLoginDTO.getCustomerId()); + staffLoginHistoryFormDTO.setStaffId(latestStaffWechatLoginDTO.getStaffId()); + staffLoginHistoryFormDTO.setWxOpenId(latestStaffWechatLoginDTO.getWxOpenId()); + staffLoginHistoryFormDTO.setMobile(latestStaffWechatLoginDTO.getMobile()); + staffLoginHistoryFormDTO.setOrgId(latestStaffWechatLoginDTO.getOrgId()); + staffLoginHistoryFormDTO.setGridId(latestStaffWechatLoginDTO.getGridId()); + Result staffLoginRecordResult = epmetUserFeignClient.saveStaffLoginRecord(staffLoginHistoryFormDTO); + 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、记录登录日志 + StaffGridInfoFormDTO staffGridInfoFormDTO = new StaffGridInfoFormDTO(); + staffGridInfoFormDTO.setCustomerId(formDTO.getCustomerId()); + staffGridInfoFormDTO.setOrgId(formDTO.getOrgId()); + staffGridInfoFormDTO.setStaffId(customerStaff.getUserId()); + Result> staffGridInfoListResult = govOrgFeignClient.getStaffGridInfo(staffGridInfoFormDTO); + String gridId = null; + if (staffGridInfoListResult.success() && null != staffGridInfoListResult.getData() && staffGridInfoListResult.getData().size() > 0) { + gridId = staffGridInfoListResult.getData().get(0).getGridId(); + } + this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid(), gridId); + UserTokenResultDTO userTokenResultDTO = this.getAuthorizationInfo(formDTO.getOrgId(), gridId, customerStaff.getUserId(), wxMaJscode2SessionResult); + return new Result().ok(userTokenResultDTO); + } + + //保存登录日志 + private Result saveStaffLoginRecord(GovWxmpEnteOrgFormDTO formDTO, String staffId, String openId, String grid) { + StaffLoginHistoryFormDTO staffLoginHistoryFormDTO = new StaffLoginHistoryFormDTO(); + staffLoginHistoryFormDTO.setCustomerId(formDTO.getCustomerId()); + staffLoginHistoryFormDTO.setStaffId(staffId); + staffLoginHistoryFormDTO.setWxOpenId(openId); + staffLoginHistoryFormDTO.setMobile(formDTO.getMobile()); + staffLoginHistoryFormDTO.setOrgId(formDTO.getOrgId()); + staffLoginHistoryFormDTO.setGridId(grid); + Result staffLoginRecordResult = epmetUserFeignClient.saveStaffLoginRecord(staffLoginHistoryFormDTO); + return staffLoginRecordResult; + } + + private UserTokenResultDTO getAuthorizationInfo(String orgId, + String gridId, + String staffId, + WxMaJscode2SessionResult wxMaJscode2SessionResult) { + //1、获取用户token + String token = this.generateGovWxmpToken(staffId); + //2、保存到redis + this.saveGovTokenDto(orgId, gridId, staffId, wxMaJscode2SessionResult, token); + UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); + userTokenResultDTO.setToken(token); + return userTokenResultDTO; + } + + /** + * @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("staffId", staffId); + String token = jwtTokenUtils.createToken(map); + logger.info("app:" + LoginConstant.APP_GOV + ";client:" + LoginConstant.CLIENT_WXMP + ";staffId:" + staffId + ";生成token[" + token + "]"); + return token; + } + + /** + * @Description 生成token + * @Date 2020/4/18 23:04 + **/ + private String saveGovTokenDto(String orgId, + String gridId, + 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.setStaffId(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.setOrgId(orgId); + govTokenDto.setGridId(gridId); + cpUserDetailRedis.set(govTokenDto, expire); + logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); + return token; + } +} + 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..225e2520fb 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; - /** * 居民端微信小程序登录 * @@ -327,94 +316,6 @@ public class LoginServiceImpl implements LoginService { 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-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/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index a77e4f3130..230c53fbc8 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 @@ -14,6 +14,7 @@ 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, "党员注册失败"), 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..08d9954eda --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java @@ -0,0 +1,80 @@ +package com.epmet.commons.tools.security.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 政府端登录信息 + * @Author yinzuomei + * @Date 2020/4/20 11:01 + */ +@Data +public class GovTokenDto implements Serializable { + /** + * 政府端:gov、居民端:resi、运营端:oper + */ + private String app; + + /** + * PC端:web、微信小程序:wxmp + */ + private String client; + + /** + * 用户ID + */ + private String staffId; + + /** + * sessionKey + */ + private String sessionKey; + + /** + * openId + */ + private String openId; + + /** + * unionId + */ + private String unionId; + + /** + * token字符串 + */ + private String token; + + /** + * 过期时间戳 + */ + private Long expireTime; + + /** + * 最后一次更新时间 + */ + private long updateTime; + + /** + * 当前登录的组织id + */ + private String orgId; + + /** + * 待定 + */ + private String orgIdPath; + + /** + * 待定 + */ + private String gridId; + + /** + * 待定 + */ + private List deptIdList; +} + 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/utils/CpUserDetailRedis.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java index f49c9ddcb5..100c583a01 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; @@ -99,4 +100,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.getStaffId()); + //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 a451ebf0b2..eed74d589d 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -108,53 +108,53 @@ - - 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 + - http://127.0.0.1:8096 - + + lb://resi-partymember-server diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffGridInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffGridInfoFormDTO.java new file mode 100644 index 0000000000..85b321f25a --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffGridInfoFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 根据用户选择的组织,查询用户与网格的关系列表 + * @Author yinzuomei + * @Date 2020/4/20 15:29 + */ +@Data +public class StaffGridInfoFormDTO implements Serializable { + /** + * 用户选择的组织所属的id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 用户选择的要进入的组织(根组织id) + */ + @NotBlank(message = "组织id不能为空") + private String orgId; + + @NotBlank(message = "staffId不能为空") + private String staffId; +} + diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffGridInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffGridInfoResultDTO.java new file mode 100644 index 0000000000..e636db75ee --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffGridInfoResultDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 根据用户选择的组织,查询用户与网格的关系列表 + * @Author yinzuomei + * @Date 2020/4/20 15:22 + */ +@Data +public class StaffGridInfoResultDTO implements Serializable { + /** + * ID 唯一标识 + */ + private String gridId; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格名称 + */ + private String gridName; + + /** + * 所属组织机构ID(customer_organization.id) + */ + private String pid; + + /** + * 所有上级组织ID + */ + private String pids; +} + 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..8163a30c15 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,14 @@ 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.form.StaffGridInfoFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; -import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; import com.epmet.excel.CustomerGridExcel; import com.epmet.service.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -124,4 +126,17 @@ public class CustomerGridController { CustomerGridDTO data = customerGridService.get(id); return new Result().ok(data); } + + /** + * @param staffGridInfoFormDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 根据用户选择的组织,查询用户与网格的关系列表 + * @Date 2020/4/20 15:34 + **/ + @PostMapping(value = "getStaffGridInfo") + public Result> getStaffGridInfo(@RequestBody StaffGridInfoFormDTO staffGridInfoFormDTO) { + ValidatorUtils.validateEntity(staffGridInfoFormDTO); + return customerGridService.listStaffGridInfo(staffGridInfoFormDTO); + } } 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..b42077b396 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,13 +18,14 @@ 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.dto.CustomerGridDTO; import com.epmet.dto.form.CustomerGridFormDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.form.StaffGridInfoFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; import com.epmet.entity.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -61,4 +62,13 @@ public interface CustomerGridDao extends BaseDao { List selectRestGridWithoutGivenAreaCode(Map paramsMap); CustomerGridDTO getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO); + + /** + * @param staffGridInfoFormDTO + * @return java.util.List + * @Author yinzuomei + * @Description 查询工作人员绑定的网格列表 + * @Date 2020/4/20 15:36 + **/ + List selectListStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO); } \ 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..d8728c39dd 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 @@ -23,7 +23,9 @@ 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.StaffGridInfoFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; import com.epmet.entity.CustomerGridEntity; import java.util.List; @@ -113,4 +115,13 @@ public interface CustomerGridService extends BaseService { * @date 2020-03-17 */ Result getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO); + + /** + * @param staffGridInfoFormDTO + * @return com.epmet.commons.tools.utils.Result> + * @Author yinzuomei + * @Description 根据用户选择的组织,查询用户与网格的关系列表 + * @Date 2020/4/20 15:35 + **/ + Result> listStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO); } \ 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..d4e61df8b1 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 @@ -28,7 +28,9 @@ 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.form.StaffGridInfoFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.dto.result.StaffGridInfoResultDTO; import com.epmet.entity.CustomerGridEntity; import com.epmet.redis.CustomerGridRedis; @@ -152,4 +154,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl().ok(baseDao.getCustomerGridByGridId(customerGridFormDTO)); } + @Override + public Result> listStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO) { + List list = baseDao.selectListStaffGridInfo(staffGridInfoFormDTO); + return new Result>().ok(list); + } + } 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..6ea3950fb8 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,24 @@ LIMIT #{pageNo}, #{pageSize} + + + \ No newline at end of file diff --git a/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/controller/OperMenuController.java b/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/controller/OperMenuController.java index 80f82dff81..12e8fae171 100644 --- a/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/controller/OperMenuController.java +++ b/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/controller/OperMenuController.java @@ -1,6 +1,5 @@ package com.epmet.controller; -import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.ErrorCode; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; @@ -58,7 +57,7 @@ public class OperMenuController { } @PostMapping - public Result save(@RequestBody OperMenuDTO dto, @LoginUser TokenDto tokenDto){ + public Result save(@RequestBody OperMenuDTO dto, TokenDto tokenDto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); operMenuService.save(dto,tokenDto); @@ -66,7 +65,7 @@ public class OperMenuController { } @PutMapping - public Result update(@RequestBody OperMenuDTO dto, @LoginUser TokenDto tokenDto){ + public Result update(@RequestBody OperMenuDTO dto, TokenDto tokenDto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); operMenuService.update(dto,tokenDto); @@ -82,7 +81,7 @@ public class OperMenuController { } @DeleteMapping("{id}") - public Result delete(@PathVariable("id") String id, @LoginUser TokenDto tokenDto){ + public Result delete(@PathVariable("id") String id, TokenDto tokenDto){ //效验数据 AssertUtils.isNull(id, "id"); @@ -121,7 +120,7 @@ public class OperMenuController { * @return List */ @GetMapping("nav") - public Result> nav(@LoginUser TokenDto tokenDto){ + public Result> nav(TokenDto tokenDto){ List list = operMenuService.getUserMenuNavList(tokenDto); return new Result>().ok(list); } @@ -132,7 +131,7 @@ public class OperMenuController { * @return Set */ @GetMapping("permissions") - public Result> permissions(@LoginUser TokenDto tokenDto){ + public Result> permissions(TokenDto tokenDto){ Set set = operMenuService.getUserPermissions(tokenDto); return new Result>().ok(set); } @@ -143,7 +142,7 @@ public class OperMenuController { * @return */ @GetMapping("select") - public Result> select(@LoginUser TokenDto tokenDto){ + public Result> select(TokenDto tokenDto){ List list = operMenuService.getUserMenuList(tokenDto, null); return new Result>().ok(list); 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..7cca833383 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 @@ -18,7 +18,6 @@ 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; @@ -133,7 +132,7 @@ public class CustomerController { * @Date 2020/3/11 21:58 **/ @GetMapping("getvalidcustomerlist") - public Result> getValidCustomerList(@LoginUser TokenDto tokenDTO) { + public Result> getValidCustomerList(TokenDto tokenDTO) { logger.info("getvalidcustomerlist:"+ JSON.toJSONString(tokenDTO)); return customerService.getValidCustomerList(); } 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..bc29a28ee2 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 @@ -1,11 +1,9 @@ package com.epmet.modules.comment.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.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; @@ -39,7 +37,7 @@ public class ResiCommentController { * @Date 2020.04.01 18:06 **/ @PostMapping("commenttopic") - public Result commentTopic(@LoginUser TokenDto tokenDto, @RequestBody ResiPublishCommentFormDTO publishCommentFormDTO){ + public Result commentTopic(TokenDto tokenDto, @RequestBody ResiPublishCommentFormDTO publishCommentFormDTO){ ValidatorUtils.validateEntity(publishCommentFormDTO); return commentService.commentTopic(tokenDto,publishCommentFormDTO); } @@ -53,7 +51,7 @@ public class ResiCommentController { * @Date 2020.04.01 23:49 **/ @PostMapping("getcommentlistoftopic") - public Result> getCommentListOfTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiQueryCommentFormDTO queryCommentFormDTO){ + public Result> getCommentListOfTopic(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 ef1bbd22c8..54db90c905 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 @@ -17,12 +17,10 @@ package com.epmet.modules.group.controller; -import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.RenException; 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.UserResiInfoFormDTO; import com.epmet.modules.group.service.ResiGroupService; import com.epmet.modules.utils.ModuleConstant; import com.epmet.resi.group.dto.group.form.*; @@ -65,7 +63,7 @@ public class ResiGroupController { * @Date 2020/3/28 20:36 **/ @PostMapping("getmygroup") - public Result> getMyGroup(@LoginUser TokenDto tokenDto, @RequestBody MyGroupFormDTO myGroupFormDTO) { + public Result> getMyGroup(TokenDto tokenDto, @RequestBody MyGroupFormDTO myGroupFormDTO) { myGroupFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(myGroupFormDTO); return resiGroupService.getMyGroup(myGroupFormDTO); @@ -80,8 +78,8 @@ public class ResiGroupController { * @Date 2020/3/28 19:52 **/ @PostMapping("getrecommendgroup") - public Result> getRecommendGroup(@LoginUser TokenDto tokenDto, - @RequestBody RecommendGroupFormDTO recommendGroupFormDTO) { + public Result> getRecommendGroup(TokenDto tokenDto, + @RequestBody RecommendGroupFormDTO recommendGroupFormDTO) { recommendGroupFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(recommendGroupFormDTO); return resiGroupService.getRecommendGroup(recommendGroupFormDTO); @@ -96,8 +94,8 @@ public class ResiGroupController { * @Date 2020/3/28 21:59 **/ @PostMapping("getcreated") - public Result> getCreated(@LoginUser TokenDto tokenDto, - @RequestBody CreatedFormDTO createdFormDTO) { + public Result> getCreated(TokenDto tokenDto, + @RequestBody CreatedFormDTO createdFormDTO) { createdFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(createdFormDTO); return resiGroupService.getCreated(createdFormDTO); @@ -112,7 +110,7 @@ public class ResiGroupController { * @Date 2020/3/28 22:20 **/ @PostMapping("modifygroup") - public Result modifyGroup(@LoginUser TokenDto tokenDto, @RequestBody ModifyGroupFormDTO modifyGroupFormDTO) { + public Result modifyGroup(TokenDto tokenDto, @RequestBody ModifyGroupFormDTO modifyGroupFormDTO) { modifyGroupFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(modifyGroupFormDTO); return resiGroupService.modifyGroup(modifyGroupFormDTO); @@ -127,8 +125,8 @@ public class ResiGroupController { * @Date 2020/3/29 17:32 **/ @PostMapping("getgroupsummarize") - public Result getGroupSummarize(@LoginUser TokenDto tokenDto, - @RequestBody GroupSummarizeFormDTO groupSummarizeFormDTO) { + public Result getGroupSummarize(TokenDto tokenDto, + @RequestBody GroupSummarizeFormDTO groupSummarizeFormDTO) { groupSummarizeFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(groupSummarizeFormDTO); return resiGroupService.getGroupSummarize(groupSummarizeFormDTO); @@ -143,8 +141,8 @@ public class ResiGroupController { * @Date 2020/3/29 19:26 **/ @PostMapping("applycreategroup") - public Result applyCreateGroup(@LoginUser TokenDto tokenDto, - @RequestBody ApplyCreateGroupFormDTO applyCreateGroupFormDTO) { + public Result applyCreateGroup(TokenDto tokenDto, + @RequestBody ApplyCreateGroupFormDTO applyCreateGroupFormDTO) { applyCreateGroupFormDTO.setUserId(tokenDto.getUserId()); applyCreateGroupFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(applyCreateGroupFormDTO); @@ -160,8 +158,8 @@ public class ResiGroupController { * @Date 2020/3/30 10:11 **/ @PostMapping("initapplygroup") - public Result initApplyGroup(@LoginUser TokenDto tokenDto, - @RequestBody InitApplyGroupFormDTO initApplyGroupFormDTO) { + public Result initApplyGroup(TokenDto tokenDto, + @RequestBody InitApplyGroupFormDTO initApplyGroupFormDTO) { if (null == tokenDto) { logger.error(ModuleConstant.USER_NOT_NULL); throw new RenException(ModuleConstant.USER_NOT_NULL); @@ -180,8 +178,8 @@ public class ResiGroupController { * @Date 2020/3/30 15:44 **/ @PostMapping("initapplycreategroup") - public Result initApplyCreatedGroup(@LoginUser TokenDto tokenDto, - @RequestBody InitApplyCreatedGroupFormDTO initApplyCreatedGroupFormDTO) { + public Result initApplyCreatedGroup(TokenDto tokenDto, + @RequestBody InitApplyCreatedGroupFormDTO initApplyCreatedGroupFormDTO) { if (null == tokenDto) { logger.error(ModuleConstant.USER_NOT_NULL); throw new RenException(ModuleConstant.USER_NOT_NULL); @@ -200,7 +198,7 @@ public class ResiGroupController { * @Date 2020/3/31 12:31 **/ @PostMapping("agreeapplygroup") - public Result agreeApplyGroup(@LoginUser TokenDto tokenDto, @RequestBody AgreeApplyGroupFormDTO agreeApplyGroupFormDTO) { + public Result agreeApplyGroup(TokenDto tokenDto, @RequestBody AgreeApplyGroupFormDTO agreeApplyGroupFormDTO) { agreeApplyGroupFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(agreeApplyGroupFormDTO); return resiGroupService.agreeApplyGroup(agreeApplyGroupFormDTO); @@ -215,7 +213,7 @@ public class ResiGroupController { * @Date 2020/3/31 13:23 **/ @PostMapping("disagreeapplygroup") - public Result disagreeApplyGroup(@LoginUser TokenDto tokenDto, @RequestBody DisAgreeApplyGroupFormDTO disAgreeApplyGroupFormDTO) { + public Result disagreeApplyGroup(TokenDto tokenDto, @RequestBody DisAgreeApplyGroupFormDTO disAgreeApplyGroupFormDTO) { disAgreeApplyGroupFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(disAgreeApplyGroupFormDTO); return resiGroupService.disagreeApplyGroup(disAgreeApplyGroupFormDTO); 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..6fcc9f75f9 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 @@ -17,7 +17,6 @@ package com.epmet.modules.invitation.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; @@ -56,8 +55,8 @@ public class GroupInvitationController { * @Date 2020/3/31 22:50 **/ @PostMapping("creategroupinvitation") - public Result createGroupInvitation(@LoginUser TokenDto tokenDto, - @RequestBody CreateGroupInvitationFormDTO formDTO) { + public Result createGroupInvitation(TokenDto tokenDto, + @RequestBody CreateGroupInvitationFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO); return groupInvitationService.createGroupInvitation(formDTO); @@ -71,8 +70,8 @@ public class GroupInvitationController { * @Date 2020/3/31 23:11 **/ @PostMapping("getlinkgroupinfo") - public Result getLinkGroupInfo(@LoginUser TokenDto tokenDto, - @RequestBody LinkGroupInfoFormDTO formDTO) { + public Result getLinkGroupInfo(TokenDto tokenDto, + @RequestBody LinkGroupInfoFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO); return groupInvitationService.getLinkGroupInfo(formDTO); @@ -87,7 +86,7 @@ public class GroupInvitationController { * @Date 2020/3/31 23:47 **/ @PostMapping("acceptinvitation") - public Result accetInvitation(@LoginUser TokenDto tokenDto, + public Result accetInvitation(TokenDto tokenDto, @RequestBody AccetInvitationFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); formDTO.setApp(tokenDto.getApp()); 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..c358e1917c 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 @@ -17,7 +17,6 @@ package com.epmet.modules.member.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; @@ -52,8 +51,8 @@ public class ResiGroupMemberController { * @Date 2020/3/29 20:01 **/ @PostMapping("applyjoingroup") - public Result applyJoinGroup(@LoginUser TokenDto tokenDto, - @RequestBody ApplyJoinGroupFormDTO applyJoinGroupFormDTO) { + public Result applyJoinGroup(TokenDto tokenDto, + @RequestBody ApplyJoinGroupFormDTO applyJoinGroupFormDTO) { applyJoinGroupFormDTO.setUserId(tokenDto.getUserId()); applyJoinGroupFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(applyJoinGroupFormDTO); @@ -69,8 +68,8 @@ public class ResiGroupMemberController { * @Date 2020/3/30 21:14 **/ @PostMapping("getgroupmember") - public Result> getGroupMemberList(@LoginUser TokenDto tokenDto, - @RequestBody GroupMemberListFormDTO groupMemberListFormDTO) { + public Result> getGroupMemberList(TokenDto tokenDto, + @RequestBody GroupMemberListFormDTO groupMemberListFormDTO) { ValidatorUtils.validateEntity(groupMemberListFormDTO); return resiGroupMemberService.getGroupMemberList(groupMemberListFormDTO); } @@ -84,8 +83,8 @@ public class ResiGroupMemberController { * @Date 2020/3/30 21:37 **/ @PostMapping("getapplyingmember") - public Result> getApplyingMember(@LoginUser TokenDto tokenDto, - @RequestBody ApplyingMemberFormDTO applyingMemberFormDTO) { + public Result> getApplyingMember(TokenDto tokenDto, + @RequestBody ApplyingMemberFormDTO applyingMemberFormDTO) { ValidatorUtils.validateEntity(applyingMemberFormDTO); return resiGroupMemberService.getApplyingMember(applyingMemberFormDTO); } @@ -99,8 +98,8 @@ public class ResiGroupMemberController { * @Date 2020/3/30 22:07 **/ @PostMapping("agreeapply") - public Result agreeApply(@LoginUser TokenDto tokenDto, - @RequestBody AgreeApplyFormDTO agreeApplyFormDTO) { + public Result agreeApply(TokenDto tokenDto, + @RequestBody AgreeApplyFormDTO agreeApplyFormDTO) { agreeApplyFormDTO.setUserId(tokenDto.getUserId()); agreeApplyFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(agreeApplyFormDTO); @@ -116,8 +115,8 @@ public class ResiGroupMemberController { * @Date 2020/3/30 22:07 **/ @PostMapping("disagreeapply") - public Result disAgreeApply(@LoginUser TokenDto tokenDto, - @RequestBody DisagreeApplyFormDTO disagreeApplyFormDTO) { + public Result disAgreeApply(TokenDto tokenDto, + @RequestBody DisagreeApplyFormDTO disagreeApplyFormDTO) { disagreeApplyFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(disagreeApplyFormDTO); return resiGroupMemberService.disAgreeApply(disagreeApplyFormDTO); @@ -128,7 +127,7 @@ public class ResiGroupMemberController { * @Description 楼院小组--删除组成员 **/ @PostMapping("removemember") - public Result removeMember(@LoginUser TokenDto tokenDto, @RequestBody RemoveMemberFormDTO removeMemberFormDTO) { + public Result removeMember(TokenDto tokenDto, @RequestBody RemoveMemberFormDTO removeMemberFormDTO) { removeMemberFormDTO.setUserId(tokenDto.getUserId()); removeMemberFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(removeMemberFormDTO); @@ -143,7 +142,7 @@ public class ResiGroupMemberController { * @Description 楼院小组--禁言组员 **/ @PostMapping("slientmember") - public Result slientMember(@LoginUser TokenDto tokenDto, @RequestBody SlientMemberFormDTO slientMemberFormDTO) { + public Result slientMember(TokenDto tokenDto, @RequestBody SlientMemberFormDTO slientMemberFormDTO) { slientMemberFormDTO.setUserId(tokenDto.getUserId()); slientMemberFormDTO.setApp(tokenDto.getApp()); ValidatorUtils.validateEntity(slientMemberFormDTO); 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..6b8af29d96 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 @@ -1,6 +1,5 @@ package com.epmet.modules.topic.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; @@ -36,7 +35,7 @@ public class ResiTopicController { * @Date 2020.03.31 13:15 **/ @PostMapping("createtopic") - public Result createTopic(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicPublishFormDTO topicPublishFormDTO){ + public Result createTopic(TokenDto tokenDto, @RequestBody ResiTopicPublishFormDTO topicPublishFormDTO){ ValidatorUtils.validateEntity(topicPublishFormDTO); return topicService.createTopic(tokenDto,topicPublishFormDTO); @@ -51,7 +50,7 @@ public class ResiTopicController { * @Date 2020.04.01 23:48 **/ @PostMapping("gettopicdetail") - public Result getTopicDetail(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicDetailFormDTO topicDetailFormDTO ){ + public Result getTopicDetail(TokenDto tokenDto, @RequestBody ResiTopicDetailFormDTO topicDetailFormDTO ){ ValidatorUtils.validateEntity(topicDetailFormDTO); return topicService.getTopicDetail(tokenDto,topicDetailFormDTO.getTopicId()); } @@ -65,7 +64,7 @@ public class ResiTopicController { * @Date 2020.04.01 10:36 **/ @PostMapping("getpasttopiclist") - public Result> getPastTopicList(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicPageFormDTO topicPageFormDTO){ + public Result> getPastTopicList(TokenDto tokenDto, @RequestBody ResiTopicPageFormDTO topicPageFormDTO){ ValidatorUtils.validateEntity(topicPageFormDTO); return topicService.getPastTopicList(tokenDto,topicPageFormDTO); } @@ -79,7 +78,7 @@ public class ResiTopicController { * @Date 2020.04.02 00:01 **/ @PostMapping("getlatesttopics") - Result> getLatestTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){ + Result> getLatestTopics(TokenDto tokenDto, @RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){ ValidatorUtils.validateEntity(topicDefaultPageFormDTO); return topicService.getLatestTopics(tokenDto,topicDefaultPageFormDTO.getGroupId()); } @@ -93,7 +92,7 @@ public class ResiTopicController { * @Date 2020.04.01 12:38 **/ @RequestMapping("hidetopic") - Result hideTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicOperationFormDTO hiddenFormDTO){ + Result hideTopic(TokenDto tokenDto, @RequestBody ResiTopicOperationFormDTO hiddenFormDTO){ ValidatorUtils.validateEntity(hiddenFormDTO); return topicService.hideTopic(tokenDto,hiddenFormDTO); } @@ -107,7 +106,7 @@ public class ResiTopicController { * @Date 2020.04.01 16:45 **/ @PostMapping("gethiddentopic") - Result> getHiddenTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicPageFormDTO topicPageFormDTO){ + Result> getHiddenTopic(TokenDto tokenDto, @RequestBody ResiTopicPageFormDTO topicPageFormDTO){ ValidatorUtils.validateEntity(topicPageFormDTO); return topicService.getHiddenTopics(tokenDto,topicPageFormDTO); } @@ -121,7 +120,7 @@ public class ResiTopicController { * @Date 2020.04.01 14:17 **/ @PostMapping("cancelhiddentopics") - Result cancelHiddenTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicCancelHiddenFormDTO cancelHiddenFormDTO){ + Result cancelHiddenTopics(TokenDto tokenDto, @RequestBody ResiTopicCancelHiddenFormDTO cancelHiddenFormDTO){ return topicService.cancelHiddenTopics(tokenDto,cancelHiddenFormDTO.getTopicIds()); } @@ -134,7 +133,7 @@ public class ResiTopicController { * @Date 2020.04.01 15:37 **/ @PostMapping("closetopic") - Result closeTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicOperationFormDTO closeFormDTO){ + Result closeTopic(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..4e9aa206cc 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 @@ -17,7 +17,6 @@ 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; @@ -54,7 +53,7 @@ public class StrangerResiGuideController { * @Date 2020/3/16 **/ @PostMapping("getgridhome") - public Result getGridHome( @LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception { + public Result getGridHome( TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception { return strangerAccessRecordService.getGridHome(tokenDTO, strangerFormDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/UserGuideController.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/UserGuideController.java index fe4d4d15ea..81e59f7130 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/UserGuideController.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/UserGuideController.java @@ -1,6 +1,5 @@ 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; @@ -27,7 +26,7 @@ public class UserGuideController { private UserAccessService userAccessService; @PostMapping("entergrid") - Result enterGrid(@LoginUser TokenDto token, @RequestBody UserEnterGridFormDTO userEnterGridFormDTO){ + Result enterGrid(TokenDto token, @RequestBody UserEnterGridFormDTO userEnterGridFormDTO){ ValidatorUtils.validateEntity(userEnterGridFormDTO); diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java index 626f78bfd4..1127ec72b5 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java @@ -1,6 +1,5 @@ package com.epmet.modules.grid.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.result.LatestGridInfoResultDTO; @@ -29,7 +28,7 @@ public class ResiMineGridController { * @Date 2020/3/24 11:10 **/ @GetMapping("getlatestgridinfo") - public Result getLatestGridInfo(@LoginUser TokenDto tokenDto){ + public Result getLatestGridInfo(TokenDto tokenDto){ return resiMineGridService.getLatestGridInfo(tokenDto); } } 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..c0c2b493aa 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 @@ -1,6 +1,5 @@ package com.epmet.modules.message.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; @@ -35,8 +34,8 @@ public class UserMessageController { * @Date 2020/3/29 20:53 **/ @PostMapping("getmymessage") - public Result> getMyMessage(@LoginUser TokenDto tokenDto, - @RequestBody MymessageFormDTO mymessageFormDTO) { + public Result> getMyMessage(TokenDto tokenDto, + @RequestBody MymessageFormDTO mymessageFormDTO) { mymessageFormDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(mymessageFormDTO); //逻辑待实现 @@ -64,7 +63,7 @@ public class UserMessageController { * @Date 2020/3/29 21:06 **/ @PostMapping("readallmsg") - public Result readAllMessage(@LoginUser TokenDto tokenDto, @RequestBody UserMessageDTO userMessageDTO) { + public Result readAllMessage(TokenDto tokenDto, @RequestBody UserMessageDTO userMessageDTO) { //逻辑待实现 return userMessageService.readAllMessage(tokenDto, userMessageDTO); } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/partymember/controller/PartyMemberController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/partymember/controller/PartyMemberController.java index 379a9491e9..bfa776d92e 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/partymember/controller/PartyMemberController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/partymember/controller/PartyMemberController.java @@ -1,6 +1,5 @@ package com.epmet.modules.partymember.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.modules.partymember.service.PartyMemberService; @@ -34,7 +33,7 @@ public class PartyMemberController { * @return Result */ @PostMapping("init") - public Result init(@LoginUser TokenDto tokenDto, @RequestBody PartyMemberInitFromDTO fromDto) { + public Result init(TokenDto tokenDto, @RequestBody PartyMemberInitFromDTO fromDto) { fromDto.setUserId(tokenDto.getUserId()); return partyMemberService.init(fromDto); } @@ -47,7 +46,7 @@ public class PartyMemberController { * @date 2020/3/30 13:50 */ @PostMapping("getverificationcode") - public Result getVerificationCode(@LoginUser TokenDto tokenDto, @RequestBody VerificationCodeFromDTO fromDto) { + public Result getVerificationCode(TokenDto tokenDto, @RequestBody VerificationCodeFromDTO fromDto) { return partyMemberService.getVerificationCode(tokenDto, fromDto); } @@ -59,7 +58,7 @@ public class PartyMemberController { * @date 2020/3/30 13:50 */ @PostMapping("submit") - public Result submit(@LoginUser TokenDto tokenDto, @RequestBody PartyMemberSubmitFromDTO fromDto) { + public Result submit(TokenDto tokenDto, @RequestBody PartyMemberSubmitFromDTO fromDto) { return partyMemberService.submit(tokenDto, fromDto); } @@ -71,7 +70,7 @@ public class PartyMemberController { * @date 2020/3/30 13:50 */ @PostMapping("extra") - public Result partyMemberInfoExtra(@LoginUser TokenDto tokenDto, @RequestBody PartyMemberSubmitFromDTO fromDto) { + public Result partyMemberInfoExtra(TokenDto tokenDto, @RequestBody PartyMemberSubmitFromDTO fromDto) { return partyMemberService.partyMemberInfoExtra(tokenDto, fromDto); } } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/controller/ResiRegisterController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/controller/ResiRegisterController.java index e9d591581e..3a8c6dee7b 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/controller/ResiRegisterController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/controller/ResiRegisterController.java @@ -1,6 +1,5 @@ package com.epmet.modules.resiregister.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; @@ -34,7 +33,7 @@ public class ResiRegisterController { * @Date 2020/3/30 **/ @PostMapping("init") - public Result init(@LoginUser TokenDto tokenDTO, @RequestBody ResiRegisterFormDTO resiRegisterFormDTO) { + public Result init(TokenDto tokenDTO, @RequestBody ResiRegisterFormDTO resiRegisterFormDTO) { ValidatorUtils.validateEntity(resiRegisterFormDTO); return resiRegisterService.init(tokenDTO, resiRegisterFormDTO); } @@ -45,7 +44,7 @@ public class ResiRegisterController { * @Description 居民端-居民注册信息提交 **/ @PostMapping("submit") - public Result submit(@LoginUser TokenDto tokenDTO, @RequestBody ResiInfoSubmitFormDTO resiInfoSubmitFormDTO) { + public Result submit(TokenDto tokenDTO, @RequestBody ResiInfoSubmitFormDTO resiInfoSubmitFormDTO) { ValidatorUtils.validateEntity(resiInfoSubmitFormDTO); return resiRegisterService.submit(tokenDTO, resiInfoSubmitFormDTO); } @@ -56,7 +55,7 @@ public class ResiRegisterController { * @Description 居民端-居民注册根据手机号获取验证码 **/ @PostMapping("getverificationcode") - public Result getVerificationCode(@LoginUser TokenDto tokenDTO, @RequestBody VerificationCodeFormDTO formDTO) { + public Result getVerificationCode(TokenDto tokenDTO, @RequestBody VerificationCodeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return resiRegisterService.getVerificationCode(tokenDTO, formDTO); } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedController.java index 03283c179a..9d555d6d40 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedController.java @@ -1,6 +1,5 @@ package com.epmet.modules.warmhearted.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; @@ -31,7 +30,7 @@ public class ResiWarmheartedController { * @Description 居民端-热心居民申请页面初始化-查询有无申请、新增访问行为记录数据 **/ @PostMapping("init") - public Result init(@LoginUser TokenDto tokenDTO, @RequestBody ResiWarmheartedFormDTO resiWarmheartedFormDTO) { + public Result init(TokenDto tokenDTO, @RequestBody ResiWarmheartedFormDTO resiWarmheartedFormDTO) { ValidatorUtils.validateEntity(resiWarmheartedFormDTO); return resiWarmheartedService.init(tokenDTO, resiWarmheartedFormDTO); } @@ -42,7 +41,7 @@ public class ResiWarmheartedController { * @Description 居民端-热心居民申请-提交申请数据 **/ @PostMapping("submit") - public Result submit(@LoginUser TokenDto tokenDTO, @RequestBody ResiWarmheartedSubmitFormDTO formDTO) { + public Result submit(TokenDto tokenDTO, @RequestBody ResiWarmheartedSubmitFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); return resiWarmheartedService.submit(tokenDTO, formDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffLoginHistoryDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffLoginHistoryDTO.java new file mode 100644 index 0000000000..6d1674936f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffLoginHistoryDTO.java @@ -0,0 +1,102 @@ +/** + * 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-20 + */ +@Data +public class StaffLoginHistoryDTO 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 + */ + private String orgId; + + /** + * 网格表Id (CUSTOMER_GRID.id) + */ + private String gridId; + + /** + * 删除标识: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/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/StaffLoginHistoryFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffLoginHistoryFormDTO.java new file mode 100644 index 0000000000..14a205d032 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffLoginHistoryFormDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 保存工作人员登录日志 + * @Author yinzuomei + * @Date 2020/4/20 14:26 + */ +@Data +public class StaffLoginHistoryFormDTO implements Serializable { + /** + * 客户ID + */ + private String customerId; + + /** + * customer_staff.userId + */ + private String staffId; + + /** + * 微信openId + */ + private String wxOpenId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 组织机构id + */ + private String orgId; + + /** + * 网格表Id (CUSTOMER_GRID.id) + */ + private String gridId; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LatestStaffWechatLoginResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LatestStaffWechatLoginResultDTO.java new file mode 100644 index 0000000000..5ad4ebde86 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LatestStaffWechatLoginResultDTO.java @@ -0,0 +1,46 @@ +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 LatestStaffWechatLoginResultDTO 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 orgId; + + /** + * 网格表Id (CUSTOMER_GRID.id) + */ + private String gridId; +} + 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..b68ea382c6 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,10 @@ 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.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; import org.springframework.beans.factory.annotation.Autowired; @@ -45,24 +46,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 +71,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 +79,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 +93,27 @@ 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); } } \ 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..b44f404523 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 @@ -17,7 +17,6 @@ package com.epmet.controller; -import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; @@ -109,7 +108,7 @@ public class OperUserController { * @author zhaoqifeng */ @GetMapping("queryOperUserDto") - public Result queryOperUserDto(@LoginUser TokenDto tokenDto) { + public Result queryOperUserDto(TokenDto tokenDto) { OperUserDTO data = operUserService.getOperUserInfoById(tokenDto.getUserId()); QueryOperUserResultDto dto = ConvertUtils.sourceToTarget(data, QueryOperUserResultDto.class); return new Result().ok(dto); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffLoginHistoryController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffLoginHistoryController.java new file mode 100644 index 0000000000..08c8e02c94 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffLoginHistoryController.java @@ -0,0 +1,64 @@ +/** + * 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.StaffLoginHistoryFormDTO; +import com.epmet.dto.result.LatestStaffWechatLoginResultDTO; +import com.epmet.service.StaffLoginHistoryService; +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-20 + */ +@RestController +@RequestMapping("staffloginhistory") +public class StaffLoginHistoryController { + + @Autowired + private StaffLoginHistoryService staffLoginHistoryService; + + /** + * @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 staffLoginHistoryService.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 StaffLoginHistoryFormDTO formDTO) { + return staffLoginHistoryService.saveStaffLoginRecord(formDTO); + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java index 6081d38fe1..8c1930d6ac 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java @@ -1,6 +1,5 @@ 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; @@ -80,7 +79,7 @@ public class UserController { * @Description 居民端个人信息-同步用户微信信息 **/ @PostMapping("updatewxuserinfo") - public Result updateWxUserInfo(@LoginUser TokenDto tokenDTO, @RequestBody WxUserInfoFormDTO wxUserInfoFormDTO) { + public Result updateWxUserInfo(TokenDto tokenDTO, @RequestBody WxUserInfoFormDTO wxUserInfoFormDTO) { wxUserInfoFormDTO.setUserId(tokenDTO.getUserId()); ValidatorUtils.validateEntity(wxUserInfoFormDTO); return userService.updateWxUserInfo(wxUserInfoFormDTO); 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..a676eb8a2c 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,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.entity.CustomerStaffEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 政府工作人员表 * @@ -29,5 +33,22 @@ 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); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffLoginHistoryDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffLoginHistoryDao.java new file mode 100644 index 0000000000..1458be2a28 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffLoginHistoryDao.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.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.LatestStaffWechatLoginResultDTO; +import com.epmet.entity.StaffLoginHistoryEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 工作人员登录日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-20 + */ +@Mapper +public interface StaffLoginHistoryDao extends BaseDao { + + /** + * @return com.epmet.dto.result.LatestStaffWechatLoginDTO + * @param openId + * @Author yinzuomei + * @Description 获取当前微信上次登录的账号信息 + * @Date 2020/4/20 12:45 + **/ + LatestStaffWechatLoginResultDTO selectLatestStaffWechatLoginRecord(String openId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffLoginHistoryEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffLoginHistoryEntity.java new file mode 100644 index 0000000000..9a9377ecfe --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffLoginHistoryEntity.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.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 工作人员登录日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("staff_login_history") +public class StaffLoginHistoryEntity 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 + */ + private String orgId; + + /** + * 网格表Id (CUSTOMER_GRID.id) + */ + private String gridId; + +} 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..b459bdb83c 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 @@ -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.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.entity.CustomerStaffEntity; import java.util.List; @@ -95,11 +96,20 @@ public interface CustomerStaffService extends BaseService { void delete(String[] ids); /** - * @param phone 手机号 + * @param mobile 手机号 * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 根据手机号查询政府端工作人员基本信息,校验用户是否存在 * @Date 2020/4/18 14:07 **/ - Result getCustsomerStaffByPhone(String phone); + 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); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffLoginHistoryService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffLoginHistoryService.java new file mode 100644 index 0000000000..fab2c9f20e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffLoginHistoryService.java @@ -0,0 +1,116 @@ +/** + * 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.StaffLoginHistoryDTO; +import com.epmet.dto.form.StaffLoginHistoryFormDTO; +import com.epmet.dto.result.LatestStaffWechatLoginResultDTO; +import com.epmet.entity.StaffLoginHistoryEntity; + +import java.util.List; +import java.util.Map; + +/** + * 工作人员登录日志表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-20 + */ +public interface StaffLoginHistoryService extends BaseService { + + /** + * 默认分页 + * + * @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 id + * @return StaffLoginHistoryDTO + * @author generator + * @date 2020-04-20 + */ + StaffLoginHistoryDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-20 + */ + void save(StaffLoginHistoryDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-20 + */ + void update(StaffLoginHistoryDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-20 + */ + 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(StaffLoginHistoryFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 7470edc96d..7fdbb725e3 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 @@ -28,6 +28,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.UserConstant; import com.epmet.dao.CustomerStaffDao; import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.entity.CustomerStaffEntity; import com.epmet.redis.CustomerStaffRedis; import com.epmet.service.CustomerStaffService; @@ -107,23 +108,26 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl getCustsomerStaffByPhone(String phone) { + public Result> getCustsomerStaffByPhone(String mobile) { //判断用户是否存在 - 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())); + 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); //判断用户是否已被禁用 - 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())); + 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()); } - CustomerStaffDTO customerStaffDTO=ConvertUtils.sourceToTarget(customerStaff, CustomerStaffDTO.class); - return new Result().ok(customerStaffDTO); + return new Result().ok(customerStaffDTO); } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffLoginHistoryServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffLoginHistoryServiceImpl.java new file mode 100644 index 0000000000..2cccdf9f3e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffLoginHistoryServiceImpl.java @@ -0,0 +1,121 @@ +/** + * 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.StaffLoginHistoryDao; +import com.epmet.dto.StaffLoginHistoryDTO; +import com.epmet.dto.form.StaffLoginHistoryFormDTO; +import com.epmet.dto.result.LatestStaffWechatLoginResultDTO; +import com.epmet.entity.StaffLoginHistoryEntity; +import com.epmet.service.StaffLoginHistoryService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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-20 + */ +@Service +public class StaffLoginHistoryServiceImpl extends BaseServiceImpl implements StaffLoginHistoryService { + private static final Logger logger = LoggerFactory.getLogger(StaffLoginHistoryServiceImpl.class); + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, StaffLoginHistoryDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, StaffLoginHistoryDTO.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 StaffLoginHistoryDTO get(String id) { + StaffLoginHistoryEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, StaffLoginHistoryDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(StaffLoginHistoryDTO dto) { + StaffLoginHistoryEntity entity = ConvertUtils.sourceToTarget(dto, StaffLoginHistoryEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(StaffLoginHistoryDTO dto) { + StaffLoginHistoryEntity entity = ConvertUtils.sourceToTarget(dto, StaffLoginHistoryEntity.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.isNotBlank(openId)) { + logger.error("openId 不能为空"); + return new Result(); + } + LatestStaffWechatLoginResultDTO latestStaffWechatLoginDTO = baseDao.selectLatestStaffWechatLoginRecord(openId); + return new Result().ok(latestStaffWechatLoginDTO); + } + + @Override + public Result saveStaffLoginRecord(StaffLoginHistoryFormDTO formDTO) { + StaffLoginHistoryEntity entity = ConvertUtils.sourceToTarget(formDTO, StaffLoginHistoryEntity.class); + insert(entity); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql index 19f25df536..e09dd173a2 100644 --- a/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql @@ -35,4 +35,22 @@ CREATE TABLE `staff_wechat` ( PRIMARY KEY (`ID`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='工作人员微信关系表 '; -alter table grid_latest MODIFY COLUMN PID VARCHAR(64) comment'上级组织ID (数据统计字段)' \ No newline at end of file +alter table grid_latest MODIFY COLUMN PID VARCHAR(64) comment'上级组织ID (数据统计字段)'; +alter table staff_wechat add column LATEST_LOGIN_TIME datetime NOT NULL COMMENT '最后一次登录时间'; +alter table staff_wechat drop column LATEST_LOGIN_TIME; +CREATE TABLE `staff_login_history` ( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `STAFF_ID` varchar(64) NOT NULL COMMENT 'customer_staff.userId', + WX_OPEN_ID varchar(64) NOT NULL COMMENT '微信openId', + `MOBILE` varchar(20) NOT NULL COMMENT '手机号', + `ORG_ID` varchar(64) NOT NULL COMMENT '组织机构id', + `GRID_ID` varchar(64) COMMENT '网格表Id (CUSTOMER_GRID.id)', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间,登录时间', + `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新人', + `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='工作人员登录日志表'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index c5ba17deab..1a8958a306 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -3,26 +3,18 @@ - - - - - - - - - - - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffLoginHistoryDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffLoginHistoryDao.xml new file mode 100644 index 0000000000..4f382bfa10 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffLoginHistoryDao.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file