Commit 42a1569b by 陶光胜

验证码接口

parent c7db237a
......@@ -48,11 +48,6 @@ public class UnionEnterpriseController {
@RequestMapping("save-union-enterprise")
public RestResponse saveUnionEnterprise(@RequestBody UnionEnterpriseQO unionEnterpriseQO){
RestResponse validateResult = this.validateAuthCode(unionEnterpriseQO);
if(validateResult != null){
return validateResult;
}
this.authCodeApiService.expireAuthCode(unionEnterpriseQO.getAuthCodeId());
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
UnionEnterpriseDTO enterpriseDTO = EntityUtil.changeEntityByJSON(UnionEnterpriseDTO.class, unionEnterpriseQO);
enterpriseDTO.setEnterpriseId(enterpriseId);
......@@ -77,6 +72,16 @@ public class UnionEnterpriseController {
return EnterpriseRestResponse.failure(response);
}
@RequestMapping("check-auth-code")
public RestResponse checkAuthCode(Integer authCodeId, String authCode){
ServiceResponse response = this.authCodeApiService.validateAuthCode(authCodeId, authCode);
this.authCodeApiService.expireAuthCode(authCodeId);
if(response.isSuccess()){
return RestResponse.success();
}
return EnterpriseRestResponse.failure(response);
}
@RequestMapping("union-enterprise-detail")
public RestResponse getUnionEnterpriseDetail(Integer unionId){
if(unionId == null){
......@@ -138,34 +143,10 @@ public class UnionEnterpriseController {
dto.setUnionManagerName(userResponse.getResult().getUserName());
dto.setUnionManagerPhone(userResponse.getResult().getPhoneNumber());
}
}
}
return RestResponse.success(result);
}
return RestResponse.success();
}
private RestResponse validateAuthCode(UnionEnterpriseQO unionEnterpriseQO){
ServiceResponse<AuthCodeDTO> authCode = this.authCodeApiService.getAuthCode(unionEnterpriseQO.getAuthCodeId());
if(authCode.isSuccess()){
AuthCodeDTO authCodeDTO = authCode.getResult();
if(authCodeDTO != null){
if(authCodeDTO.getStatus() == 0){
return EnterpriseRestResponse.failure(ErrorCode.AUTHCODE_USED);
}
if(authCodeDTO.getExpirationTime().before(new Date())){
return EnterpriseRestResponse.failure(ErrorCode.AUTHCODE_EXPIRE);
}
if(!authCodeDTO.getAuthCode().equals(unionEnterpriseQO.getAuthCode())){
return EnterpriseRestResponse.failure(ErrorCode.AUTHCODE_MISTAKE);
}
}else {
return EnterpriseRestResponse.failure(ErrorCode.AUTHCODE_ERR);
}
}else {
EnterpriseRestResponse.failure(ErrorCode.AUTHCODE_ERR);
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment