bug问题修护

dev
huwei 2026-07-10 10:03:24 +08:00
parent e95baa8fbb
commit 46259ac287
6 changed files with 135 additions and 1 deletions

View File

@ -73,13 +73,58 @@ public class GlobalExceptionHandler {
message("request.invalid", exception.getMessage())); message("request.invalid", exception.getMessage()));
} }
@ExceptionHandler(com.alibaba.cola.exception.BizException.class)
public ResponseEntity<SingleResponse<Void>> handleColaBizException(
com.alibaba.cola.exception.BizException exception) {
LOGGER.warn("COLA BizException caught: {}", exception.getMessage());
String msg = exception.getMessage();
if (msg == null || msg.isEmpty()) {
msg = "业务处理异常";
}
return response(HttpStatus.OK, SYSTEM_ERROR_CODE, msg);
}
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public ResponseEntity<SingleResponse<Void>> handleUnexpectedException(Exception exception) { public ResponseEntity<SingleResponse<Void>> handleUnexpectedException(Exception exception) {
// 尝试从 cause 中提取有意义的错误信息
Throwable cause = findBizExceptionCause(exception);
if (cause instanceof BizException) {
BizException bizEx = (BizException) cause;
String message = message("error." + bizEx.getCode(), bizEx.getMessage());
LOGGER.warn("Unwrapped BizException from controller exception: {}", message);
return response(HttpStatus.OK, bizEx.getCode(), message);
}
if (cause instanceof com.alibaba.cola.exception.BizException) {
com.alibaba.cola.exception.BizException colaBizEx =
(com.alibaba.cola.exception.BizException) cause;
LOGGER.warn("Unwrapped COLA BizException from controller exception: {}",
colaBizEx.getMessage());
String msg = colaBizEx.getMessage();
if (msg == null || msg.isEmpty()) {
msg = "业务处理异常";
}
return response(HttpStatus.OK, SYSTEM_ERROR_CODE, msg);
}
LOGGER.error("Unhandled controller exception", exception); LOGGER.error("Unhandled controller exception", exception);
return response(HttpStatus.OK, SYSTEM_ERROR_CODE, return response(HttpStatus.OK, SYSTEM_ERROR_CODE,
message("system.error", "Internal server error")); message("system.error", "Internal server error"));
} }
/**
* BizException COLA
*/
private Throwable findBizExceptionCause(Throwable exception) {
Throwable cause = exception.getCause();
while (cause != null) {
if (cause instanceof BizException
|| cause instanceof com.alibaba.cola.exception.BizException) {
return cause;
}
cause = cause.getCause();
}
return null;
}
private ResponseEntity<SingleResponse<Void>> response(HttpStatus status, String code, String message) { private ResponseEntity<SingleResponse<Void>> response(HttpStatus status, String code, String message) {
return ResponseEntity.status(status).body(SingleResponse.error(code, message)); return ResponseEntity.status(status).body(SingleResponse.error(code, message));
} }

View File

@ -77,7 +77,14 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
userAddCmd.setName(result.getUserName()); userAddCmd.setName(result.getUserName());
String encrypt = Sm2Util.encryptHex(MD5.md5(defPassword), publicKey); String encrypt = Sm2Util.encryptHex(MD5.md5(defPassword), publicKey);
userAddCmd.setPassword(encrypt); userAddCmd.setPassword(encrypt);
try {
gbsUserFacadeClient.add(userAddCmd); gbsUserFacadeClient.add(userAddCmd);
} catch (RuntimeException ex) {
LOGGER.warn("GBS user sync failed while adding personnel", ex);
if (gbsUserSyncFailFast) {
throw ex;
}
}
return SingleResponse.success(co); return SingleResponse.success(co);
} }

View File

@ -2,6 +2,8 @@ package org.qinan.safetyeval.client.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDate; import java.time.LocalDate;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
/** /**
@ -12,93 +14,121 @@ import lombok.Data;
@Data @Data
public class OrgPersonnelAddCmd { public class OrgPersonnelAddCmd {
@Size(max = 50, message = "姓名长度不能超过50个字符")
@ApiModelProperty(value = "用户名称/姓名") @ApiModelProperty(value = "用户名称/姓名")
private String userName; private String userName;
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "账号格式不正确请输入11位手机号")
@Size(max = 50, message = "账号长度不能超过50个字符")
@ApiModelProperty(value = "账号") @ApiModelProperty(value = "账号")
private String account; private String account;
@ApiModelProperty(value = "性别编码(1男2女)") @ApiModelProperty(value = "性别编码(1男2女)")
private Integer genderCode; private Integer genderCode;
@Size(max = 10, message = "性别名称长度不能超过10个字符")
@ApiModelProperty(value = "性别名称") @ApiModelProperty(value = "性别名称")
private String genderName; private String genderName;
@ApiModelProperty(value = "出生日期") @ApiModelProperty(value = "出生日期")
private LocalDate birthDate; private LocalDate birthDate;
@Pattern(regexp = "^\\d{17}[\\dXx]$", message = "身份证号格式不正确")
@Size(max = 18, message = "身份证号长度不能超过18个字符")
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
private String idCardNo; private String idCardNo;
@Size(max = 500, message = "现住地址长度不能超过500个字符")
@ApiModelProperty(value = "现住地址") @ApiModelProperty(value = "现住地址")
private String currentAddress; private String currentAddress;
@Size(max = 500, message = "办公地址长度不能超过500个字符")
@ApiModelProperty(value = "办公地址") @ApiModelProperty(value = "办公地址")
private String officeAddress; private String officeAddress;
@Size(max = 32, message = "学历编码长度不能超过32个字符")
@ApiModelProperty(value = "学历编码") @ApiModelProperty(value = "学历编码")
private String educationCode; private String educationCode;
@Size(max = 50, message = "学历名称长度不能超过50个字符")
@ApiModelProperty(value = "学历名称") @ApiModelProperty(value = "学历名称")
private String educationName; private String educationName;
@Size(max = 200, message = "毕业院校长度不能超过200个字符")
@ApiModelProperty(value = "毕业院校") @ApiModelProperty(value = "毕业院校")
private String graduateSchool; private String graduateSchool;
@Size(max = 100, message = "专业长度不能超过100个字符")
@ApiModelProperty(value = "专业") @ApiModelProperty(value = "专业")
private String major; private String major;
@ApiModelProperty(value = "就职状态编码(1在职2离职)") @ApiModelProperty(value = "就职状态编码(1在职2离职)")
private Integer employmentStatusCode; private Integer employmentStatusCode;
@Size(max = 50, message = "就职状态名称长度不能超过50个字符")
@ApiModelProperty(value = "就职状态名称") @ApiModelProperty(value = "就职状态名称")
private String employmentStatusName; private String employmentStatusName;
@Size(max = 32, message = "人员类型编码长度不能超过32个字符")
@ApiModelProperty(value = "人员类型编码(1基础人员2专职评价师)") @ApiModelProperty(value = "人员类型编码(1基础人员2专职评价师)")
private String personTypeCode; private String personTypeCode;
@Size(max = 50, message = "人员类型名称长度不能超过50个字符")
@ApiModelProperty(value = "人员类型名称") @ApiModelProperty(value = "人员类型名称")
private String personTypeName; private String personTypeName;
@Size(max = 500, message = "资质范围长度不能超过500个字符")
@ApiModelProperty(value = "资质范围") @ApiModelProperty(value = "资质范围")
private String qualScope; private String qualScope;
@Size(max = 32, message = "职业等级编码长度不能超过32个字符")
@ApiModelProperty(value = "职业等级编码") @ApiModelProperty(value = "职业等级编码")
private String professionalLevelCode; private String professionalLevelCode;
@Size(max = 200, message = "职业等级名称长度不能超过200个字符")
@ApiModelProperty(value = "职业等级名称") @ApiModelProperty(value = "职业等级名称")
private String professionalLevelName; private String professionalLevelName;
@Size(max = 100, message = "证书编号长度不能超过100个字符")
@ApiModelProperty(value = "安全评价师证书编号") @ApiModelProperty(value = "安全评价师证书编号")
private String evaluatorCertNo; private String evaluatorCertNo;
@Size(max = 32, message = "学历类型编码长度不能超过32个字符")
@ApiModelProperty(value = "学历类型编码(全日制/在职教育)") @ApiModelProperty(value = "学历类型编码(全日制/在职教育)")
private String educationTypeCode; private String educationTypeCode;
@Size(max = 50, message = "学历类型名称长度不能超过50个字符")
@ApiModelProperty(value = "学历类型名称") @ApiModelProperty(value = "学历类型名称")
private String educationTypeName; private String educationTypeName;
@Size(max = 32, message = "学历层次编码长度不能超过32个字符")
@ApiModelProperty(value = "学历层次编码(专科/本科/硕士/博士)") @ApiModelProperty(value = "学历层次编码(专科/本科/硕士/博士)")
private String educationLevelCode; private String educationLevelCode;
@Size(max = 50, message = "学历层次名称长度不能超过50个字符")
@ApiModelProperty(value = "学历层次名称") @ApiModelProperty(value = "学历层次名称")
private String educationLevelName; private String educationLevelName;
@Size(max = 50, message = "职称长度不能超过50个字符")
@ApiModelProperty(value = "职称") @ApiModelProperty(value = "职称")
private String titleName; private String titleName;
@ApiModelProperty(value = "是否注册安全工程师(1是2否)") @ApiModelProperty(value = "是否注册安全工程师(1是2否)")
private Integer registerEngineerFlag; private Integer registerEngineerFlag;
@Size(max = 1000, message = "出版学术专著等长度不能超过1000个字符")
@ApiModelProperty(value = "出版学术专著专利获奖论文等") @ApiModelProperty(value = "出版学术专著专利获奖论文等")
private String publications; private String publications;
@Size(max = 1000, message = "专业能力及认定方式长度不能超过1000个字符")
@ApiModelProperty(value = "自我申报的专业能力及认定方式") @ApiModelProperty(value = "自我申报的专业能力及认定方式")
private String abilityDeclaration; private String abilityDeclaration;
@Size(max = 65535, message = "工作经历长度不能超过65535个字符")
@ApiModelProperty(value = "主要学习工作经历") @ApiModelProperty(value = "主要学习工作经历")
private String workExperience; private String workExperience;
@Size(max = 2000, message = "证明材料地址长度不能超过2000个字符")
@ApiModelProperty(value = "申报专业能力证明材料地址") @ApiModelProperty(value = "申报专业能力证明材料地址")
private String proofMaterialUrl; private String proofMaterialUrl;

View File

@ -2,6 +2,7 @@ package org.qinan.safetyeval.client.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDate; import java.time.LocalDate;
import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
/** /**
@ -13,30 +14,39 @@ import lombok.Data;
public class OrgPersonnelCertAddCmd { public class OrgPersonnelCertAddCmd {
@ApiModelProperty(value = "证照名称") @ApiModelProperty(value = "证照名称")
@Size(max = 200, message = "证照名称不能超过200个字符")
private String certName; private String certName;
@ApiModelProperty(value = "证书类型编码") @ApiModelProperty(value = "证书类型编码")
@Size(max = 32, message = "证书类型编码不能超过32个字符")
private String certTypeCode; private String certTypeCode;
@ApiModelProperty(value = "证书类型名称") @ApiModelProperty(value = "证书类型名称")
@Size(max = 50, message = "证书类型名称不能超过50个字符")
private String certTypeName; private String certTypeName;
@ApiModelProperty(value = "证书类别编码") @ApiModelProperty(value = "证书类别编码")
@Size(max = 32, message = "证书类别编码不能超过32个字符")
private String certCategoryCode; private String certCategoryCode;
@ApiModelProperty(value = "证书类别名称") @ApiModelProperty(value = "证书类别名称")
@Size(max = 50, message = "证书类别名称不能超过50个字符")
private String certCategoryName; private String certCategoryName;
@ApiModelProperty(value = "证书作业类别编码") @ApiModelProperty(value = "证书作业类别编码")
@Size(max = 32, message = "证书作业类别编码不能超过32个字符")
private String operationCategoryCode; private String operationCategoryCode;
@ApiModelProperty(value = "证书作业类别名称") @ApiModelProperty(value = "证书作业类别名称")
@Size(max = 50, message = "证书作业类别名称不能超过50个字符")
private String operationCategoryName; private String operationCategoryName;
@ApiModelProperty(value = "证书编号") @ApiModelProperty(value = "证书编号")
@Size(max = 100, message = "证书编号不能超过100个字符")
private String certNo; private String certNo;
@ApiModelProperty(value = "发证机关") @ApiModelProperty(value = "发证机关")
@Size(max = 200, message = "发证机关不能超过200个字符")
private String issueOrg; private String issueOrg;
@ApiModelProperty(value = "证书有效开始日期") @ApiModelProperty(value = "证书有效开始日期")
@ -49,6 +59,7 @@ public class OrgPersonnelCertAddCmd {
private LocalDate reviewDate; private LocalDate reviewDate;
@ApiModelProperty(value = "证书附件地址") @ApiModelProperty(value = "证书附件地址")
@Size(max = 500, message = "证书附件地址不能超过500个字符")
private String certAttachmentUrl; private String certAttachmentUrl;
@ApiModelProperty(value = "人员id") @ApiModelProperty(value = "人员id")

View File

@ -2,6 +2,7 @@ package org.qinan.safetyeval.client.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDate; import java.time.LocalDate;
import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
/** /**
@ -16,30 +17,39 @@ public class OrgPersonnelCertModifyCmd {
private Long id; private Long id;
@ApiModelProperty(value = "证照名称") @ApiModelProperty(value = "证照名称")
@Size(max = 200, message = "证照名称不能超过200个字符")
private String certName; private String certName;
@ApiModelProperty(value = "证书类型编码") @ApiModelProperty(value = "证书类型编码")
@Size(max = 32, message = "证书类型编码不能超过32个字符")
private String certTypeCode; private String certTypeCode;
@ApiModelProperty(value = "证书类型名称") @ApiModelProperty(value = "证书类型名称")
@Size(max = 50, message = "证书类型名称不能超过50个字符")
private String certTypeName; private String certTypeName;
@ApiModelProperty(value = "证书类别编码") @ApiModelProperty(value = "证书类别编码")
@Size(max = 32, message = "证书类别编码不能超过32个字符")
private String certCategoryCode; private String certCategoryCode;
@ApiModelProperty(value = "证书类别名称") @ApiModelProperty(value = "证书类别名称")
@Size(max = 50, message = "证书类别名称不能超过50个字符")
private String certCategoryName; private String certCategoryName;
@ApiModelProperty(value = "证书作业类别编码") @ApiModelProperty(value = "证书作业类别编码")
@Size(max = 32, message = "证书作业类别编码不能超过32个字符")
private String operationCategoryCode; private String operationCategoryCode;
@ApiModelProperty(value = "证书作业类别名称") @ApiModelProperty(value = "证书作业类别名称")
@Size(max = 50, message = "证书作业类别名称不能超过50个字符")
private String operationCategoryName; private String operationCategoryName;
@ApiModelProperty(value = "证书编号") @ApiModelProperty(value = "证书编号")
@Size(max = 100, message = "证书编号不能超过100个字符")
private String certNo; private String certNo;
@ApiModelProperty(value = "发证机关") @ApiModelProperty(value = "发证机关")
@Size(max = 200, message = "发证机关不能超过200个字符")
private String issueOrg; private String issueOrg;
@ApiModelProperty(value = "证书有效开始日期") @ApiModelProperty(value = "证书有效开始日期")
@ -52,6 +62,7 @@ public class OrgPersonnelCertModifyCmd {
private LocalDate reviewDate; private LocalDate reviewDate;
@ApiModelProperty(value = "证书附件地址") @ApiModelProperty(value = "证书附件地址")
@Size(max = 500, message = "证书附件地址不能超过500个字符")
private String certAttachmentUrl; private String certAttachmentUrl;
@ApiModelProperty(value = "人员id") @ApiModelProperty(value = "人员id")

View File

@ -2,6 +2,8 @@ package org.qinan.safetyeval.client.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDate; import java.time.LocalDate;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
/** /**
@ -15,93 +17,121 @@ public class OrgPersonnelModifyCmd {
@ApiModelProperty(value = "主键ID") @ApiModelProperty(value = "主键ID")
private Long id; private Long id;
@Size(max = 50, message = "姓名长度不能超过50个字符")
@ApiModelProperty(value = "用户名称/姓名") @ApiModelProperty(value = "用户名称/姓名")
private String userName; private String userName;
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "账号格式不正确请输入11位手机号")
@Size(max = 50, message = "账号长度不能超过50个字符")
@ApiModelProperty(value = "账号") @ApiModelProperty(value = "账号")
private String account; private String account;
@ApiModelProperty(value = "性别编码(1男2女)") @ApiModelProperty(value = "性别编码(1男2女)")
private Integer genderCode; private Integer genderCode;
@Size(max = 10, message = "性别名称长度不能超过10个字符")
@ApiModelProperty(value = "性别名称") @ApiModelProperty(value = "性别名称")
private String genderName; private String genderName;
@ApiModelProperty(value = "出生日期") @ApiModelProperty(value = "出生日期")
private LocalDate birthDate; private LocalDate birthDate;
@Pattern(regexp = "^\\d{17}[\\dXx]$", message = "身份证号格式不正确")
@Size(max = 18, message = "身份证号长度不能超过18个字符")
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
private String idCardNo; private String idCardNo;
@Size(max = 500, message = "现住地址长度不能超过500个字符")
@ApiModelProperty(value = "现住地址") @ApiModelProperty(value = "现住地址")
private String currentAddress; private String currentAddress;
@Size(max = 500, message = "办公地址长度不能超过500个字符")
@ApiModelProperty(value = "办公地址") @ApiModelProperty(value = "办公地址")
private String officeAddress; private String officeAddress;
@Size(max = 32, message = "学历编码长度不能超过32个字符")
@ApiModelProperty(value = "学历编码") @ApiModelProperty(value = "学历编码")
private String educationCode; private String educationCode;
@Size(max = 50, message = "学历名称长度不能超过50个字符")
@ApiModelProperty(value = "学历名称") @ApiModelProperty(value = "学历名称")
private String educationName; private String educationName;
@Size(max = 200, message = "毕业院校长度不能超过200个字符")
@ApiModelProperty(value = "毕业院校") @ApiModelProperty(value = "毕业院校")
private String graduateSchool; private String graduateSchool;
@Size(max = 100, message = "专业长度不能超过100个字符")
@ApiModelProperty(value = "专业") @ApiModelProperty(value = "专业")
private String major; private String major;
@ApiModelProperty(value = "就职状态编码(1在职2离职)") @ApiModelProperty(value = "就职状态编码(1在职2离职)")
private Integer employmentStatusCode; private Integer employmentStatusCode;
@Size(max = 50, message = "就职状态名称长度不能超过50个字符")
@ApiModelProperty(value = "就职状态名称") @ApiModelProperty(value = "就职状态名称")
private String employmentStatusName; private String employmentStatusName;
@Size(max = 32, message = "人员类型编码长度不能超过32个字符")
@ApiModelProperty(value = "人员类型编码(1基础人员2专职评价师)") @ApiModelProperty(value = "人员类型编码(1基础人员2专职评价师)")
private String personTypeCode; private String personTypeCode;
@Size(max = 50, message = "人员类型名称长度不能超过50个字符")
@ApiModelProperty(value = "人员类型名称") @ApiModelProperty(value = "人员类型名称")
private String personTypeName; private String personTypeName;
@Size(max = 500, message = "资质范围长度不能超过500个字符")
@ApiModelProperty(value = "资质范围") @ApiModelProperty(value = "资质范围")
private String qualScope; private String qualScope;
@Size(max = 32, message = "职业等级编码长度不能超过32个字符")
@ApiModelProperty(value = "职业等级编码") @ApiModelProperty(value = "职业等级编码")
private String professionalLevelCode; private String professionalLevelCode;
@Size(max = 200, message = "职业等级名称长度不能超过200个字符")
@ApiModelProperty(value = "职业等级名称") @ApiModelProperty(value = "职业等级名称")
private String professionalLevelName; private String professionalLevelName;
@Size(max = 100, message = "证书编号长度不能超过100个字符")
@ApiModelProperty(value = "安全评价师证书编号") @ApiModelProperty(value = "安全评价师证书编号")
private String evaluatorCertNo; private String evaluatorCertNo;
@Size(max = 32, message = "学历类型编码长度不能超过32个字符")
@ApiModelProperty(value = "学历类型编码(全日制/在职教育)") @ApiModelProperty(value = "学历类型编码(全日制/在职教育)")
private String educationTypeCode; private String educationTypeCode;
@Size(max = 50, message = "学历类型名称长度不能超过50个字符")
@ApiModelProperty(value = "学历类型名称") @ApiModelProperty(value = "学历类型名称")
private String educationTypeName; private String educationTypeName;
@Size(max = 32, message = "学历层次编码长度不能超过32个字符")
@ApiModelProperty(value = "学历层次编码(专科/本科/硕士/博士)") @ApiModelProperty(value = "学历层次编码(专科/本科/硕士/博士)")
private String educationLevelCode; private String educationLevelCode;
@Size(max = 50, message = "学历层次名称长度不能超过50个字符")
@ApiModelProperty(value = "学历层次名称") @ApiModelProperty(value = "学历层次名称")
private String educationLevelName; private String educationLevelName;
@Size(max = 50, message = "职称长度不能超过50个字符")
@ApiModelProperty(value = "职称") @ApiModelProperty(value = "职称")
private String titleName; private String titleName;
@ApiModelProperty(value = "是否注册安全工程师(1是2否)") @ApiModelProperty(value = "是否注册安全工程师(1是2否)")
private Integer registerEngineerFlag; private Integer registerEngineerFlag;
@Size(max = 1000, message = "出版学术专著等长度不能超过1000个字符")
@ApiModelProperty(value = "出版学术专著专利获奖论文等") @ApiModelProperty(value = "出版学术专著专利获奖论文等")
private String publications; private String publications;
@Size(max = 1000, message = "专业能力及认定方式长度不能超过1000个字符")
@ApiModelProperty(value = "自我申报的专业能力及认定方式") @ApiModelProperty(value = "自我申报的专业能力及认定方式")
private String abilityDeclaration; private String abilityDeclaration;
@Size(max = 65535, message = "工作经历长度不能超过65535个字符")
@ApiModelProperty(value = "主要学习工作经历") @ApiModelProperty(value = "主要学习工作经历")
private String workExperience; private String workExperience;
@Size(max = 2000, message = "证明材料地址长度不能超过2000个字符")
@ApiModelProperty(value = "申报专业能力证明材料地址") @ApiModelProperty(value = "申报专业能力证明材料地址")
private String proofMaterialUrl; private String proofMaterialUrl;