Browse Source

修改:

1.区块链用户身份认证调整,增加字段,url变化
master
wangxianzhang 4 years ago
parent
commit
a286d4030f
  1. 7
      epmet-auth-client/pom.xml
  2. 25
      epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java
  3. 21
      epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java
  4. 20
      epmet-auth/src/main/java/com/epmet/controller/GovWebController.java
  5. 8
      epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
  6. 9
      epmet-auth/src/main/java/com/epmet/service/GovWebService.java
  7. 25
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
  8. 41
      epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java

7
epmet-auth-client/pom.xml

@ -11,4 +11,11 @@
<artifactId>epmet-auth-client</artifactId>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</project>

25
epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.auth.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @ClassName BlockChainStaffAuthResultDTO
* @Description 区块链用户认证结果
* @Author wangxianzhang
* @Date 2022/1/20 10:41 上午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BlockChainStaffAuthResultDTO {
private String userId;
private String realName;
private String phone;
private String headUrl;
private String agencyId;
private String agencyName;
}

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

@ -122,26 +122,5 @@ public class GovLoginController {
List<StaffOrgsResultDTO> staffOrgs = govLoginService.getMyOrgByPassword(formDTO);
return new Result<List<StaffOrgsResultDTO>>().ok(staffOrgs);
}
/**
* 区块链web 系统身份认证
* @param input
* @return
*/
@PostMapping("/blockchain/authentication")
public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) {
ValidatorUtils.validateEntity(input);
String customerId = input.getCustomerId();
String mobile = input.getMobile();
String password = input.getPassword();
String userId = govLoginService.blockChainStaffAuthenticationByPwd(customerId, mobile, password);
HashMap<String, String> m = new HashMap<>();
m.put("userId", userId);
return new Result().ok(m);
}
}

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

@ -1,8 +1,10 @@
package com.epmet.controller;
import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO;
import com.epmet.commons.tools.utils.RSASignature;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.BcStaffAuthenticationFormDTO;
import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.GovWebService;
@ -13,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.HashMap;
/**
* @author sun
@ -63,5 +67,21 @@ public class GovWebController {
return new Result().ok(publicKey);
}
/**
* 区块链web 系统身份认证
* @param input
* @return
*/
@PostMapping("/blockchain/authentication")
public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) {
ValidatorUtils.validateEntity(input);
String customerId = input.getCustomerId();
String mobile = input.getMobile();
String password = input.getPassword();
BlockChainStaffAuthResultDTO r = govWebService.blockChainStaffAuthenticationByPwd(customerId, mobile, password);
return new Result().ok(r);
}
}

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

@ -76,12 +76,4 @@ public interface GovLoginService {
* @Date 2020/6/30 22:43
**/
List<StaffOrgsResultDTO> getMyOrgByPassword(StaffOrgsFormDTO formDTO);
/**
* 区块链系统通过用户密码认证身份
* @param mobile
* @param password
* @return
*/
String blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password);
}

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

@ -1,5 +1,6 @@
package com.epmet.service;
import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO;
import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
@ -16,4 +17,12 @@ public interface GovWebService {
* @Description PC工作端-工作人员登录
**/
UserTokenResultDTO login(GovWebLoginFormDTO formDTO);
/**
* 区块链系统通过用户密码认证身份
* @param mobile
* @param password
* @return
*/
BlockChainStaffAuthResultDTO blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password);
}

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

@ -492,30 +492,5 @@ public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver
}
return result.getData();
}
@Override
public String blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password) {
GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO();
form.setCustomerId(customerId);
form.setMobile(mobile);
GovWebOperLoginResultDTO staff = getResultDataOrThrowsException(epmetUserFeignClient.getStaffIdAndPwd(form), ServiceConstant.EPMET_USER_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
String.format("【区块链获取用户信息】根据手机号%s和指定客户ID:%s查找用户信息失败", mobile, customerId),
"查询用户失败");
if (staff == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
String.format("【区块链获取用户信息】根据手机号%s和指定客户ID:%s查找用户信息失败", mobile, customerId));
}
if (!PasswordUtils.matches(password, staff.getPassWord())) {
// 密码不匹配
throw new EpmetException(EpmetErrorCode.ERR10004.getCode(), String.format("【区块链获取用户信息】密码不匹配,手机号:%s", mobile));
}
return staff.getUserId();
}
}

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

@ -1,13 +1,21 @@
package com.epmet.service.impl;
import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.GovTokenDto;
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.CustomerStaffDTO;
import com.epmet.dto.form.CustomerStaffFormDTO;
import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.form.GovWebOperLoginFormDTO;
import com.epmet.dto.result.GovWebOperLoginResultDTO;
@ -32,7 +40,7 @@ import java.util.Map;
*/
@Slf4j
@Service
public class GovWebServiceImpl implements GovWebService {
public class GovWebServiceImpl implements GovWebService, ResultDataResolver {
private static final Logger logger = LoggerFactory.getLogger(GovWebServiceImpl.class);
@Autowired
@ -131,5 +139,36 @@ public class GovWebServiceImpl implements GovWebService {
return token;
}
@Override
public BlockChainStaffAuthResultDTO blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password) {
GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO();
form.setCustomerId(customerId);
form.setMobile(mobile);
// 用户认证
GovWebOperLoginResultDTO staff = getResultDataOrThrowsException(epmetUserFeignClient.getStaffIdAndPwd(form), ServiceConstant.EPMET_USER_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
String.format("【区块链用户认证】根据手机号%s和指定客户ID:%s认证用户失败", mobile, customerId),
"认证失败");
if (staff == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
String.format("【区块链用户认证】根据手机号%s和指定客户ID:%s认证用户失败", mobile, customerId));
}
if (!PasswordUtils.matches(password, staff.getPassWord())) {
// 密码不匹配
throw new EpmetException(EpmetErrorCode.ERR10004.getCode(), String.format("【区块链用户认证】密码不匹配,手机号:%s", mobile));
}
// 用户基础信息
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, staff.getUserId());
BlockChainStaffAuthResultDTO r = new BlockChainStaffAuthResultDTO(staff.getUserId(), staffInfo.getRealName(),
staffInfo.getMobile(), staffInfo.getHeadPhoto(), staffInfo.getAgencyId(), staffInfo.getAgencyName());
return r;
}
}

Loading…
Cancel
Save