Browse Source

新增:

1.【区块链】区块链web界面用户身份认证
feature/evaluate
wangxianzhang 4 years ago
parent
commit
468ff87bb5
  1. 22
      epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java
  2. 24
      epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java
  3. 8
      epmet-auth/src/main/java/com/epmet/service/GovLoginService.java
  4. 29
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java

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

@ -14,6 +14,7 @@ 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;
import java.util.List;
/**
@ -121,5 +122,26 @@ 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);
}
}

24
epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java

@ -0,0 +1,24 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @ClassName BcAdminLoginFormDTO
* @Description 区块链管理系统staff身份认证
* @Author wangxianzhang
* @Date 2022/1/17 10:11 下午
*/
@Data
public class BcStaffAuthenticationFormDTO {
@NotBlank(message = "客户ID必填")
private String customerId;
@NotBlank(message = "手机号必填")
private String mobile;
@NotBlank(message = "密码必填")
private String password;
}

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

@ -76,4 +76,12 @@ 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);
}

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

@ -5,8 +5,10 @@ import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.password.PasswordUtils;
@ -46,7 +48,7 @@ import java.util.stream.Collectors;
* @Date 2020/4/20 10:56
*/
@Service
public class GovLoginServiceImpl implements GovLoginService {
public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver {
private static final Logger logger = LoggerFactory.getLogger(GovLoginServiceImpl.class);
private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]";
@Autowired
@ -490,5 +492,30 @@ public class GovLoginServiceImpl implements GovLoginService {
}
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();
}
}

Loading…
Cancel
Save