Browse Source

赞提

master
yinzuomei 5 years ago
parent
commit
84614c5a14
  1. 11
      epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java
  2. 8
      epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgsFormDTO.java
  3. 2
      epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  4. 27
      epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  5. 2
      epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
  6. 15
      epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java
  7. 7
      epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java
  8. 7
      epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
  9. 104
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
  10. 13
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java
  11. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffLatestLoginGridFormDTO.java
  12. 18
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffOrgFormDTO.java
  13. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffLatestLoginGridResultDTO.java
  14. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffOrgsResultDTO.java
  15. 15
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  16. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  17. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  18. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  19. 17
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  20. 1
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

11
epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java

@ -4,8 +4,9 @@ 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.form.StaffOrgsFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.GovLoginService;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Description 政府端登录
* @Author yinzuomei
@ -58,10 +61,10 @@ public class GovLoginController {
* @Description 3手机验证码获取组织
* @Date 2020/4/18 21:14
**/
@PostMapping(value = "/loginwxmp/getorgs")
public Result getorgs(GovWxmpGetOrgsFormDTO formDTO) {
@PostMapping(value = "/loginwxmp/getmyorg")
public Result<List<StaffOrgsResultDTO>> getmyorg(StaffOrgsFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return govLoginService.getorgs(formDTO);
return govLoginService.getMyOrg(formDTO);
}
/**

8
epmet-auth/src/main/java/com/epmet/dto/form/GovWxmpGetOrgsFormDTO.java → epmet-auth/src/main/java/com/epmet/dto/form/StaffOrgsFormDTO.java

@ -11,12 +11,18 @@ import java.io.Serializable;
* @Date 2020/4/18 10:38
*/
@Data
public class GovWxmpGetOrgsFormDTO implements Serializable {
public class StaffOrgsFormDTO implements Serializable {
private static final long serialVersionUID = 4193133227120225342L;
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空")
private String mobile;
/**
* 验证码
*/
@NotBlank(message="验证码不能为空")
private String smsCode;
}

2
epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -76,7 +76,7 @@ public interface EpmetUserFeignClient {
* @Date 2020/4/18 22:44
**/
@PostMapping(value = "epmetuser/staffwechat/savestaffwechat", consumes = MediaType.APPLICATION_JSON_VALUE)
Result savestaffwechat(@RequestBody StaffWechatFormDTO staffWechatFormDTO);
Result saveStaffWechat(@RequestBody StaffWechatFormDTO staffWechatFormDTO);
/**
* @param openId

27
epmet-auth/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -2,8 +2,10 @@ 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.dto.form.StaffLatestLoginGridFormDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffLatestLoginGridResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.feign.fallback.GovOrgFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
@ -18,6 +20,23 @@ import java.util.List;
*/
@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);
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.StaffGridInfoResultDTO>>
* @param staffGridInfoFormDTO
* @Author yinzuomei
* @Description
* @Date 2020/4/20 21:36
**/
@PostMapping(value = "gov/org/customergrid/getStaffGridInfo",consumes = MediaType.APPLICATION_JSON_VALUE)
Result<StaffLatestLoginGridResultDTO> getStaffLatestLoginGrid(StaffLatestLoginGridFormDTO staffGridInfoFormDTO);
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.StaffOrgsResultDTO>>
* @param staffOrgFormDTO
* @Author yinzuomei
* @Description 获取客户对应的根级组织名称
* @Date 2020/4/20 21:37
**/
@PostMapping(value = "/gov/org/customeragency/getStaffOrgList",consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO);
}

2
epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java

@ -43,7 +43,7 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
}
@Override
public Result savestaffwechat(StaffWechatFormDTO staffWechatFormDTO) {
public Result saveStaffWechat(StaffWechatFormDTO staffWechatFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffWechat", staffWechatFormDTO);
}

15
epmet-auth/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallback.java

@ -3,8 +3,10 @@ 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.dto.form.StaffLatestLoginGridFormDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffLatestLoginGridResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.feign.GovOrgFeignClient;
import org.springframework.stereotype.Component;
@ -18,8 +20,13 @@ import java.util.List;
@Component
public class GovOrgFeignClientFallback implements GovOrgFeignClient {
@Override
public Result<List<StaffGridInfoResultDTO>> getStaffGridInfo(StaffGridInfoFormDTO staffGridInfoFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffGridInfo", staffGridInfoFormDTO);
public Result<StaffLatestLoginGridResultDTO> getStaffLatestLoginGrid(StaffLatestLoginGridFormDTO staffLatestLoginGridFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffLatestLoginGrid", staffLatestLoginGridFormDTO);
}
@Override
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffOrgList", staffOrgFormDTO);
}
}

7
epmet-auth/src/main/java/com/epmet/redis/CaptchaRedis.java

@ -11,7 +11,6 @@ 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.GovWxmpGetOrgsFormDTO;
import com.epmet.dto.form.SendSmsCodeFormDTO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -72,14 +71,14 @@ public class CaptchaRedis {
}
/**
* @param formDTO
* @param mobile
* @return java.lang.String
* @Author yinzuomei
* @Description 获取登录时发送的验证码
* @Date 2020/4/18 21:33
**/
public String getSmsCode(GovWxmpGetOrgsFormDTO formDTO) {
String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_GOV, LoginConstant.CLIENT_WXMP, formDTO.getMobile());
public String getSmsCode(String mobile) {
String smsCodeKey = RedisKeys.getLoginSmsCodeKey(LoginConstant.APP_GOV, LoginConstant.CLIENT_WXMP, mobile);
String smsCode = (String) redisUtils.get(smsCodeKey);
return smsCode;
}

7
epmet-auth/src/main/java/com/epmet/service/GovLoginService.java

@ -3,10 +3,13 @@ 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.form.StaffOrgsFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import java.util.List;
/**
* @Description 政府端登录服务
* @Author yinzuomei
@ -29,7 +32,7 @@ public interface GovLoginService {
* @Description 3手机验证码获取组织
* @Date 2020/4/18 21:11
**/
Result getorgs(GovWxmpGetOrgsFormDTO formDTO);
Result<List<StaffOrgsResultDTO>> getMyOrg(StaffOrgsFormDTO formDTO);
/**
* @param formDTO

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

@ -10,9 +10,7 @@ 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.dto.result.*;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.MessageFeignClient;
@ -26,6 +24,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -96,7 +95,7 @@ public class GovLoginServiceImpl implements GovLoginService {
* @Date 2020/4/18 21:11
**/
@Override
public Result getorgs(GovWxmpGetOrgsFormDTO formDTO) {
public Result<List<StaffOrgsResultDTO>> getMyOrg(StaffOrgsFormDTO formDTO) {
//1、根据手机号查询到用户信息
Result<List<CustomerStaffDTO>> customerStaffResult = epmetUserFeignClient.checkCustomerStaff(formDTO.getMobile());
if (!customerStaffResult.success()) {
@ -104,12 +103,19 @@ public class GovLoginServiceImpl implements GovLoginService {
return new Result().error(customerStaffResult.getCode());
}
//2、验证码是否正确
String rightSmsCode = captchaRedis.getSmsCode(formDTO);
String rightSmsCode = captchaRedis.getSmsCode(formDTO.getMobile());
if (!formDTO.getSmsCode().equals(rightSmsCode)) {
return new Result<>().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
return new Result<List<StaffOrgsResultDTO>>().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode());
}
//3、TODO返回组织树
return new Result();
//3、查询用户所有的组织信息
List<String> customerIdList = new ArrayList<>();
for (CustomerStaffDTO customerStaffDTO : customerStaffResult.getData()) {
customerIdList.add(customerStaffDTO.getCustomerId());
}
StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO();
staffOrgFormDTO.setCustomerIdList(customerIdList);
Result<List<StaffOrgsResultDTO>> result = govOrgFeignClient.getStaffOrgList(staffOrgFormDTO);
return result;
}
@Override
@ -129,12 +135,34 @@ public class GovLoginServiceImpl implements GovLoginService {
//4、获取用户token
String token = this.generateGovWxmpToken(latestStaffWechatLoginDTO.getStaffId());
//5、保存到redis
this.saveGovTokenDto(latestStaffWechatLoginDTO.getOrgId(), latestStaffWechatLoginDTO.getGridId(), latestStaffWechatLoginDTO.getStaffId(), wxMaJscode2SessionResult, token);
this.saveLatestGovTokenDto(latestStaffWechatLoginDTO, wxMaJscode2SessionResult, token);
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token);
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO);
}
//保存tokenDto到redis
private void saveLatestGovTokenDto(LatestStaffWechatLoginResultDTO latestStaffWechatLoginDTO,
WxMaJscode2SessionResult wxMaJscode2SessionResult,
String token) {
int expire = jwtTokenProperties.getExpire();
GovTokenDto govTokenDto = new GovTokenDto();
govTokenDto.setApp(LoginConstant.APP_GOV);
govTokenDto.setClient(LoginConstant.CLIENT_WXMP);
govTokenDto.setStaffId(latestStaffWechatLoginDTO.getStaffId());
govTokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid());
govTokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey());
govTokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid());
govTokenDto.setToken(token);
govTokenDto.setUpdateTime(System.currentTimeMillis());
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
govTokenDto.setOrgId(latestStaffWechatLoginDTO.getOrgId());
govTokenDto.setGridId(latestStaffWechatLoginDTO.getGridId());
govTokenDto.setCustomerId(latestStaffWechatLoginDTO.getCustomerId());
cpUserDetailRedis.set(govTokenDto, expire);
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
}
//保存登录日志
private Result saveStaffLoginRecord(LatestStaffWechatLoginResultDTO latestStaffWechatLoginDTO) {
StaffLoginHistoryFormDTO staffLoginHistoryFormDTO = new StaffLoginHistoryFormDTO();
@ -164,19 +192,30 @@ public class GovLoginServiceImpl implements GovLoginService {
WxMaJscode2SessionResult wxMaJscode2SessionResult = loginService.getWxMaUser(LoginConstant.APP_GOV, formDTO.getWxCode());
//3、记录staff_wechat
this.savestaffwechat(customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid());
//4、记录登录日志
StaffGridInfoFormDTO staffGridInfoFormDTO = new StaffGridInfoFormDTO();
//4、查询用户绑定的网格
StaffLatestLoginGridResultDTO latestGridInfo = this.getLatestGridInfo(formDTO, customerStaff.getUserId());
//5、记录登录日志
this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid(), latestGridInfo.getGridId());
//1、获取用户token
String token = this.generateGovWxmpToken(customerStaff.getUserId());
//2、保存到redis
this.saveGovTokenDto(formDTO.getOrgId(), formDTO.getCustomerId(), latestGridInfo.getGridId(), customerStaff.getUserId(), wxMaJscode2SessionResult, token);
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token);
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO);
}
//查询用户绑定的网格
private StaffLatestLoginGridResultDTO getLatestGridInfo(GovWxmpEnteOrgFormDTO formDTO, String userId) {
StaffLatestLoginGridFormDTO staffGridInfoFormDTO = new StaffLatestLoginGridFormDTO();
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();
staffGridInfoFormDTO.setStaffId(userId);
Result<StaffLatestLoginGridResultDTO> staffGridInfoListResult = govOrgFeignClient.getStaffLatestLoginGrid(staffGridInfoFormDTO);
if (staffGridInfoListResult.success() && null != staffGridInfoListResult.getData()) {
return staffGridInfoListResult.getData();
}
this.saveStaffLoginRecord(formDTO, customerStaff.getUserId(), wxMaJscode2SessionResult.getOpenid(), gridId);
UserTokenResultDTO userTokenResultDTO = this.getAuthorizationInfo(formDTO.getOrgId(), gridId, customerStaff.getUserId(), wxMaJscode2SessionResult);
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO);
return new StaffLatestLoginGridResultDTO();
}
//保存登录日志
@ -192,18 +231,6 @@ public class GovLoginServiceImpl implements GovLoginService {
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
@ -217,7 +244,7 @@ public class GovLoginServiceImpl implements GovLoginService {
StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO();
staffWechatFormDTO.setUserId(userId);
staffWechatFormDTO.setWxOpenId(openid);
return epmetUserFeignClient.savestaffwechat(staffWechatFormDTO);
return epmetUserFeignClient.saveStaffWechat(staffWechatFormDTO);
}
/**
@ -238,11 +265,12 @@ public class GovLoginServiceImpl implements GovLoginService {
* @Description 生成token
* @Date 2020/4/18 23:04
**/
private String saveGovTokenDto(String orgId,
String gridId,
String staffId,
WxMaJscode2SessionResult wxMaJscode2SessionResult,
String token) {
private void saveGovTokenDto(String orgId,
String customerId,
String gridId,
String staffId,
WxMaJscode2SessionResult wxMaJscode2SessionResult,
String token) {
int expire = jwtTokenProperties.getExpire();
GovTokenDto govTokenDto = new GovTokenDto();
govTokenDto.setApp(LoginConstant.APP_GOV);
@ -256,9 +284,9 @@ public class GovLoginServiceImpl implements GovLoginService {
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
govTokenDto.setOrgId(orgId);
govTokenDto.setGridId(gridId);
govTokenDto.setCustomerId(customerId);
cpUserDetailRedis.set(govTokenDto, expire);
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
return token;
}
}

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

@ -58,22 +58,27 @@ public class GovTokenDto implements Serializable {
private long updateTime;
/**
* 当前登录的组织id
* 当前工作人员进入的客户id
*/
private String customerId;
/**
* 当前登录的组织id(顶级)
*/
private String orgId;
/**
* 待定
* 当前网格对应的组织结构id的全路径用:隔开
*/
private String orgIdPath;
/**
* 待定
* 当前所在网格id
*/
private String gridId;
/**
* 待定
* 部门id列表
*/
private List<String> deptIdList;
}

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffGridInfoFormDTO.java → epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffLatestLoginGridFormDTO.java

@ -11,7 +11,7 @@ import java.io.Serializable;
* @Date 2020/4/20 15:29
*/
@Data
public class StaffGridInfoFormDTO implements Serializable {
public class StaffLatestLoginGridFormDTO implements Serializable {
/**
* 用户选择的组织所属的id
*/
@ -24,6 +24,9 @@ public class StaffGridInfoFormDTO implements Serializable {
@NotBlank(message = "组织id不能为空")
private String orgId;
/**
* 工作人员id
*/
@NotBlank(message = "staffId不能为空")
private String staffId;
}

18
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/StaffOrgFormDTO.java

@ -0,0 +1,18 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 根据客户id查询组织结构信息入参
* @Author yinzuomei
* @Date 2020/4/20 21:42
*/
@Data
public class StaffOrgFormDTO implements Serializable {
private static final long serialVersionUID = 2514896455028592288L;
private List<String> customerIdList;
}

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffGridInfoResultDTO.java → epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/StaffLatestLoginGridResultDTO.java

@ -10,7 +10,7 @@ import java.io.Serializable;
* @Date 2020/4/20 15:22
*/
@Data
public class StaffGridInfoResultDTO implements Serializable {
public class StaffLatestLoginGridResultDTO implements Serializable {
/**
* ID 唯一标识
*/

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

@ -0,0 +1,31 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 政府端工作人员获取我的组织
* @Author yinzuomei
* @Date 2020/4/20 18:45
*/
@Data
public class StaffOrgsResultDTO implements Serializable {
private static final long serialVersionUID = -9148184731135509803L;
/**
* 组织id
*/
private String orgId;
/**
* 客户id
*/
private String customerId;
/**
* 组织名称
*/
private String orgName;
}

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

@ -23,9 +23,11 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.excel.CustomerAgencyExcel;
import com.epmet.service.CustomerAgencyService;
import org.springframework.beans.factory.annotation.Autowired;
@ -91,4 +93,15 @@ public class CustomerAgencyController {
ExcelUtils.exportExcelToTarget(response, null, list, CustomerAgencyExcel.class);
}
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.StaffOrgsResultDTO>>
* @param staffOrgsFormDTO
* @Author yinzuomei
* @Description 登录-获取工作人员所有组织
* @Date 2020/4/20 21:59
**/
@PostMapping("getStaffOrgList")
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(@RequestBody StaffOrgFormDTO staffOrgsFormDTO){
return customerAgencyService.getStaffOrgList(staffOrgsFormDTO);
}
}

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

@ -18,8 +18,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 机关单位信息表
@ -29,5 +33,12 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
/**
* @param customerIdList
* @return java.util.List<com.epmet.dto.result.StaffOrgsResultDTO>
* @Author yinzuomei
* @Description 查询客户对应的根级组织
* @Date 2020/4/20 21:48
**/
List<StaffOrgsResultDTO> selectStaffOrgList(@Param("customerIdList") List<String> customerIdList);
}

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

@ -19,7 +19,10 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import java.util.List;
@ -92,4 +95,13 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @date 2020-04-20
*/
void delete(String[] ids);
/**
* @param staffOrgsFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.StaffOrgsResultDTO>>
* @Author yinzuomei
* @Description 根据客户id查询组织名称
* @Date 2020/4/20 21:45
**/
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO);
}

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

@ -20,11 +20,14 @@ 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.constant.FieldConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService;
@ -101,4 +104,12 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO) {
if (null == staffOrgsFormDTO || staffOrgsFormDTO.getCustomerIdList().size() == 0) {
return new Result<>();
}
List<StaffOrgsResultDTO> list = baseDao.selectStaffOrgList(staffOrgsFormDTO.getCustomerIdList());
return new Result<List<StaffOrgsResultDTO>>().ok(list);
}
}

17
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -21,5 +21,20 @@
<result property="totalUser" column="TOTAL_USER"/>
</resultMap>
<!-- 查询客户对应的根级组织 -->
<select id="selectStaffOrgList" parameterType="map" resultType="com.epmet.dto.result.StaffOrgsResultDTO">
SELECT
cta.pid AS orgId,
cta.CUSTOMER_ID AS customerId,
cta.ORGANIZATION_NAME AS orgName
FROM
customer_staff_agency cta
WHERE
cta.DEL_FLAG = '0'
AND co.PID = '0'
and cta.CUSTOMER_ID IN
<foreach item="customerId" collection="customerIdList" open="(" separator="," close=")">
#{customerId}
</foreach>
</select>
</mapper>

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

@ -8,6 +8,7 @@
select * from customer_staff cs
where cs.MOBILE=#{mobile}
and cs.DEL_FLAG='1'
order by cs.ACTIVE_TIME desc,cs.CREATED_TIME asc
</select>
<!-- 根据手机号+客户id获取工作人员基本信息 -->

Loading…
Cancel
Save