Browse Source

Merge branch 'dev_plugins' into dev_temp

dev_shibei_match
sunyuchao 5 years ago
parent
commit
67ac1b4167
  1. 39
      epmet-auth/src/main/java/com/epmet/controller/GovWebController.java
  2. 46
      epmet-auth/src/main/java/com/epmet/dto/form/GovWebLoginFormDTO.java
  3. 2
      epmet-auth/src/main/java/com/epmet/dto/form/LoginCommonFormDTO.java
  4. 11
      epmet-auth/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  5. 6
      epmet-auth/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
  6. 19
      epmet-auth/src/main/java/com/epmet/service/GovWebService.java
  7. 124
      epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java
  8. 20
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/QueryFunctionListFormDTO.java
  9. 5
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/FunctionController.java
  10. 9
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/FunctionDao.java
  11. 3
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/FunctionService.java
  12. 5
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/FunctionServiceImpl.java
  13. 14
      epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/FunctionDao.xml
  14. 26
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerListFormDTO.java
  15. 21
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GovWebOperLoginFormDTO.java
  16. 23
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CustomerListResultDTO.java
  17. 16
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovWebOperLoginResultDTO.java
  18. 48
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java
  19. 42
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  20. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
  21. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java
  22. 33
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  23. 58
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  24. 14
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml
  25. 14
      epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

39
epmet-auth/src/main/java/com/epmet/controller/GovWebController.java

@ -0,0 +1,39 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.GovWebService;
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 PC工作端-登陆服务
* @author sun
*/
@RestController
@RequestMapping("govweb")
public class GovWebController {
@Autowired
private GovWebService govWebService;
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端-工作人员登录
**/
@PostMapping("login")
public Result<UserTokenResultDTO> workLogin(@RequestBody GovWebLoginFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<UserTokenResultDTO>().ok(govWebService.login(formDTO));
}
}

46
epmet-auth/src/main/java/com/epmet/dto/form/GovWebLoginFormDTO.java

@ -0,0 +1,46 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description PC工作端 手机号+密码登陆-接口入参
* @Author sun
*/
@Data
public class GovWebLoginFormDTO extends LoginCommonFormDTO implements Serializable {
private static final long serialVersionUID = 7950477424010655108L;
/**
* 客户Id
*/
@NotBlank(message = "客户Id不能为空",groups = {AddUserShowGroup.class})
private String customerId;
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空",groups = {AddUserShowGroup.class})
private String phone;
/**
* 密码
*/
@NotBlank(message = "密码不能为空",groups = {AddUserShowGroup.class})
private String password;
/**
* 验证码
*/
@NotBlank(message="验证码不能为空",groups = {AddUserShowGroup.class})
private String captcha;
/**
* 唯一标识
*/
@NotBlank(message="唯一标识不能为空",groups = {AddUserInternalGroup.class})
private String uuid;
}

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

@ -19,7 +19,7 @@ public class LoginCommonFormDTO implements Serializable {
/**
* 政府端:gov居民端:resi运营端:oper
*/
@NotBlank(message = "app不能为空(政府端:gov、居民端:resi、运营端:oper)",groups ={AddUserInternalGroup.class} )
@NotBlank(message = "app不能为空(工作端:gov、居民端:resi、运营端:oper)",groups ={AddUserInternalGroup.class} )
private String app;
/**

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

@ -7,6 +7,7 @@ import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.GovWebOperLoginResultDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.dto.result.StaffLatestAgencyResultDTO;
import com.epmet.feign.fallback.EpmetUserFeignClientFallback;
@ -115,4 +116,14 @@ public interface EpmetUserFeignClient {
*/
@PostMapping("/epmetuser/staffrole/staffroles")
Result<List<GovStaffRoleDTO>> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端登陆-根据客户Id和手机号查询登陆用户信息
**/
@PostMapping(value = "epmetuser/customerstaff/getstaffidandpwd", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<GovWebOperLoginResultDTO> getStaffIdAndPwd(@RequestBody GovWebOperLoginFormDTO formDTO);
}

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

@ -8,6 +8,7 @@ import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.UserDTO;
import com.epmet.dto.UserWechatDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.GovWebOperLoginResultDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.dto.result.StaffLatestAgencyResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
@ -68,4 +69,9 @@ public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff", staffRoleFormDTO);
}
@Override
public Result<GovWebOperLoginResultDTO> getStaffIdAndPwd(GovWebOperLoginFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffIdAndPwd", formDTO);
}
}

19
epmet-auth/src/main/java/com/epmet/service/GovWebService.java

@ -0,0 +1,19 @@
package com.epmet.service;
import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
/**
* @Description 第三方-居民端政府端登陆服务
* @author sun
*/
public interface GovWebService {
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端-工作人员登录
**/
UserTokenResultDTO login(GovWebLoginFormDTO formDTO);
}

124
epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java

@ -0,0 +1,124 @@
package com.epmet.service.impl;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
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.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.form.GovWebOperLoginFormDTO;
import com.epmet.dto.form.LoginByPassWordFormDTO;
import com.epmet.dto.form.PasswordLoginUserInfoFormDTO;
import com.epmet.dto.result.GovWebOperLoginResultDTO;
import com.epmet.dto.result.PasswordLoginUserInfoResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
import com.epmet.service.CaptchaService;
import com.epmet.service.GovWebService;
import lombok.extern.slf4j.Slf4j;
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.Map;
/**
* @author sun
* @Description 第三方-居民端政府端登陆服务
*/
@Slf4j
@Service
public class GovWebServiceImpl implements GovWebService {
private static final Logger logger = LoggerFactory.getLogger(GovWebServiceImpl.class);
@Autowired
private CaptchaService captchaService;
@Autowired
private JwtTokenUtils jwtTokenUtils;
@Autowired
private JwtTokenProperties jwtTokenProperties;
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端-工作人员登录
**/
@Override
public UserTokenResultDTO login(GovWebLoginFormDTO formDTO) {
//1.参数校验
if (!(LoginConstant.APP_GOV.equals(formDTO.getApp()) && LoginConstant.CLIENT_WEB.equals(formDTO.getClient()))) {
logger.error("当前接口只适用于PC工作端运营管理后台");
throw new RenException("当前接口只适用于PC工作端运营管理后台");
}
//2.验证码校验
boolean flag = captchaService.validate(formDTO.getUuid(), formDTO.getCaptcha());
if (!flag) {
logger.error(String.format("用户%s登录,验证码输入错误,暂时放行", formDTO.getPhone()));
//暂时关闭验证码校验 TODO
//throw new RenException(EpmetErrorCode.ERR10019.getCode());
}
//3.校验登陆账号是否存在
//根据客户Id和手机号查询登陆用户信息(此处不需要判断登陆人是否是有效客户以及是否是客户的根管理员,前一接口获取登陆手机号对应客户列表已经判断了)
GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO();
form.setCustomerId(formDTO.getCustomerId());
form.setMobile(formDTO.getPhone());
Result<GovWebOperLoginResultDTO> result = epmetUserFeignClient.getStaffIdAndPwd(form);
if (!result.success() || null == result.getData() || null == result.getData().getUserId()) {
logger.error("根据手机号查询PC工作端登陆人员信息失败,返回10003账号不存在");
throw new RenException(EpmetErrorCode.ERR10003.getCode());
}
GovWebOperLoginResultDTO resultDTO = result.getData();
//4.密码是否正确
//密码错误
if (!PasswordUtils.matches(formDTO.getPassword(), resultDTO.getPassWord())) {
logger.error("登陆密码错误");
throw new RenException(EpmetErrorCode.ERR10004.getCode());
}
//5.生成token存到redis并返回
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(this.packagingUserToken(formDTO, resultDTO.getUserId()));
return userTokenResultDTO;
}
/**
* 生成PC工作端token
* @author sun
*/
private String packagingUserToken(GovWebLoginFormDTO formDTO, String userId) {
// 生成token
Map<String, Object> map = new HashMap<>();
map.put("app", formDTO.getApp());
map.put("client", formDTO.getClient());
map.put("userId", userId);
String token = jwtTokenUtils.createToken(map);
logger.info("app:" + formDTO.getApp() + ";client:" + formDTO.getClient() + ";userId:" + userId + ";生成token[" + token + "]");
int expire = jwtTokenProperties.getExpire();
TokenDto tokenDto = new TokenDto();
tokenDto.setApp(formDTO.getApp());
tokenDto.setClient(formDTO.getClient());
tokenDto.setUserId(userId);
tokenDto.setToken(token);
tokenDto.setUpdateTime(System.currentTimeMillis());
tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
cpUserDetailRedis.set(tokenDto, expire);
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
return token;
}
}

20
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/form/QueryFunctionListFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 运营端-查询已上架功能列表-接口入参
* @author sun
*/
@Data
public class QueryFunctionListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 功能类型0.默认功能1.定制功能
*/
private String functionGroup;
}

5
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/FunctionController.java

@ -28,6 +28,7 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.FunctionDTO;
import com.epmet.dto.form.QueryFunctionListFormDTO;
import com.epmet.excel.FunctionExcel;
import com.epmet.service.FunctionService;
import org.springframework.beans.factory.annotation.Autowired;
@ -101,8 +102,8 @@ public class FunctionController {
* @Date 2020/3/23 22:11
**/
@GetMapping("queryFunctionList")
public Result<List<FunctionDTO>> queryFunctionList() {
return functionService.queryFunctionList();
public Result<List<FunctionDTO>> queryFunctionList(QueryFunctionListFormDTO formDTO) {
return functionService.queryFunctionList(formDTO);
}
/**

9
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/FunctionDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.FunctionDTO;
import com.epmet.dto.form.QueryFunctionListFormDTO;
import com.epmet.entity.FunctionEntity;
import org.apache.ibatis.annotations.Mapper;
@ -48,4 +49,12 @@ public interface FunctionDao extends BaseDao<FunctionEntity> {
* @Description 查询所有已上架功能列表(默认定制功能)
**/
List<FunctionDTO> selectShopFunctionList(int shoppingStatus);
/**
* @param
* @return java.util.List<com.epmet.dto.FunctionDTO>
* @Author sun
* @Description 查询已上架的所有功能供下拉框使用
**/
List<FunctionDTO> selectQueryFunctionList(QueryFunctionListFormDTO formDTO);
}

3
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/FunctionService.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.FunctionDTO;
import com.epmet.dto.form.QueryFunctionListFormDTO;
import com.epmet.entity.FunctionEntity;
import java.util.List;
@ -101,7 +102,7 @@ public interface FunctionService extends BaseService<FunctionEntity> {
* @description 查询已上架的所有功能供下拉框使用
* @Date 2020/3/23 22:10
**/
Result<List<FunctionDTO>> queryFunctionList();
Result<List<FunctionDTO>> queryFunctionList(QueryFunctionListFormDTO formDTO);
/**
* @param dto

5
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/FunctionServiceImpl.java

@ -28,6 +28,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.FunctionDao;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.FunctionDTO;
import com.epmet.dto.form.QueryFunctionListFormDTO;
import com.epmet.entity.CustomerFunctionEntity;
import com.epmet.entity.FunctionEntity;
import com.epmet.feign.OperCrmOpenFeignClient;
@ -125,8 +126,8 @@ public class FunctionServiceImpl extends BaseServiceImpl<FunctionDao, FunctionEn
* @Date 2020/3/23 22:10
**/
@Override
public Result<List<FunctionDTO>> queryFunctionList() {
return new Result<List<FunctionDTO>>().ok(baseDao.selectFunctionList());
public Result<List<FunctionDTO>> queryFunctionList(QueryFunctionListFormDTO formDTO) {
return new Result<List<FunctionDTO>>().ok(baseDao.selectQueryFunctionList(formDTO));
}
/**

14
epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/FunctionDao.xml

@ -38,4 +38,18 @@
AND
shopping_status = #{shoppingStatus}
</select>
<select id="selectQueryFunctionList" resultType="com.epmet.dto.FunctionDTO">
SELECT
f.id,
f.FUNCTION_NAME AS functionName
FROM
FUNCTION f
WHERE
f.DEL_FLAG = '0'
AND f.SHOPPING_STATUS = '1'
<if test="functionGroup != null and functionGroup.trim() != ''">
AND f.function_group = #{functionGroup}
</if>
</select>
</mapper>

26
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerListFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 查询登陆用户客户列表工作端
* @CreateTime 2020/8/25
*/
@Data
public class CustomerListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
public interface UserIdGroup extends CustomerClientShowGroup{}
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空",groups = UserIdGroup.class)
private String phone;
}

21
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/GovWebOperLoginFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description PC工作端登陆获取登陆人信息-接口入参
* @Author sun
*/
@Data
public class GovWebOperLoginFormDTO implements Serializable {
private static final long serialVersionUID = -6653010297552029277L;
@NotBlank(message = "客户Id不能为空")
private String customerId;
@NotBlank(message = "手机号不能为空")
private String mobile;
}

23
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CustomerListResultDTO.java

@ -0,0 +1,23 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 查询登陆用户客户列表工作端
* @CreateTime 2020/8/25
*/
@Data
public class CustomerListResultDTO implements Serializable {
/**
* 客户Id
*/
private String customerId;
/**
* 客户名称
*/
private String customerName;
}

16
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/GovWebOperLoginResultDTO.java

@ -0,0 +1,16 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description PC工作端登陆获取登陆人信息-接口返参
* @Author sun
*/
@Data
public class GovWebOperLoginResultDTO implements Serializable {
private static final long serialVersionUID = -5353521601282463394L;
private String userId;
private String passWord;
}

48
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/StaffBasicInfoResultDTO.java

@ -0,0 +1,48 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 获取pc工作端登陆用户信息
* @CreateTime 2020/8/25
*/
@Data
public class StaffBasicInfoResultDTO implements Serializable {
/**
* 客户Id
*/
private String customerId;
/**
* 用户Id
*/
private String userId;
/**
* 真实姓名
*/
private String realName;
/**
* 性别0.未知1男2.
*/
private String gender;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String mobile;
/**
* 地址
*/
private String address;
}

42
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -17,7 +17,9 @@
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.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
@ -359,4 +361,44 @@ public class CustomerStaffController {
customerStaffService.updateRootManage(formDTO);
return new Result();
}
/**
* 查询登陆用户客户列表工作端
* 根据手机号查询customer_staff表数据在根据查询到的数据的userId判断是不是根管理员最后将同一手机号对应的客户列表且该手机都是根管理员的客户列表返给前端
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerListResultDTO>>
* @Author zhangyong
* @Date 10:03 2020-08-25
**/
@PostMapping(value = "customerlist")
public Result<List<CustomerListResultDTO>> customerList(@RequestBody CustomerListFormDTO formDTO){
return customerStaffService.selectCustomerList(formDTO);
}
/**
* 获取pc工作端登陆用户信息
* 根据token中userId去查询登陆用户基本信息
* @param tokenDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.StaffBasicInfoResultDTO>
* @Author zhangyong
* @Date 11:09 2020-08-25
**/
@PostMapping(value = "staffbasicinfo")
public Result<StaffBasicInfoResultDTO> staffBasicInfo(@LoginUser TokenDto tokenDTO){
return customerStaffService.selectStaffBasicInfo(tokenDTO.getUserId());
}
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端登陆-根据客户Id和手机号查询登陆用户信息
**/
@PostMapping("getstaffidandpwd")
public Result<GovWebOperLoginResultDTO> getStaffIdAndPwd(@RequestBody GovWebOperLoginFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return new Result<GovWebOperLoginResultDTO>().ok(customerStaffService.getStaffIdAndPwd(formDTO));
}
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java

@ -172,4 +172,12 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
* @return com.epmet.dto.CustomerStaffDTO
*/
CustomerStaffDTO selectRootManage(@Param("orgId") String orgId, @Param("roleKey") String roleKey);
/**
* @param formDTO
* @return
* @Author sun
* @Description 根据客户Id和手机号查询工作人员信息
**/
GovWebOperLoginResultDTO selectByCustomerIdAndPhone(GovWebOperLoginFormDTO formDTO);
}

20
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/StaffRoleDao.java

@ -17,17 +17,18 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.annotation.DataFilter;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.commons.mybatis.entity.DataScope;
import com.epmet.dto.StaffRoleDTO;
import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.CustomerStaffRoleListFormDTO;
import com.epmet.dto.result.*;
import com.epmet.dto.result.CustomerStaffRoleListResultDTO;
import com.epmet.dto.result.CustomerStaffRoleResultDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.StaffRolesResultDTO;
import com.epmet.entity.StaffRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.context.annotation.Scope;
import java.util.List;
@ -100,4 +101,15 @@ public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
List<CustomerStaffRoleResultDTO> selectStaffRoles(@Param("staffId") String staffId);
List<StaffRoleEntity> listStaffRoleEntytiesByStaffIdAndOrgId(@Param("agencyId") String agencyId, @Param("staffId") String staffId);
}
/**
* 根据用户id角色id查询 工作人员-角色关系表
*
* @param staffId
* @param roleId
* @return com.epmet.dto.StaffRoleDTO
* @Author zhangyong
* @Date 10:45 2020-08-25
**/
StaffRoleDTO selectStaffRoleByStaffIdAndRoleId(@Param("staffId") String staffId, @Param("roleId") String roleId);
}

33
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java

@ -284,4 +284,35 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
* @return com.epmet.dto.CustomerStaffDTO
*/
void updateRootManage(UpdateRootManageFormDTO formDTO);
}
/**
* 查询登陆用户客户列表工作端
* 根据手机号查询customer_staff表数据在根据查询到的数据的userId判断是不是根管理员最后将同一手机号对应的客户列表且该手机都是根管理员的客户列表返给前端
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CustomerListResultDTO>>
* @Author zhangyong
* @Date 10:03 2020-08-25
**/
Result<List<CustomerListResultDTO>> selectCustomerList(CustomerListFormDTO formDTO);
/**
* 获取pc工作端登陆用户信息
* 根据token中userId去查询登陆用户基本信息
*
* @param userId
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.StaffBasicInfoResultDTO>
* @Author zhangyong
* @Date 11:10 2020-08-25
**/
Result<StaffBasicInfoResultDTO> selectStaffBasicInfo(String userId);
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端登陆-根据客户Id和手机号查询登陆用户信息
**/
GovWebOperLoginResultDTO getStaffIdAndPwd(GovWebOperLoginFormDTO formDTO);
}

58
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -17,12 +17,14 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.entity.DataScope;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
@ -47,6 +49,7 @@ import com.epmet.entity.StaffRoleEntity;
import com.epmet.entity.UserEntity;
import com.epmet.feign.AuthFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.redis.CustomerStaffRedis;
import com.epmet.service.CustomerStaffService;
import com.epmet.service.GovStaffRoleService;
@ -99,6 +102,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
private CustomerStaffDao customerStaffDao;
@Autowired
private GovStaffRoleDao govStaffRoleDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Override
public PageData<CustomerStaffDTO> page(Map<String, Object> params) {
@ -611,4 +616,55 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
update(dto);
}
}
@Override
public Result<List<CustomerListResultDTO>> selectCustomerList(CustomerListFormDTO formDTO) {
List<CustomerListResultDTO> listResultDTO = new ArrayList<>();
CustomerListResultDTO resultDTO = new CustomerListResultDTO();
CustomerDTO customerDTO = new CustomerDTO();
// 1.根据手机号,去 customer_staff表,进行查询; 查询结果 多条:字段 customer_id,user_id
List<CustomerStaffDTO> customerStaffList = baseDao.selectListCustomerStaffDTO(formDTO.getPhone());
for (CustomerStaffDTO staffDTO : customerStaffList){
// 2.根据 customer_id 去 gov_staff_role表,查询 customer_id + role_key = root_manager ,确定 根管理员的id,即roleId
GovStaffRoleDTO roleKey = govStaffRoleDao.getRoleByCustomerIdAndRoleKey(staffDTO.getCustomerId(), RoleKeyConstants.ROLE_KEY_ROOT_MANAGER);
// 3.根据roleId + staff_id(即 userId) 查 staff_role表的主键id, 如果查到了,那这个userId就是 根管理员
StaffRoleDTO staffRoleDTO = staffRoleDao.selectStaffRoleByStaffIdAndRoleId(staffDTO.getUserId(), roleKey.getId());
if (null != staffRoleDTO){
// 4.如果userID是根管理员的话,则根据customerId 去 customer表 查询 id、customer_name
customerDTO.setId(staffDTO.getCustomerId());
Result<CustomerDTO> customerInfo = operCrmOpenFeignClient.getCustomerInfo(customerDTO);
if (!customerInfo.success()) {
logger.error(String.format("获取根管理员信息失败,调用%s服务查询客户名称失败,入参%s", ServiceConstant.OPER_CRM_SERVER, JSON.toJSONString(staffDTO.getCustomerId())));
} else {
if (null != customerInfo.getData()){
resultDTO.setCustomerId(customerInfo.getData().getId());
resultDTO.setCustomerName(customerInfo.getData().getCustomerName());
listResultDTO.add(resultDTO);
}
}
}
}
return new Result<List<CustomerListResultDTO>>().ok(listResultDTO);
}
@Override
public Result<StaffBasicInfoResultDTO> selectStaffBasicInfo(String userId) {
CustomerStaffEntity staffEntity = baseDao.selectByUserId(userId);
StaffBasicInfoResultDTO resultDTO = ConvertUtils.sourceToTarget(staffEntity, StaffBasicInfoResultDTO.class);
resultDTO.setGender(String.valueOf(staffEntity.getGender()));
return new Result<StaffBasicInfoResultDTO>().ok(resultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端登陆-根据客户Id和手机号查询登陆用户信息
**/
@Override
public GovWebOperLoginResultDTO getStaffIdAndPwd(GovWebOperLoginFormDTO formDTO) {
//1.根据客户Id和手机号查询用户信息
return baseDao.selectByCustomerIdAndPhone(formDTO);
}
}

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

@ -295,4 +295,18 @@
AND r.DEL_FLAG = '0'
AND S.DEL_FLAG = '0'
</select>
<select id="selectByCustomerIdAndPhone" resultType="com.epmet.dto.result.GovWebOperLoginResultDTO">
SELECT
user_id AS "userId",
`password` AS "passWord"
FROM
`customer_staff`
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND mobile = #{mobile}
ORDER BY created_time DESC
LIMIT 1
</select>
</mapper>

14
epmet-user/epmet-user-server/src/main/resources/mapper/StaffRoleDao.xml

@ -164,4 +164,16 @@
and sr.ORG_ID = #{agencyId}
and sr.DEL_FLAG='0'
</select>
</mapper>
<select id="selectStaffRoleByStaffIdAndRoleId" resultType="com.epmet.dto.StaffRoleDTO">
select
ID id,
STAFF_ID staffId,
ROLE_ID roleId,
ORG_ID orgId
from staff_role sr
where sr.STAFF_ID = #{staffId}
and sr.ROLE_ID = #{roleId}
and sr.DEL_FLAG='0'
</select>
</mapper>

Loading…
Cancel
Save