Commit 52036e3e authored by suhuiguang's avatar suhuiguang

1.业务审批通过更新证时,更新证版本号及原因

parent f784f9ac
......@@ -14,9 +14,8 @@ public class CertInfoRequestParam {
private String certNo;
/**
* 证类型:使用登记证、使用标志
* 证类型:useCert-使用登记证、useFlag-使用标志
*/
@NotBlank(message = "证类型不能为空!")
private String certType;
/**
......
package com.yeejoin.amos.boot.module.app.api.exception;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import static org.springframework.http.HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS;
public class AuthException extends BaseException {
public AuthException(String message) {
super(message, AuthException.class.getSimpleName(), "数据不合法");
this.httpStatus = UNAVAILABLE_FOR_LEGAL_REASONS.value();
}
}
......@@ -20,6 +20,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.net.InetAddress;
......@@ -56,6 +57,7 @@ public class AmosWeAppApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmosWeAppApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
......
......@@ -2,13 +2,13 @@ package com.yeejoin.amos.boot.module.app.biz.service.impl;
import com.yeejoin.amos.boot.biz.common.dto.JgUseRegistrationManageDto;
import com.yeejoin.amos.boot.module.app.api.dto.CertInfoRequestParam;
import com.yeejoin.amos.boot.module.app.api.exception.AuthException;
import com.yeejoin.amos.boot.module.app.api.mapper.AppCommonMapper;
import com.yeejoin.amos.boot.module.app.biz.strategy.SearchDetailStrategyContext;
import com.yeejoin.amos.boot.module.common.api.crypto.AESUtil;
import com.yeejoin.amos.boot.module.common.api.enums.CertificateStatusEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.validation.constraints.NotBlank;
import java.util.Map;
......@@ -25,7 +25,7 @@ public class CertDetailServiceImpl {
}
public Map<String, Object> getCertInfoForWX(CertInfoRequestParam requestParam) {
this.setDefaultVersionForOld(requestParam);
this.setDefaultFieldForOld(requestParam);
String certOrApplyNo = this.deCodeCertNo(requestParam.getCertNo());
String version = this.deCodeByAES(requestParam.getVersion());
String certType = this.deCodeByAES(requestParam.getCertType());
......@@ -33,39 +33,42 @@ public class CertDetailServiceImpl {
return SearchDetailStrategyContext.getHandler(this.getManageType(jgUseRegistrationManage)).hanlder(jgUseRegistrationManage, certType);
}
private void setDefaultVersionForOld(CertInfoRequestParam requestParam) {
private void setDefaultFieldForOld(CertInfoRequestParam requestParam) {
if (StringUtils.isBlank(requestParam.getVersion())) {
requestParam.setVersion(AESUtil.encrypt("1"));
}
if (StringUtils.isBlank(requestParam.getCertType())) {
requestParam.setCertType(AESUtil.encrypt("useCert"));
}
}
private JgUseRegistrationManageDto checkParam(String certOrApplyNo, String version) {
JgUseRegistrationManageDto jgUseRegistrationManage = commonMapper.selectOneCert(certOrApplyNo);
if (jgUseRegistrationManage == null) {
throw new BadRequest("无此证信息!");
throw new AuthException("无此证信息!");
}
// 表创建字段时已经给默认值 1 正常不为null 程序健壮处理
if (jgUseRegistrationManage.getVersion() == null) {
jgUseRegistrationManage.setVersion(1);
}
if (jgUseRegistrationManage.getVersion().toString().equals(version)) {
throw new BadRequest(this.buildErrorInfo(jgUseRegistrationManage));
if (!jgUseRegistrationManage.getVersion().toString().equals(version)) {
throw new AuthException(this.buildErrorInfo(jgUseRegistrationManage));
}
if (CertificateStatusEnum.YIZHUXIAO.getName().equals(jgUseRegistrationManage.getCertificateStatus())) {
throw new BadRequest("此证已注销!");
throw new AuthException("此证已注销!");
}
return jgUseRegistrationManage;
}
private String buildErrorInfo(JgUseRegistrationManageDto jgUseRegistrationManage) {
return "该证发生" + jgUseRegistrationManage.getChangeReason() + "导致证注销, 请联系监管单位进行换证!";
return "由于办理" + jgUseRegistrationManage.getChangeReason() + "业务导致该证注销, 请联系监管单位进行换证!";
}
private String deCodeByAES(@NotBlank(message = "证类型不能为空!") String data) {
try {
return AESUtil.decrypt(data);
} catch (Exception e) {
throw new BadRequest("非法的二维码!");
throw new AuthException("非法的二维码!");
}
}
......@@ -77,7 +80,7 @@ public class CertDetailServiceImpl {
try {
return AESUtil.decrypt(certNo);
} catch (Exception e) {
throw new BadRequest("非法的二维码!");
throw new AuthException("非法的二维码!");
}
}
......
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