Browse Source

政府端小程序登录发送验证码、wxCode获取最近一次登录账户token、enterorg接口开发

master
yinzuomei 5 years ago
parent
commit
6de6509b19
  1. 14
      epmet-auth/pom.xml
  2. 81
      epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java
  3. 31
      epmet-auth/src/main/java/com/epmet/controller/LoginController.java
  4. 39
      epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpEnteOrgFormDTO.java
  5. 21
      epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpFormDTO.java
  6. 10
      epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpGetOrgsFormDTO.java
  7. 4
      epmet-auth/src/main/java/com/epmet/dto/form/SendSmsCodeFormDTO.java
  8. 43
      epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  9. 23
      epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  10. 24
      epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
  11. 25
      epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java
  12. 9
      epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java
  13. 51
      epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
  14. 19
      epmet-auth/src/main/java/com/epmet/service/LoginService.java
  15. 264
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
  16. 99
      epmet-auth/src/main/java/com/epmet/service/impl/LoginServiceImpl.java
  17. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/LoginUser.java
  18. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  19. 80
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java
  20. 11
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java
  21. 31
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/CpUserDetailRedis.java
  22. 60
      epmet-gateway/pom.xml
  23. 30
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffGridInfoFormDTO.java
  24. 39
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffGridInfoResultDTO.java
  25. 19
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java
  26. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  27. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  28. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  29. 20
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
  30. 13
      epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/controller/OperMenuController.java
  31. 3
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  32. 6
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/comment/controller/ResiCommentController.java
  33. 34
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  34. 11
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/controller/GroupInvitationController.java
  35. 25
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/controller/ResiGroupMemberController.java
  36. 17
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java
  37. 3
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java
  38. 3
      epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/UserGuideController.java
  39. 3
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/grid/controller/ResiMineGridController.java
  40. 7
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/message/controller/UserMessageController.java
  41. 9
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/partymember/controller/PartyMemberController.java
  42. 7
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/resiregister/controller/ResiRegisterController.java
  43. 5
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedController.java
  44. 102
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffLoginHistoryDTO.java
  45. 21
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java
  46. 44
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StaffLoginHistoryFormDTO.java
  47. 46
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LatestStaffWechatLoginResultDTO.java
  48. 36
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  49. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java
  50. 64
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffLoginHistoryController.java
  51. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java
  52. 23
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
  53. 42
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffLoginHistoryDao.java
  54. 68
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffLoginHistoryEntity.java
  55. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  56. 116
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffLoginHistoryService.java
  57. 26
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  58. 121
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffLoginHistoryServiceImpl.java
  59. 20
      epmet-user/epmet-user-server/src/main/resources/db/migration/epmet_user.sql
  60. 34
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml
  61. 40
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffLoginHistoryDao.xml

14
epmet-auth/pom.xml

@ -92,6 +92,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>gov-org-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
@ -187,8 +193,8 @@
<resi.wx.ma.appId>wx9b6102a8ee5add65</resi.wx.ma.appId>
<resi.wx.ma.secret>16fdb68bc2b3e732324ba5d8b8a9b5e2</resi.wx.ma.secret>
<!--政府端小程序配置-->
<resi.wx.ma.appId>wx3d1372029eb816a3</resi.wx.ma.appId>
<resi.wx.ma.secret>651f02d71ed3f123dfb584b8bf0f4d8b</resi.wx.ma.secret>
<gov.wx.ma.appId>wx3d1372029eb816a3</gov.wx.ma.appId>
<gov.wx.ma.secret>651f02d71ed3f123dfb584b8bf0f4d8b</gov.wx.ma.secret>
</properties>
</profile>
@ -224,8 +230,8 @@
<resi.wx.ma.appId>wx9b6102a8ee5add65</resi.wx.ma.appId>
<resi.wx.ma.secret>16fdb68bc2b3e732324ba5d8b8a9b5e2</resi.wx.ma.secret>
<!--政府端小程序配置-->
<resi.wx.ma.appId>wx3d1372029eb816a3</resi.wx.ma.appId>
<resi.wx.ma.secret>651f02d71ed3f123dfb584b8bf0f4d8b</resi.wx.ma.secret>
<gov.wx.ma.appId>wx3d1372029eb816a3</gov.wx.ma.appId>
<gov.wx.ma.secret>651f02d71ed3f123dfb584b8bf0f4d8b</gov.wx.ma.secret>
</properties>
</profile>
</profiles>

81
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<com.epmet.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 1政府端小程序根据wxCode获取上一次登录信息返回token
* @Date 2020/4/20 11:22
**/
@PostMapping(value = "/loginwxmp/loginbywxcode")
public Result<UserTokenResultDTO> 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<com.epmet.common.token.dto.result.UserTokenResultDTO>
* @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<com.epmet.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 4选择组织进入首页
* @Date 2020/4/20 13:07
**/
@PostMapping(value = "/loginwxmp/enterorg")
public Result<UserTokenResultDTO> enterOrg(GovWxmpEnteOrgFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return govLoginService.enterOrg(formDTO);
}
}

31
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<com.epmet.common.token.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 政府端微信小程序登录-手机验证码登录
* @Date 2020/4/18 21:14
**/
@PostMapping(value = "/govwxmp/loginbyphone")
public Result<UserTokenResultDTO> loginByPhone(LoginByPhoneFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return loginService.loginByPhone(formDTO);
}
}

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

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

10
epmet-auth/src/main/java/com/epmet/dto/form/LoginByPhoneFormDTO.java → 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;
}

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

43
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<PasswordLoginUserInfoResultDTO> 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<CustomerStaffDTO> checkCustomerStaff(@PathVariable("phone") String phone);
@GetMapping(value = "epmetuser/customerstaff/getcustsomerstaffbyphone/{mobile}")
Result<List<CustomerStaffDTO>> 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<com.epmet.dto.result.LatestStaffWechatLoginDTO>
* @Author yinzuomei
* @Description 获取当前微信上次登录的账号信息
* @Date 2020/4/20 12:53
**/
@GetMapping(value = "epmetuser/staffloginhistory/getlatest/{openId}")
Result<LatestStaffWechatLoginResultDTO> getLatestStaffWechatLoginRecord(@PathVariable("openId") String openId);
/**
* @param customerStaffFormDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerStaffDTO>
* @Author yinzuomei
* @Description 根据手机号+客户id获取工作人员基本信息
* @Date 2020/4/20 14:16
**/
@PostMapping(value = "epmetuser/customerstaff/getcustomerstaffinfo", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<CustomerStaffDTO> 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);
}

23
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<List<StaffGridInfoResultDTO>> getStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO);
}

24
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<CustomerStaffDTO> checkCustomerStaff(String phone) {
public Result<List<CustomerStaffDTO>> 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<LatestStaffWechatLoginResultDTO> getLatestStaffWechatLoginRecord(String openId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getLatestStaffWechatLoginRecord", openId);
}
@Override
public Result<CustomerStaffDTO> 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);
}
}

25
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<List<StaffGridInfoResultDTO>> getStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffGridInfo", staffGridInfoFormDTO);
}
}

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

51
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<com.epmet.common.token.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 3手机验证码获取组织
* @Date 2020/4/18 21:11
**/
Result<UserTokenResultDTO> getorgs(GovWxmpGetOrgsFormDTO formDTO);
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 政府端小程序根据wxCode获取上一次登录信息返回token
* @Date 2020/4/20 11:23
**/
Result<UserTokenResultDTO> loginByWxCode(GovWxmpFormDTO formDTO);
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 4选择组织进入首页
* @Date 2020/4/20 13:08
**/
Result<UserTokenResultDTO> enterOrg(GovWxmpEnteOrgFormDTO formDTO);
}

19
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<com.epmet.common.token.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 政府端微信小程序登录-手机验证码登录
* @Date 2020/4/18 21:11
**/
Result<UserTokenResultDTO> loginByPhone(LoginByPhoneFormDTO formDTO);
}

264
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<List<CustomerStaffDTO>> 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<Map<String, String>> 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<com.epmet.common.token.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 3手机验证码获取组织
* @Date 2020/4/18 21:11
**/
@Override
public Result<UserTokenResultDTO> getorgs(GovWxmpGetOrgsFormDTO formDTO) {
//1、根据手机号查询到用户信息
Result<List<CustomerStaffDTO>> 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<UserTokenResultDTO>().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
}
//3、TODO返回组织树
return new Result();
}
@Override
public Result<UserTokenResultDTO> loginByWxCode(GovWxmpFormDTO formDTO) {
//1、解析微信用户
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(formDTO.getApp(), formDTO.getWxCode());
Result<LatestStaffWechatLoginResultDTO> 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<UserTokenResultDTO>().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<UserTokenResultDTO>().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<UserTokenResultDTO> enterOrg(GovWxmpEnteOrgFormDTO formDTO) {
//1、需要校验要登录的客户,是否被禁用
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO();
customerStaffFormDTO.setCustomerId(formDTO.getCustomerId());
customerStaffFormDTO.setMobile(formDTO.getMobile());
Result<CustomerStaffDTO> 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<List<StaffGridInfoResultDTO>> 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<UserTokenResultDTO>().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<String, Object> 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;
}
}

99
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<CustomerStaffDTO> 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<Map<String, String>> 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<com.epmet.common.token.dto.result.UserTokenResultDTO>
* @Author yinzuomei
* @Description 政府端微信小程序登录-手机验证码登录
* @Date 2020/4/18 21:11
**/
@Override
public Result<UserTokenResultDTO> loginByPhone(LoginByPhoneFormDTO formDTO) {
//1、根据手机号查询到用户信息
Result<CustomerStaffDTO> 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<UserTokenResultDTO>().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
}
//3、解析wxCode
UserTokenResultDTO userTokenResultDTO=this.getAuthorizationInfo(formDTO,customerStaffResult.getData());
return new Result<UserTokenResultDTO>().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

2
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

1
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, "党员注册失败"),

80
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<String> deptIdList;
}

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

31
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<String, Object> 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_usercustomer_usercustomer_staff表主键
* @return
*/
public GovTokenDto getGovTokenDto(String app, String client, String userId) {
String key = RedisKeys.getCpUserKey(app,client,userId);
Map<String, Object> map = redisUtils.hGetAll(key);
if (MapUtil.isEmpty(map)) {
return null;
}
//map to bean
GovTokenDto govTokenDto = BeanUtil.mapToBean(map, GovTokenDto.class, true);
return govTokenDto;
}
}

60
epmet-gateway/pom.xml

@ -108,53 +108,53 @@
<nacos.ip></nacos.ip>
<!-- gateway routes -->
<!-- 1、认证服务 -->
<!-- <gateway.routes.epmet-auth-server.uri>lb://epmet-auth-server</gateway.routes.epmet-auth-server.uri>-->
<gateway.routes.epmet-auth-server.uri>http://127.0.0.1:8081</gateway.routes.epmet-auth-server.uri>
<gateway.routes.epmet-auth-server.uri>lb://epmet-auth-server</gateway.routes.epmet-auth-server.uri>
<!-- <gateway.routes.epmet-auth-server.uri>http://127.0.0.1:8081</gateway.routes.epmet-auth-server.uri>-->
<!-- 2、Admin服务 -->
<!-- <gateway.routes.epmet-admin-server.uri>lb://epmet-admin-server</gateway.routes.epmet-admin-server.uri>-->
<gateway.routes.epmet-admin-server.uri>http://127.0.0.1:8082</gateway.routes.epmet-admin-server.uri>
<gateway.routes.epmet-admin-server.uri>lb://epmet-admin-server</gateway.routes.epmet-admin-server.uri>
<!-- <gateway.routes.epmet-admin-server.uri>http://127.0.0.1:8082</gateway.routes.epmet-admin-server.uri>-->
<!-- 4、OSS服务 -->
<!-- <gateway.routes.epmet-oss-server.uri>lb://epmet-oss-server</gateway.routes.epmet-oss-server.uri>-->
<gateway.routes.epmet-oss-server.uri>http://127.0.0.1:8083</gateway.routes.epmet-oss-server.uri>
<gateway.routes.epmet-oss-server.uri>lb://epmet-oss-server</gateway.routes.epmet-oss-server.uri>
<!-- <gateway.routes.epmet-oss-server.uri>http://127.0.0.1:8083</gateway.routes.epmet-oss-server.uri>-->
<!-- 5、消息服务 -->
<!-- <gateway.routes.epmet-message-server.uri>lb://epmet-message-server</gateway.routes.epmet-message-server.uri>-->
<gateway.routes.epmet-message-server.uri>http://127.0.0.1:8085</gateway.routes.epmet-message-server.uri>
<gateway.routes.epmet-message-server.uri>lb://epmet-message-server</gateway.routes.epmet-message-server.uri>
<!-- <gateway.routes.epmet-message-server.uri>http://127.0.0.1:8085</gateway.routes.epmet-message-server.uri>-->
<!-- 6、工作流服务 -->
<!-- <gateway.routes.epmet-activiti-server.uri>lb://epmet-activiti-server</gateway.routes.epmet-activiti-server.uri>-->
<gateway.routes.epmet-activiti-server.uri>http://127.0.0.1:8086</gateway.routes.epmet-activiti-server.uri>
<gateway.routes.epmet-activiti-server.uri>lb://epmet-activiti-server</gateway.routes.epmet-activiti-server.uri>
<!-- <gateway.routes.epmet-activiti-server.uri>http://127.0.0.1:8086</gateway.routes.epmet-activiti-server.uri>-->
<!-- 7、定时任务服务 -->
<!-- <gateway.routes.epmet-job-server.uri>lb://epmet-job-server</gateway.routes.epmet-job-server.uri>-->
<gateway.routes.epmet-job-server.uri>http://127.0.0.1:8084</gateway.routes.epmet-job-server.uri>
<gateway.routes.epmet-job-server.uri>lb://epmet-job-server</gateway.routes.epmet-job-server.uri>
<!-- <gateway.routes.epmet-job-server.uri>http://127.0.0.1:8084</gateway.routes.epmet-job-server.uri>-->
<!-- 8、用户模块 -->
<!-- <gateway.routes.epmet-user-server.uri>lb://epmet-user-server</gateway.routes.epmet-user-server.uri>-->
<gateway.routes.epmet-user-server.uri>http://127.0.0.1:8087</gateway.routes.epmet-user-server.uri>
<gateway.routes.epmet-user-server.uri>lb://epmet-user-server</gateway.routes.epmet-user-server.uri>
<!-- <gateway.routes.epmet-user-server.uri>http://127.0.0.1:8087</gateway.routes.epmet-user-server.uri>-->
<!-- 9、新模块结构demo -->
<!-- <gateway.routes.epmet-demo-server.uri>lb://epmet-demo-server</gateway.routes.epmet-demo-server.uri>-->
<gateway.routes.epmet-demo-server.uri>http://127.0.0.1:8088</gateway.routes.epmet-demo-server.uri>
<!-- 10、运营端客户定制化服务 -->
<!-- <gateway.routes.epmet-oper-customize-server.uri>lb://oper-customize-server</gateway.routes.epmet-oper-customize-server.uri>-->
<gateway.routes.oper-customize-server.uri>http://127.0.0.1:8089</gateway.routes.oper-customize-server.uri>
<gateway.routes.oper-customize-server.uri>lb://oper-customize-server</gateway.routes.oper-customize-server.uri>
<!-- <gateway.routes.oper-customize-server.uri>http://127.0.0.1:8089</gateway.routes.oper-customize-server.uri>-->
<!-- 11、运营端客户定制化服务 -->
<!-- <gateway.routes.oper-crm-server.uri>lb://oper-crm-server</gateway.routes.oper-crm-server.uri>-->
<gateway.routes.oper-crm-server.uri>http://127.0.0.1:8090</gateway.routes.oper-crm-server.uri>
<gateway.routes.oper-crm-server.uri>lb://oper-crm-server</gateway.routes.oper-crm-server.uri>
<!-- <gateway.routes.oper-crm-server.uri>http://127.0.0.1:8090</gateway.routes.oper-crm-server.uri>-->
<!-- 12、居民端陌生人导览 -->
<!-- <gateway.routes.resi-guide-server.uri>lb://oper-crm-server</gateway.routes.resi-guide-server.uri>-->
<gateway.routes.resi-guide-server.uri>http://127.0.0.1:8091</gateway.routes.resi-guide-server.uri>
<gateway.routes.resi-guide-server.uri>lb://resi-guide-server</gateway.routes.resi-guide-server.uri>
<!-- <gateway.routes.resi-guide-server.uri>http://127.0.0.1:8091</gateway.routes.resi-guide-server.uri>-->
<!-- 13、政府组织管理 -->
<!-- <gateway.routes.gov-org-server.uri>lb://gov-org-server</gateway.routes.gov-org-server.uri>-->
<gateway.routes.gov-org-server.uri>http://127.0.0.1:8092</gateway.routes.gov-org-server.uri>
<gateway.routes.gov-org-server.uri>lb://gov-org-server</gateway.routes.gov-org-server.uri>
<!-- <gateway.routes.gov-org-server.uri>http://127.0.0.1:8092</gateway.routes.gov-org-server.uri>-->
<!-- 14、#运营端访问权限控制 -->
<!-- <gateway.routes.oper-access-server.uri>lb://oper-access-server</gateway.routes.oper-access-server.uri>-->
<gateway.routes.oper-access-server.uri>http://127.0.0.1:8093</gateway.routes.oper-access-server.uri>
<gateway.routes.oper-access-server.uri>lb://oper-access-server</gateway.routes.oper-access-server.uri>
<!-- <gateway.routes.oper-access-server.uri>http://127.0.0.1:8093</gateway.routes.oper-access-server.uri>-->
<!-- 15、居民端个人信息 -->
<!-- <gateway.routes.resi-mine-server.uri>lb://resi-mine-server</gateway.routes.resi-mine-server.uri>-->
<gateway.routes.resi-mine-server.uri>http://127.0.0.1:8094</gateway.routes.resi-mine-server.uri>
<gateway.routes.resi-mine-server.uri>lb://resi-mine-server</gateway.routes.resi-mine-server.uri>
<!-- <gateway.routes.resi-mine-server.uri>http://127.0.0.1:8094</gateway.routes.resi-mine-server.uri>-->
<!-- 16、居民端楼院校组 -->
<!-- <gateway.routes.resi-group-server.uri>lb://resi-group-server</gateway.routes.resi-group-server.uri>-->
<gateway.routes.resi-group-server.uri>http://127.0.0.1:8095</gateway.routes.resi-group-server.uri>
<gateway.routes.resi-group-server.uri>lb://resi-group-server</gateway.routes.resi-group-server.uri>
<!-- <gateway.routes.resi-group-server.uri>http://127.0.0.1:8095</gateway.routes.resi-group-server.uri>-->
<!-- 17、党员认证、热心居民申请 -->
<gateway.routes.resi-partymember-server.uri>http://127.0.0.1:8096</gateway.routes.resi-partymember-server.uri>
<!-- <gateway.routes.resi-partymember-server.uri>lb://resi-partymember-server</gateway.routes.resi-partymember-server.uri>-->
<!-- <gateway.routes.resi-partymember-server.uri>http://127.0.0.1:8096</gateway.routes.resi-partymember-server.uri>-->
<gateway.routes.resi-partymember-server.uri>lb://resi-partymember-server</gateway.routes.resi-partymember-server.uri>
</properties>
</profile>
<profile>

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

39
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;
/**
* 所属组织机构IDcustomer_organization.id
*/
private String pid;
/**
* 所有上级组织ID
*/
private String pids;
}

19
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<CustomerGridDTO>().ok(data);
}
/**
* @param staffGridInfoFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.StaffGridInfoResultDTO>>
* @Author yinzuomei
* @Description 根据用户选择的组织查询用户与网格的关系列表
* @Date 2020/4/20 15:34
**/
@PostMapping(value = "getStaffGridInfo")
public Result<List<StaffGridInfoResultDTO>> getStaffGridInfo(@RequestBody StaffGridInfoFormDTO staffGridInfoFormDTO) {
ValidatorUtils.validateEntity(staffGridInfoFormDTO);
return customerGridService.listStaffGridInfo(staffGridInfoFormDTO);
}
}

16
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<CustomerGridEntity> {
List<CustomerGridForStrangerResultDTO> selectRestGridWithoutGivenAreaCode(Map<String,Object> paramsMap);
CustomerGridDTO getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO);
/**
* @param staffGridInfoFormDTO
* @return java.util.List<com.epmet.dto.result.StaffGridInfoResultDTO>
* @Author yinzuomei
* @Description 查询工作人员绑定的网格列表
* @Date 2020/4/20 15:36
**/
List<StaffGridInfoResultDTO> selectListStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO);
}

11
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<CustomerGridEntity> {
* @date 2020-03-17
*/
Result<CustomerGridDTO> getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO);
/**
* @param staffGridInfoFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.StaffGridInfoResultDTO>>
* @Author yinzuomei
* @Description 根据用户选择的组织查询用户与网格的关系列表
* @Date 2020/4/20 15:35
**/
Result<List<StaffGridInfoResultDTO>> listStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO);
}

8
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<CustomerGridDao, Cu
return new Result<CustomerGridDTO>().ok(baseDao.getCustomerGridByGridId(customerGridFormDTO));
}
@Override
public Result<List<StaffGridInfoResultDTO>> listStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO) {
List<StaffGridInfoResultDTO> list = baseDao.selectListStaffGridInfo(staffGridInfoFormDTO);
return new Result<List<StaffGridInfoResultDTO>>().ok(list);
}
}

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

@ -92,4 +92,24 @@
LIMIT #{pageNo}, #{pageSize}
</select>
<!-- 查询工作人员绑定的网格列表 -->
<select id="selectListStaffGridInfo" parameterType="com.epmet.dto.form.StaffGridInfoFormDTO" resultType="com.epmet.dto.result.StaffGridInfoResultDTO">
SELECT
csg.GRID_ID,
cg.CUSTOMER_ID,
cg.GRID_NAME,
cg.PID,
cg.PIDS
FROM
customer_staff_grid csg
LEFT JOIN customer_grid cg ON ( csg.GRID_ID = cg.id )
WHERE
csg.DEL_FLAG = '0'
AND cg.DEL_FLAG = '0'
AND csg.USER_ID=#{staffId}
and cg.PID like concat(#{orgId},'%')
and cg.CUSTOMER_ID=#{customerId}
order by csg.CREATED_TIME desc
</select>
</mapper>

13
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<OperMenuDTO>
*/
@GetMapping("nav")
public Result<List<OperMenuDTO>> nav(@LoginUser TokenDto tokenDto){
public Result<List<OperMenuDTO>> nav(TokenDto tokenDto){
List<OperMenuDTO> list = operMenuService.getUserMenuNavList(tokenDto);
return new Result<List<OperMenuDTO>>().ok(list);
}
@ -132,7 +131,7 @@ public class OperMenuController {
* @return Set<String>
*/
@GetMapping("permissions")
public Result<Set<String>> permissions(@LoginUser TokenDto tokenDto){
public Result<Set<String>> permissions(TokenDto tokenDto){
Set<String> set = operMenuService.getUserPermissions(tokenDto);
return new Result<Set<String>>().ok(set);
}
@ -143,7 +142,7 @@ public class OperMenuController {
* @return
*/
@GetMapping("select")
public Result<List<OperMenuDTO>> select(@LoginUser TokenDto tokenDto){
public Result<List<OperMenuDTO>> select(TokenDto tokenDto){
List<OperMenuDTO> list = operMenuService.getUserMenuList(tokenDto, null);
return new Result<List<OperMenuDTO>>().ok(list);

3
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<List<ValidCustomerResultDTO>> getValidCustomerList(@LoginUser TokenDto tokenDTO) {
public Result<List<ValidCustomerResultDTO>> getValidCustomerList(TokenDto tokenDTO) {
logger.info("getvalidcustomerlist:"+ JSON.toJSONString(tokenDTO));
return customerService.getValidCustomerList();
}

6
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<List<ResiCommentResultDTO>> getCommentListOfTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiQueryCommentFormDTO queryCommentFormDTO){
public Result<List<ResiCommentResultDTO>> getCommentListOfTopic(TokenDto tokenDto, @RequestBody ResiQueryCommentFormDTO queryCommentFormDTO){
ValidatorUtils.validateEntity(queryCommentFormDTO);
return commentService.getCommentList(tokenDto,queryCommentFormDTO);
}

34
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<List<MyGroupResultDTO>> getMyGroup(@LoginUser TokenDto tokenDto, @RequestBody MyGroupFormDTO myGroupFormDTO) {
public Result<List<MyGroupResultDTO>> 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<List<RecommendGroupResultDTO>> getRecommendGroup(@LoginUser TokenDto tokenDto,
@RequestBody RecommendGroupFormDTO recommendGroupFormDTO) {
public Result<List<RecommendGroupResultDTO>> 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<List<CreatedResultDTO>> getCreated(@LoginUser TokenDto tokenDto,
@RequestBody CreatedFormDTO createdFormDTO) {
public Result<List<CreatedResultDTO>> 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<GroupSummarizeResultDTO> getGroupSummarize(@LoginUser TokenDto tokenDto,
@RequestBody GroupSummarizeFormDTO groupSummarizeFormDTO) {
public Result<GroupSummarizeResultDTO> 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);

11
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<CreateGroupInvitationResultDTO> createGroupInvitation(@LoginUser TokenDto tokenDto,
@RequestBody CreateGroupInvitationFormDTO formDTO) {
public Result<CreateGroupInvitationResultDTO> 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<LinkGroupInfoResultDTO> getLinkGroupInfo(@LoginUser TokenDto tokenDto,
@RequestBody LinkGroupInfoFormDTO formDTO) {
public Result<LinkGroupInfoResultDTO> 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());

25
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<List<GroupMemberListResultDTO>> getGroupMemberList(@LoginUser TokenDto tokenDto,
@RequestBody GroupMemberListFormDTO groupMemberListFormDTO) {
public Result<List<GroupMemberListResultDTO>> 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<List<ApplyingMemberResultDTO>> getApplyingMember(@LoginUser TokenDto tokenDto,
@RequestBody ApplyingMemberFormDTO applyingMemberFormDTO) {
public Result<List<ApplyingMemberResultDTO>> 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);

17
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<ResiTopicDetailResultDTO> getTopicDetail(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicDetailFormDTO topicDetailFormDTO ){
public Result<ResiTopicDetailResultDTO> 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<List<ResiTopicInfoResultDTO>> getPastTopicList(@LoginUser TokenDto tokenDto, @RequestBody ResiTopicPageFormDTO topicPageFormDTO){
public Result<List<ResiTopicInfoResultDTO>> 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<List<ResiTopicInfoResultDTO>> getLatestTopics(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicDefaultPageFormDTO topicDefaultPageFormDTO){
Result<List<ResiTopicInfoResultDTO>> 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<List<ResiTopicInfoResultDTO>> getHiddenTopic(@LoginUser TokenDto tokenDto,@RequestBody ResiTopicPageFormDTO topicPageFormDTO){
Result<List<ResiTopicInfoResultDTO>> 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);
}

3
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<HomeDesignByCustomerResultDTO> getGridHome( @LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception {
public Result<HomeDesignByCustomerResultDTO> getGridHome( TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception {
return strangerAccessRecordService.getGridHome(tokenDTO, strangerFormDTO);
}

3
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<UserInfoOnEnterGridResultDTO> enterGrid(@LoginUser TokenDto token, @RequestBody UserEnterGridFormDTO userEnterGridFormDTO){
Result<UserInfoOnEnterGridResultDTO> enterGrid(TokenDto token, @RequestBody UserEnterGridFormDTO userEnterGridFormDTO){
ValidatorUtils.validateEntity(userEnterGridFormDTO);

3
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<LatestGridInfoResultDTO> getLatestGridInfo(@LoginUser TokenDto tokenDto){
public Result<LatestGridInfoResultDTO> getLatestGridInfo(TokenDto tokenDto){
return resiMineGridService.getLatestGridInfo(tokenDto);
}
}

7
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<List<UserMessageDTO>> getMyMessage(@LoginUser TokenDto tokenDto,
@RequestBody MymessageFormDTO mymessageFormDTO) {
public Result<List<UserMessageDTO>> 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);
}

9
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<PartyMemberInitResultDto>
*/
@PostMapping("init")
public Result<PartyMemberInitResultDTO> init(@LoginUser TokenDto tokenDto, @RequestBody PartyMemberInitFromDTO fromDto) {
public Result<PartyMemberInitResultDTO> 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);
}
}

7
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<ResiRegisterResultDTO> init(@LoginUser TokenDto tokenDTO, @RequestBody ResiRegisterFormDTO resiRegisterFormDTO) {
public Result<ResiRegisterResultDTO> 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);
}

5
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<ResiWarmheartedResultDTO> init(@LoginUser TokenDto tokenDTO, @RequestBody ResiWarmheartedFormDTO resiWarmheartedFormDTO) {
public Result<ResiWarmheartedResultDTO> 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);
}

102
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/StaffLoginHistoryDTO.java

@ -0,0 +1,102 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
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;
}

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

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

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

36
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<PageData<CustomerStaffDTO>> page(@RequestParam Map<String, Object> params){
public Result<PageData<CustomerStaffDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CustomerStaffDTO> page = customerStaffService.page(params);
return new Result<PageData<CustomerStaffDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<CustomerStaffDTO> get(@PathVariable("id") String id){
public Result<CustomerStaffDTO> get(@PathVariable("id") String id) {
CustomerStaffDTO data = customerStaffService.get(id);
return new Result<CustomerStaffDTO>().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<CustomerStaffDTO> getCustsomerStaffByPhone(@PathVariable("phone") String phone) {
return customerStaffService.getCustsomerStaffByPhone(phone);
@GetMapping(value = "getcustsomerstaffbyphone/{mobile}")
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(@PathVariable("mobile") String mobile) {
return customerStaffService.getCustsomerStaffByPhone(mobile);
}
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerStaffDTO>
* @Author yinzuomei
* @Description 根据手机号+客户id获取工作人员基本信息
* @Date 2020/4/20 14:04
**/
@PostMapping(value = "getcustomerstaffinfo")
public Result<CustomerStaffDTO> getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return customerStaffService.getCustomerStaffInfo(formDTO);
}
}

3
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<QueryOperUserResultDto> queryOperUserDto(@LoginUser TokenDto tokenDto) {
public Result<QueryOperUserResultDto> queryOperUserDto(TokenDto tokenDto) {
OperUserDTO data = operUserService.getOperUserInfoById(tokenDto.getUserId());
QueryOperUserResultDto dto = ConvertUtils.sourceToTarget(data, QueryOperUserResultDto.class);
return new Result<QueryOperUserResultDto>().ok(dto);

64
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StaffLoginHistoryController.java

@ -0,0 +1,64 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.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<com.epmet.dto.result.LatestStaffWechatLoginDTO>
* @Author yinzuomei
* @Description 获取当前微信上次登录的账号信息
* @Date 2020/4/20 12:42
**/
@GetMapping(value = "getlatest/{openId}")
public Result<LatestStaffWechatLoginResultDTO> 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);
}
}

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

23
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<CustomerStaffEntity> {
/**
* @param mobile
* @return java.util.List<com.epmet.dto.CustomerStaffDTO>
* @Author yinzuomei
* @Description 根据手机号查询工作人员信息
* @Date 2020/4/20 13:17
**/
List<CustomerStaffDTO> selectListCustomerStaffDTO(String mobile);
/**
* @param formDTO
* @return com.epmet.dto.CustomerStaffDTO
* @Author yinzuomei
* @Description 根据手机号+客户id获取工作人员基本信息
* @Date 2020/4/20 14:08
**/
CustomerStaffDTO selectListCustomerStaffInfo(CustomerStaffFormDTO formDTO);
}

42
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffLoginHistoryDao.java

@ -0,0 +1,42 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.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<StaffLoginHistoryEntity> {
/**
* @return com.epmet.dto.result.LatestStaffWechatLoginDTO
* @param openId
* @Author yinzuomei
* @Description 获取当前微信上次登录的账号信息
* @Date 2020/4/20 12:45
**/
LatestStaffWechatLoginResultDTO selectLatestStaffWechatLoginRecord(String openId);
}

68
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/StaffLoginHistoryEntity.java

@ -0,0 +1,68 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.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;
}

14
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<CustomerStaffEntity> {
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<CustomerStaffDTO> getCustsomerStaffByPhone(String phone);
Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(String mobile);
/**
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerStaffDTO>
* @Author yinzuomei
* @Description 根据手机号+客户id获取工作人员基本信息
* @Date 2020/4/20 14:05
**/
Result<CustomerStaffDTO> getCustomerStaffInfo(CustomerStaffFormDTO formDTO);
}

116
epmet-user/epmet-user-server/src/main/java/com/epmet/service/StaffLoginHistoryService.java

@ -0,0 +1,116 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.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<StaffLoginHistoryEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<StaffLoginHistoryDTO>
* @author generator
* @date 2020-04-20
*/
PageData<StaffLoginHistoryDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<StaffLoginHistoryDTO>
* @author generator
* @date 2020-04-20
*/
List<StaffLoginHistoryDTO> list(Map<String, Object> 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<com.epmet.dto.result.LatestStaffWechatLoginDTO>
* @Author yinzuomei
* @Description 获取当前微信上次登录的账号信息
* @Date 2020/4/20 12:43
**/
Result<LatestStaffWechatLoginResultDTO> 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);
}

26
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<CustomerStaffDao,
}
@Override
public Result<CustomerStaffDTO> getCustsomerStaffByPhone(String phone) {
public Result<List<CustomerStaffDTO>> getCustsomerStaffByPhone(String mobile) {
//判断用户是否存在
QueryWrapper<CustomerStaffEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(phone), FieldConstant.MOBILE, phone);
List<CustomerStaffEntity> 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<CustomerStaffDTO> customerStaffDTOList = baseDao.selectListCustomerStaffDTO(mobile);
if (null == customerStaffDTOList || customerStaffDTOList.size() == 0) {
logger.error(String.format("根据手机号查询用户异常,手机号:[%s],code[%s],msg[%s]", mobile, EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode(), EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getMsg()));
return new Result().error(EpmetErrorCode.GOV_STAFF_NOT_EXISTS.getCode());
}
return new Result<List<CustomerStaffDTO>>().ok(customerStaffDTOList);
}
@Override
public Result<CustomerStaffDTO> getCustomerStaffInfo(CustomerStaffFormDTO formDTO) {
CustomerStaffDTO customerStaffDTO = baseDao.selectListCustomerStaffInfo(formDTO);
//判断用户是否已被禁用
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<CustomerStaffDTO>().ok(customerStaffDTO);
}
}

121
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffLoginHistoryServiceImpl.java

@ -0,0 +1,121 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.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<StaffLoginHistoryDao, StaffLoginHistoryEntity> implements StaffLoginHistoryService {
private static final Logger logger = LoggerFactory.getLogger(StaffLoginHistoryServiceImpl.class);
@Override
public PageData<StaffLoginHistoryDTO> page(Map<String, Object> params) {
IPage<StaffLoginHistoryEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, StaffLoginHistoryDTO.class);
}
@Override
public List<StaffLoginHistoryDTO> list(Map<String, Object> params) {
List<StaffLoginHistoryEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, StaffLoginHistoryDTO.class);
}
private QueryWrapper<StaffLoginHistoryEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<StaffLoginHistoryEntity> 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<LatestStaffWechatLoginResultDTO> getLatestStaffWechatLoginRecord(String openId) {
if (StringUtils.isNotBlank(openId)) {
logger.error("openId 不能为空");
return new Result();
}
LatestStaffWechatLoginResultDTO latestStaffWechatLoginDTO = baseDao.selectLatestStaffWechatLoginRecord(openId);
return new Result<LatestStaffWechatLoginResultDTO>().ok(latestStaffWechatLoginDTO);
}
@Override
public Result saveStaffLoginRecord(StaffLoginHistoryFormDTO formDTO) {
StaffLoginHistoryEntity entity = ConvertUtils.sourceToTarget(formDTO, StaffLoginHistoryEntity.class);
insert(entity);
return new Result();
}
}

20
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 (数据统计字段)'
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='工作人员登录日志表';

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

@ -3,26 +3,18 @@
<mapper namespace="com.epmet.dao.CustomerStaffDao">
<resultMap type="com.epmet.entity.CustomerStaffEntity" id="customerStaffMap">
<result property="id" column="ID"/>
<result property="userId" column="USER_ID"/>
<result property="realName" column="REAL_NAME"/>
<result property="gender" column="GENDER"/>
<result property="email" column="EMAIL"/>
<result property="mobile" column="MOBILE"/>
<result property="address" column="ADDRESS"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="workType" column="WORK_TYPE"/>
<result property="headPhoto" column="HEAD_PHOTO"/>
<result property="activeFlag" column="ACTIVE_FLAG"/>
<result property="activeTime" column="ACTIVE_TIME"/>
<result property="enableFlag" column="ENABLE_FLAG"/>
</resultMap>
<!-- 根据手机号查询工作人员信息 -->
<select id="selectListCustomerStaffDTO" parameterType="java.lang.String" resultType="com.epmet.dto.CustomerStaffDTO">
select * from customer_staff cs
where cs.MOBILE=#{mobile}
and cs.DEL_FLAG='1'
</select>
<!-- 根据手机号+客户id获取工作人员基本信息 -->
<select id="selectListCustomerStaffInfo" parameterType="com.epmet.dto.form.CustomerStaffFormDTO" resultType="com.epmet.dto.CustomerStaffDTO">
select * from customer_staff cs
where cs.MOBILE=#{mobile}
and cs.CUSTOMER_ID=#{customerId}
and cs.DEL_FLAG='1'
</select>
</mapper>

40
epmet-user/epmet-user-server/src/main/resources/mapper/StaffLoginHistoryDao.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.StaffLoginHistoryDao">
<resultMap type="com.epmet.entity.StaffLoginHistoryEntity" id="staffLoginHistoryMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="staffId" column="STAFF_ID"/>
<result property="wxOpenId" column="WX_OPEN_ID"/>
<result property="mobile" column="MOBILE"/>
<result property="orgId" column="ORG_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 获取当前微信上次登录的账号信息 -->
<select id="selectLatestStaffWechatLoginRecord" parameterType="java.lang.String" resultType="com.epmet.dto.result.LatestStaffWechatLoginResultDTO">
SELECT
slh.CUSTOMER_ID,
slh.STAFF_ID,
slh.WX_OPEN_ID,
slh.MOBILE,
slh.ORG_ID,
slh.GRID_ID
FROM
staff_login_history slh
WHERE
slh.DEL_FLAG = '0'
AND slh.WX_OPEN_ID =#{openId}
ORDER BY
slh.CREATED_TIME DESC
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save