Commit 4c3997b628130df6ca28f0b159f2da4db22d96d9
1 parent
eb3ad700
完成错误码
Showing
19 changed files
with
964 additions
and
0 deletions
src/main/java/cn/iocoder/dashboard/framework/validator/InEnum.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.framework.validator; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.core.IntArrayValuable; | |
| 4 | + | |
| 5 | +import javax.validation.Constraint; | |
| 6 | +import javax.validation.Payload; | |
| 7 | +import java.lang.annotation.*; | |
| 8 | + | |
| 9 | +@Target({ | |
| 10 | + ElementType.METHOD, | |
| 11 | + ElementType.FIELD, | |
| 12 | + ElementType.ANNOTATION_TYPE, | |
| 13 | + ElementType.CONSTRUCTOR, | |
| 14 | + ElementType.PARAMETER, | |
| 15 | + ElementType.TYPE_USE | |
| 16 | +}) | |
| 17 | +@Retention(RetentionPolicy.RUNTIME) | |
| 18 | +@Documented | |
| 19 | +@Constraint( | |
| 20 | + validatedBy = InEnumValidator.class | |
| 21 | +) | |
| 22 | +public @interface InEnum { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * @return 实现 EnumValuable 接口的 | |
| 26 | + */ | |
| 27 | + Class<? extends IntArrayValuable> value(); | |
| 28 | + | |
| 29 | + String message() default "必须在指定范围 {value}"; | |
| 30 | + | |
| 31 | + Class<?>[] groups() default {}; | |
| 32 | + | |
| 33 | + Class<? extends Payload>[] payload() default {}; | |
| 34 | + | |
| 35 | +} | |
| 0 | 36 | \ No newline at end of file | ... | ... |
src/main/java/cn/iocoder/dashboard/framework/validator/InEnumValidator.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.framework.validator; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.core.IntArrayValuable; | |
| 4 | + | |
| 5 | +import javax.validation.ConstraintValidator; | |
| 6 | +import javax.validation.ConstraintValidatorContext; | |
| 7 | +import java.util.Arrays; | |
| 8 | +import java.util.Collections; | |
| 9 | +import java.util.List; | |
| 10 | +import java.util.stream.Collectors; | |
| 11 | + | |
| 12 | +public class InEnumValidator implements ConstraintValidator<InEnum, Integer> { | |
| 13 | + | |
| 14 | + private List<Integer> values; | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + public void initialize(InEnum annotation) { | |
| 18 | + IntArrayValuable[] values = annotation.value().getEnumConstants(); | |
| 19 | + if (values.length == 0) { | |
| 20 | + this.values = Collections.emptyList(); | |
| 21 | + } else { | |
| 22 | + this.values = Arrays.stream(values[0].array()).boxed().collect(Collectors.toList()); | |
| 23 | + } | |
| 24 | + } | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + public boolean isValid(Integer value, ConstraintValidatorContext context) { | |
| 28 | + // 为空时,默认不校验,即认为通过 | |
| 29 | + if (value == null) { | |
| 30 | + return true; | |
| 31 | + } | |
| 32 | + // 校验通过 | |
| 33 | + if (values.contains(value)) { | |
| 34 | + return true; | |
| 35 | + } | |
| 36 | + // 校验不通过,自定义提示语句(因为,注解上的 value 是枚举类,无法获得枚举类的实际值) | |
| 37 | + context.disableDefaultConstraintViolation(); // 禁用默认的 message 的值 | |
| 38 | + context.buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate() | |
| 39 | + .replaceAll("\\{value}", values.toString())).addConstraintViolation(); // 重新添加错误提示语句 | |
| 40 | + return false; | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | |
| 44 | + | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/ErrorCodeController.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.errorcode; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; | |
| 6 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; | |
| 7 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | |
| 8 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; | |
| 9 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; | |
| 10 | +import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; | |
| 11 | +import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; | |
| 12 | +import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; | |
| 13 | +import io.swagger.annotations.Api; | |
| 14 | +import io.swagger.annotations.ApiOperation; | |
| 15 | +import org.springframework.web.bind.annotation.*; | |
| 16 | + | |
| 17 | +import javax.annotation.Resource; | |
| 18 | +import javax.validation.constraints.NotNull; | |
| 19 | +import java.util.Date; | |
| 20 | +import java.util.List; | |
| 21 | + | |
| 22 | +import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | |
| 23 | + | |
| 24 | +@Api(tags = "错误码") | |
| 25 | +@RestController | |
| 26 | +@RequestMapping("/system/error-code") | |
| 27 | +public class ErrorCodeController { | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private ErrorCodeService errorCodeService; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 获得指定分组下的错误码列表 | |
| 34 | + * | |
| 35 | + * @param group 错误码分组 | |
| 36 | + * @param minUpdateTime 最小更新时间,允许为空。 | |
| 37 | + * 通过该参数,我们可以增量获取超过 minUpdateTime 时间的错误码 | |
| 38 | + * @return 错误码列表 | |
| 39 | + */ | |
| 40 | + @ApiOperation("获取指定分组下的状态码") | |
| 41 | + @GetMapping("/list-group") | |
| 42 | + public CommonResult<List<ErrorCodeVO>> listErrorCodes(@NotNull(message = "错误码分组不能为空") String group, Date minUpdateTime) { | |
| 43 | + return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(group, minUpdateTime))); | |
| 44 | + } | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 自动生成错误码 | |
| 48 | + * | |
| 49 | + * @param autoGenerateDTOs 自动生成信息 DTO | |
| 50 | + */ | |
| 51 | + @ApiOperation("自动生成错误码") | |
| 52 | + @PostMapping("/generate") | |
| 53 | + public CommonResult<Boolean> autoGenerateErrorCodes(List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { | |
| 54 | + errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); | |
| 55 | + return success(Boolean.TRUE); | |
| 56 | + } | |
| 57 | + | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 创建错误码 | |
| 61 | + * | |
| 62 | + * @param createDTO 创建错误码 DTO | |
| 63 | + * @return 错误码编号 | |
| 64 | + */ | |
| 65 | + @ApiOperation("创建错误码") | |
| 66 | + @PostMapping("/create") | |
| 67 | + public CommonResult<Integer> createErrorCode(ErrorCodeCreateDTO createDTO) { | |
| 68 | + return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId()); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 更新错误码 | |
| 73 | + * | |
| 74 | + * @param updateDTO 更新错误码 DTO | |
| 75 | + */ | |
| 76 | + @ApiOperation("更新错误码") | |
| 77 | + @PatchMapping("/update") | |
| 78 | + public CommonResult<Boolean> updateErrorCode(ErrorCodeUpdateDTO updateDTO) { | |
| 79 | + errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)); | |
| 80 | + return success(Boolean.TRUE); | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 删除错误码 | |
| 85 | + * | |
| 86 | + * @param errorCodeId 错误码编号 | |
| 87 | + */ | |
| 88 | + @ApiOperation("删除错误码") | |
| 89 | + @DeleteMapping("delete") | |
| 90 | + public CommonResult<Boolean> deleteErrorCode(Integer errorCodeId) { | |
| 91 | + errorCodeService.deleteErrorCode(errorCodeId); | |
| 92 | + return success(Boolean.TRUE); | |
| 93 | + } | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * 获得错误码 | |
| 97 | + * | |
| 98 | + * @param errorCodeId 错误码编号 | |
| 99 | + * @return 错误码 | |
| 100 | + */ | |
| 101 | + @ApiOperation("获取错误码") | |
| 102 | + @GetMapping("/query") | |
| 103 | + public CommonResult<ErrorCodeVO> getErrorCode(Integer errorCodeId) { | |
| 104 | + return success(ErrorCodeConvert.INSTANCE.convert(errorCodeService.getErrorCode(errorCodeId))); | |
| 105 | + } | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * 获得错误码列表 | |
| 109 | + * | |
| 110 | + * @param errorCodeIds 错误码编号列表 | |
| 111 | + * @return 错误码列表 | |
| 112 | + */ | |
| 113 | + @ApiOperation("获取错误码列表") | |
| 114 | + @GetMapping("/query-ids") | |
| 115 | + public CommonResult<List<ErrorCodeVO>> listErrorCodes(List<Integer> errorCodeIds) { | |
| 116 | + return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds))); | |
| 117 | + } | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * 获得错误码分页 | |
| 121 | + * | |
| 122 | + * @param pageDTO 错误码分页查询 | |
| 123 | + * @return 错误码分页结果 | |
| 124 | + */ | |
| 125 | + @ApiOperation("获取错误码分页列表") | |
| 126 | + @GetMapping("/page") | |
| 127 | + public CommonResult<PageResult<ErrorCodeVO>> pageErrorCode(ErrorCodePageDTO pageDTO) { | |
| 128 | + final PageResult<ErrorCodeBO> pageResult = errorCodeService.pageErrorCode(ErrorCodeConvert.INSTANCE.convert(pageDTO)); | |
| 129 | + return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult)); | |
| 130 | + } | |
| 131 | + | |
| 132 | + | |
| 133 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodeAutoGenerateDTO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.experimental.Accessors; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | +import java.io.Serializable; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 错误码自动生成 DTO | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +@Accessors(chain = true) | |
| 15 | +public class ErrorCodeAutoGenerateDTO implements Serializable { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 错误码编码 | |
| 19 | + */ | |
| 20 | + @NotNull(message = "错误码编码不能为空") | |
| 21 | + private Integer code; | |
| 22 | + /** | |
| 23 | + * 错误码错误提示 | |
| 24 | + */ | |
| 25 | + @NotEmpty(message = "错误码错误提示不能为空") | |
| 26 | + private String message; | |
| 27 | + /** | |
| 28 | + * 错误码分组 | |
| 29 | + */ | |
| 30 | + @NotNull(message = "错误码分组不能为空") | |
| 31 | + private String group; | |
| 32 | + | |
| 33 | +} | |
| 0 | 34 | \ No newline at end of file | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodeCreateDTO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.framework.validator.InEnum; | |
| 4 | +import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.experimental.Accessors; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotEmpty; | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | +import java.io.Serializable; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 错误码创建 DTO | |
| 14 | + */ | |
| 15 | +@Data | |
| 16 | +@Accessors(chain = true) | |
| 17 | +public class ErrorCodeCreateDTO implements Serializable { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 错误码编码 | |
| 21 | + */ | |
| 22 | + @NotNull(message = "错误码编码不能为空") | |
| 23 | + private Integer code; | |
| 24 | + /** | |
| 25 | + * 错误码错误提示 | |
| 26 | + */ | |
| 27 | + @NotEmpty(message = "错误码错误提示不能为空") | |
| 28 | + private String message; | |
| 29 | + /** | |
| 30 | + * 错误码类型 | |
| 31 | + */ | |
| 32 | + @NotNull(message = "错误码类型不能为空") | |
| 33 | + @InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}") | |
| 34 | + private Integer type; | |
| 35 | + /** | |
| 36 | + * 错误码分组 | |
| 37 | + */ | |
| 38 | + @NotNull(message = "错误码分组不能为空") | |
| 39 | + private String group; | |
| 40 | + /** | |
| 41 | + * 错误码备注 | |
| 42 | + */ | |
| 43 | + private String memo; | |
| 44 | + | |
| 45 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodePageDTO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.PageParam; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.experimental.Accessors; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 错误码分页 DTO | |
| 10 | + */ | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@Accessors(chain = true) | |
| 14 | +public class ErrorCodePageDTO extends PageParam { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 错误码编码 | |
| 18 | + */ | |
| 19 | + private Integer code; | |
| 20 | + /** | |
| 21 | + * 错误码错误提示 | |
| 22 | + * | |
| 23 | + * 模糊匹配 | |
| 24 | + */ | |
| 25 | + private String message; | |
| 26 | + /** | |
| 27 | + * 错误码分组 | |
| 28 | + * | |
| 29 | + * 模糊匹配 | |
| 30 | + */ | |
| 31 | + private String group; | |
| 32 | + | |
| 33 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodeUpdateDTO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.framework.validator.InEnum; | |
| 4 | +import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.experimental.Accessors; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | +import java.io.Serializable; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 错误码更新 DTO | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +@Accessors(chain = true) | |
| 16 | +public class ErrorCodeUpdateDTO implements Serializable { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 错误码编号 | |
| 20 | + */ | |
| 21 | + @NotNull(message = "错误码编号不能为空") | |
| 22 | + private Integer id; | |
| 23 | + /** | |
| 24 | + * 错误码编码 | |
| 25 | + */ | |
| 26 | + @NotNull(message = "错误码编码不能为空") | |
| 27 | + private Integer code; | |
| 28 | + /** | |
| 29 | + * 错误码错误提示 | |
| 30 | + */ | |
| 31 | + private String message; | |
| 32 | + /** | |
| 33 | + * 错误码类型 | |
| 34 | + */ | |
| 35 | + @InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}") | |
| 36 | + private Integer type; | |
| 37 | + /** | |
| 38 | + * 错误码分组 | |
| 39 | + */ | |
| 40 | + private String group; | |
| 41 | + /** | |
| 42 | + * 错误码备注 | |
| 43 | + */ | |
| 44 | + private String memo; | |
| 45 | + | |
| 46 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/ErrorCodeVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.experimental.Accessors; | |
| 5 | + | |
| 6 | +import java.io.Serializable; | |
| 7 | +import java.util.Date; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 错误码 | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +@Accessors(chain = true) | |
| 14 | +public class ErrorCodeVO implements Serializable { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 错误码编号 | |
| 18 | + */ | |
| 19 | + private Integer id; | |
| 20 | + /** | |
| 21 | + * 错误码编码 | |
| 22 | + */ | |
| 23 | + private Integer code; | |
| 24 | + /** | |
| 25 | + * 错误码错误提示 | |
| 26 | + */ | |
| 27 | + private String message; | |
| 28 | + /** | |
| 29 | + * 错误码类型 | |
| 30 | + */ | |
| 31 | + private Integer type; | |
| 32 | + /** | |
| 33 | + * 错误码分组 | |
| 34 | + */ | |
| 35 | + private String group; | |
| 36 | + /** | |
| 37 | + * 错误码备注 | |
| 38 | + */ | |
| 39 | + private String memo; | |
| 40 | + /** | |
| 41 | + * 创建时间 | |
| 42 | + */ | |
| 43 | + private Date createTime; | |
| 44 | + /** | |
| 45 | + * 最后更新时间 | |
| 46 | + */ | |
| 47 | + private Date updateTime; | |
| 48 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/ErrorCodeConvert.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.convert.errorcode; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; | |
| 5 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; | |
| 6 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | |
| 7 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; | |
| 8 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; | |
| 9 | +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; | |
| 10 | +import cn.iocoder.dashboard.modules.system.service.errorcode.bo.*; | |
| 11 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
| 12 | +import org.mapstruct.Mapper; | |
| 13 | +import org.mapstruct.Mapping; | |
| 14 | +import org.mapstruct.factory.Mappers; | |
| 15 | + | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | +@Mapper | |
| 19 | +public interface ErrorCodeConvert { | |
| 20 | + | |
| 21 | + ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class); | |
| 22 | + | |
| 23 | + ErrorCodeDO convert(ErrorCodeCreateBO bean); | |
| 24 | + | |
| 25 | + ErrorCodeBO convert(ErrorCodeDO bean); | |
| 26 | + | |
| 27 | + List<ErrorCodeBO> convertList(List<ErrorCodeDO> list); | |
| 28 | + | |
| 29 | + @Mapping(source = "records", target = "list") | |
| 30 | + PageResult<ErrorCodeBO> convertPage(IPage<ErrorCodeDO> page); | |
| 31 | + | |
| 32 | + ErrorCodeDO convert(ErrorCodeUpdateBO bean); | |
| 33 | + | |
| 34 | + ErrorCodeCreateBO convert(ErrorCodeCreateDTO bean); | |
| 35 | + | |
| 36 | + ErrorCodeUpdateBO convert(ErrorCodeUpdateDTO bean); | |
| 37 | + | |
| 38 | + ErrorCodeVO convert(ErrorCodeBO bean); | |
| 39 | + | |
| 40 | + List<ErrorCodeVO> convertList02(List<ErrorCodeBO> list); | |
| 41 | + | |
| 42 | + PageResult<ErrorCodeVO> convertPage(PageResult<ErrorCodeBO> page); | |
| 43 | + | |
| 44 | + ErrorCodePageBO convert(ErrorCodePageDTO bean); | |
| 45 | + | |
| 46 | + ErrorCodeDO convert(ErrorCodeAutoGenerateBO bean); | |
| 47 | + | |
| 48 | + List<ErrorCodeAutoGenerateBO> convertList03(List<ErrorCodeAutoGenerateDTO> list); | |
| 49 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/ErrorCodeDO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.EqualsAndHashCode; | |
| 8 | +import lombok.experimental.Accessors; | |
| 9 | + | |
| 10 | +@Data | |
| 11 | +@TableName(value = "system_error_code") | |
| 12 | +@EqualsAndHashCode() | |
| 13 | +@Accessors(chain = true) | |
| 14 | +public class ErrorCodeDO { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 错误码编号 | |
| 18 | + */ | |
| 19 | + private Integer id; | |
| 20 | + /** | |
| 21 | + * 错误码编码 | |
| 22 | + */ | |
| 23 | + private Integer code; | |
| 24 | + /** | |
| 25 | + * 错误码错误提示 | |
| 26 | + */ | |
| 27 | + private String message; | |
| 28 | + /** | |
| 29 | + * 错误码类型 | |
| 30 | + * | |
| 31 | + * 外键 {@link ErrorCodeTypeEnum} | |
| 32 | + */ | |
| 33 | + private Integer type; | |
| 34 | + /** | |
| 35 | + * 错误码分组 | |
| 36 | + * | |
| 37 | + * 一般情况下,可以采用应用名 | |
| 38 | + */ | |
| 39 | + @TableField("`group`") // 避免和数据库关键字冲突 | |
| 40 | + private String group; | |
| 41 | + /** | |
| 42 | + * 错误码备注 | |
| 43 | + */ | |
| 44 | + private String memo; | |
| 45 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/ErrorCodeMapper.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.dal.mysql.errorcode; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | |
| 4 | +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; | |
| 5 | +import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodePageBO; | |
| 6 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 7 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
| 8 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
| 9 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
| 10 | +import org.apache.ibatis.annotations.Mapper; | |
| 11 | + | |
| 12 | +import java.util.Collection; | |
| 13 | +import java.util.Date; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +@Mapper | |
| 17 | +public interface ErrorCodeMapper extends BaseMapper<ErrorCodeDO> { | |
| 18 | + default IPage<ErrorCodeDO> selectPage(ErrorCodePageBO pageBO) { | |
| 19 | + return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), | |
| 20 | + new QueryWrapperX<ErrorCodeDO>().likeIfPresent("`group`", pageBO.getGroup()) | |
| 21 | + .eqIfPresent("code", pageBO.getCode()).likeIfPresent("message", pageBO.getMessage())); | |
| 22 | + } | |
| 23 | + | |
| 24 | + default List<ErrorCodeDO> selectListByCodes(Collection<Integer> codes) { | |
| 25 | + return selectList(new QueryWrapper<ErrorCodeDO>().in("code", codes)); | |
| 26 | + } | |
| 27 | + | |
| 28 | + default ErrorCodeDO selectByCode(Integer code) { | |
| 29 | + return selectOne(new QueryWrapper<ErrorCodeDO>().eq("code", code)); | |
| 30 | + } | |
| 31 | + | |
| 32 | + default List<ErrorCodeDO> selectListByGroup(String group, Date minUpdateTime) { | |
| 33 | + return selectList(new QueryWrapperX<ErrorCodeDO>().eq("`group`", group) | |
| 34 | + .gtIfPresent("update_time", minUpdateTime)); | |
| 35 | + } | |
| 36 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java
| ... | ... | @@ -75,4 +75,9 @@ public interface SysErrorCodeConstants { |
| 75 | 75 | // ========== 文件 1002009000 ========== |
| 76 | 76 | ErrorCode FILE_PATH_EXISTS = new ErrorCode(1002009001, "文件路径已经存在"); |
| 77 | 77 | |
| 78 | + // ========== 错误码模块 1002009000 ========== | |
| 79 | + ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002009000, "错误码不存在"); | |
| 80 | + ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002009001, "已经存在编码为【{}}】的错误码"); | |
| 81 | + ErrorCode ERROR_CAN_NOT_UPDATE_SYSTEM_TYPE_ERROR = new ErrorCode(1002004003, "不能修改类型为系统内置的错误码"); | |
| 82 | + | |
| 78 | 83 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/enums/errorcode/ErrorCodeTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.enums.errorcode; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.core.IntArrayValuable; | |
| 4 | + | |
| 5 | +import java.util.Arrays; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * @author dylan | |
| 9 | + */ | |
| 10 | + | |
| 11 | +public enum ErrorCodeTypeEnum implements IntArrayValuable { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 自动生成 | |
| 15 | + */ | |
| 16 | + AUTO_GENERATION(1), | |
| 17 | + /** | |
| 18 | + * 手动编辑 | |
| 19 | + */ | |
| 20 | + MANUAL_OPERATION(2); | |
| 21 | + | |
| 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErrorCodeTypeEnum::getType).toArray(); | |
| 23 | + | |
| 24 | + private final Integer type; | |
| 25 | + | |
| 26 | + ErrorCodeTypeEnum(Integer type) { | |
| 27 | + this.type = type; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public Integer getType() { | |
| 31 | + return type; | |
| 32 | + } | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public int[] array() { | |
| 36 | + return ARRAYS; | |
| 37 | + } | |
| 38 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.service.errorcode; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | |
| 5 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; | |
| 7 | +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; | |
| 8 | +import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper; | |
| 9 | +import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | |
| 10 | +import cn.iocoder.dashboard.modules.system.service.errorcode.bo.*; | |
| 11 | +import cn.iocoder.dashboard.util.collection.CollectionUtils; | |
| 12 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
| 13 | +import lombok.extern.slf4j.Slf4j; | |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Transactional; | |
| 17 | +import org.springframework.validation.annotation.Validated; | |
| 18 | + | |
| 19 | +import javax.validation.Valid; | |
| 20 | +import java.util.Date; | |
| 21 | +import java.util.List; | |
| 22 | +import java.util.Map; | |
| 23 | + | |
| 24 | +import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.ERROR_CODE_DUPLICATE; | |
| 25 | +import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.ERROR_CODE_NOT_EXISTS; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * 错误码 Service | |
| 29 | + */ | |
| 30 | +@Slf4j | |
| 31 | +@Validated | |
| 32 | +@Service | |
| 33 | +public class ErrorCodeService { | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + ErrorCodeMapper errorCodeMapper; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 创建错误码 | |
| 40 | + * | |
| 41 | + * @param createBO 创建错误码 BO | |
| 42 | + * @return 错误码 | |
| 43 | + */ | |
| 44 | + public ErrorCodeBO createErrorCode(@Valid ErrorCodeCreateBO createBO) { | |
| 45 | + checkDuplicateErrorCode(createBO.getCode(), null); | |
| 46 | + // 插入到数据库 | |
| 47 | + ErrorCodeDO errorCodeDO = ErrorCodeConvert.INSTANCE.convert(createBO); | |
| 48 | + errorCodeMapper.insert(errorCodeDO); | |
| 49 | + // 返回 | |
| 50 | + return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 更新错误码 | |
| 55 | + * | |
| 56 | + * @param updateBO 更新错误码 BO | |
| 57 | + */ | |
| 58 | + public void updateErrorCode(@Valid ErrorCodeUpdateBO updateBO) { | |
| 59 | + checkDuplicateErrorCode(updateBO.getCode(), updateBO.getId()); | |
| 60 | + // 校验更新的错误码是否存在 | |
| 61 | + if (errorCodeMapper.selectById(updateBO.getId()) == null) { | |
| 62 | + throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS); | |
| 63 | + } | |
| 64 | + // 更新到数据库 | |
| 65 | + ErrorCodeDO updateObject = ErrorCodeConvert.INSTANCE.convert(updateBO); | |
| 66 | + errorCodeMapper.updateById(updateObject); | |
| 67 | + } | |
| 68 | + | |
| 69 | + @Transactional | |
| 70 | + public void autoGenerateErrorCodes(@Valid List<ErrorCodeAutoGenerateBO> autoGenerateBOs) { | |
| 71 | + if (CollUtil.isEmpty(autoGenerateBOs)) { | |
| 72 | + return; | |
| 73 | + } | |
| 74 | + List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByCodes( | |
| 75 | + CollectionUtils.convertSet(autoGenerateBOs, ErrorCodeAutoGenerateBO::getCode)); | |
| 76 | + Map<Integer, ErrorCodeDO> errorCodeDOMap = CollectionUtils.convertMap(errorCodeDOs, ErrorCodeDO::getCode); | |
| 77 | + // 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了 | |
| 78 | + autoGenerateBOs.forEach(autoGenerateBO -> { | |
| 79 | + ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateBO.getCode()); | |
| 80 | + // 不存在,则进行新增 | |
| 81 | + if (errorCodeDO == null) { | |
| 82 | + errorCodeDO = ErrorCodeConvert.INSTANCE.convert(autoGenerateBO) | |
| 83 | + .setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType()); | |
| 84 | + errorCodeMapper.insert(errorCodeDO); | |
| 85 | + return; | |
| 86 | + } | |
| 87 | + // 存在,则进行更新。更新有三个前置条件: | |
| 88 | + // 条件 1. 只更新自动生成的错误码,即 Type 为 ErrorCodeTypeEnum.AUTO_GENERATION | |
| 89 | + if (!ErrorCodeTypeEnum.AUTO_GENERATION.getType().equals(errorCodeDO.getType())) { | |
| 90 | + return; | |
| 91 | + } | |
| 92 | + // 条件 2. 分组 group 必须匹配,避免存在错误码冲突的情况 | |
| 93 | + if (!autoGenerateBO.getGroup().equals(errorCodeDO.getGroup())) { | |
| 94 | + log.error("[autoGenerateErrorCodes][自动创建({}/{}) 错误码失败,数据库中已经存在({}/{})]", | |
| 95 | + autoGenerateBO.getCode(), autoGenerateBO.getGroup(), | |
| 96 | + errorCodeDO.getCode(), errorCodeDO.getGroup()); | |
| 97 | + return; | |
| 98 | + } | |
| 99 | + // 条件 3. 错误提示语存在差异 | |
| 100 | + if (autoGenerateBO.getMessage().equals(errorCodeDO.getMessage())) { | |
| 101 | + return; | |
| 102 | + } | |
| 103 | + // 最终匹配,进行更新 | |
| 104 | + errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateBO.getMessage())); | |
| 105 | + }); | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * 删除错误码 | |
| 110 | + * | |
| 111 | + * @param errorCodeId 错误码编号 | |
| 112 | + */ | |
| 113 | + public void deleteErrorCode(Integer errorCodeId) { | |
| 114 | + // 校验删除的错误码是否存在 | |
| 115 | + if (errorCodeMapper.selectById(errorCodeId) == null) { | |
| 116 | + throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS); | |
| 117 | + } | |
| 118 | + // 标记删除 | |
| 119 | + errorCodeMapper.deleteById(errorCodeId); | |
| 120 | + } | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * 获得错误码 | |
| 124 | + * | |
| 125 | + * @param errorCodeId 错误码编号 | |
| 126 | + * @return 错误码 | |
| 127 | + */ | |
| 128 | + public ErrorCodeBO getErrorCode(Integer errorCodeId) { | |
| 129 | + ErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId); | |
| 130 | + return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); | |
| 131 | + } | |
| 132 | + | |
| 133 | + /** | |
| 134 | + * 获得错误码列表 | |
| 135 | + * | |
| 136 | + * @param errorCodeIds 错误码编号列表 | |
| 137 | + * @return 错误码列表 | |
| 138 | + */ | |
| 139 | + public List<ErrorCodeBO> listErrorCodes(List<Integer> errorCodeIds) { | |
| 140 | + List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds); | |
| 141 | + return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * 获得错误码分页 | |
| 146 | + * | |
| 147 | + * @param pageBO 错误码分页查询 | |
| 148 | + * @return 错误码分页结果 | |
| 149 | + */ | |
| 150 | + public PageResult<ErrorCodeBO> pageErrorCode(ErrorCodePageBO pageBO) { | |
| 151 | + IPage<ErrorCodeDO> errorCodeDOPage = errorCodeMapper.selectPage(pageBO); | |
| 152 | + return ErrorCodeConvert.INSTANCE.convertPage(errorCodeDOPage); | |
| 153 | + } | |
| 154 | + | |
| 155 | + /** | |
| 156 | + * 校验错误码的唯一字段是否重复 | |
| 157 | + * | |
| 158 | + * 是否存在相同编码的错误码 | |
| 159 | + * | |
| 160 | + * @param code 错误码编码 | |
| 161 | + * @param id 错误码编号 | |
| 162 | + */ | |
| 163 | + private void checkDuplicateErrorCode(Integer code, Integer id) { | |
| 164 | + ErrorCodeDO errorCodeDO = errorCodeMapper.selectByCode(code); | |
| 165 | + if (errorCodeDO == null) { | |
| 166 | + return; | |
| 167 | + } | |
| 168 | + // 如果 id 为空,说明不用比较是否为相同 id 的错误码 | |
| 169 | + if (id == null) { | |
| 170 | + throw ServiceExceptionUtil.exception(ERROR_CODE_DUPLICATE); | |
| 171 | + } | |
| 172 | + if (!errorCodeDO.getId().equals(id)) { | |
| 173 | + throw ServiceExceptionUtil.exception(ERROR_CODE_DUPLICATE); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + public List<ErrorCodeBO> listErrorCodes(String group, Date minUpdateTime) { | |
| 178 | + List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); | |
| 179 | + return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); | |
| 180 | + } | |
| 181 | + | |
| 182 | +} | |
| 183 | + | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeAutoGenerateBO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.experimental.Accessors; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | +import java.io.Serializable; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 错误码自动生成 BO | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +@Accessors(chain = true) | |
| 15 | +public class ErrorCodeAutoGenerateBO implements Serializable { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 错误码编码 | |
| 19 | + */ | |
| 20 | + @NotNull(message = "错误码编码不能为空") | |
| 21 | + private Integer code; | |
| 22 | + /** | |
| 23 | + * 错误码错误提示 | |
| 24 | + */ | |
| 25 | + @NotEmpty(message = "错误码错误提示不能为空") | |
| 26 | + private String message; | |
| 27 | + /** | |
| 28 | + * 错误码分组 | |
| 29 | + */ | |
| 30 | + @NotNull(message = "错误码分组不能为空") | |
| 31 | + private String group; | |
| 32 | + | |
| 33 | +} | |
| 0 | 34 | \ No newline at end of file | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeBO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.experimental.Accessors; | |
| 5 | + | |
| 6 | +import java.util.Date; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 错误码 BO | |
| 10 | + */ | |
| 11 | +@Data | |
| 12 | +@Accessors(chain = true) | |
| 13 | +public class ErrorCodeBO { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 错误码编号 | |
| 17 | + */ | |
| 18 | + private Integer id; | |
| 19 | + /** | |
| 20 | + * 错误码编码 | |
| 21 | + */ | |
| 22 | + private Integer code; | |
| 23 | + /** | |
| 24 | + * 错误码错误提示 | |
| 25 | + */ | |
| 26 | + private String message; | |
| 27 | + /** | |
| 28 | + * 错误码类型 | |
| 29 | + */ | |
| 30 | + private Integer type; | |
| 31 | + /** | |
| 32 | + * 错误码分组 | |
| 33 | + */ | |
| 34 | + private String group; | |
| 35 | + /** | |
| 36 | + * 错误码备注 | |
| 37 | + */ | |
| 38 | + private String memo; | |
| 39 | + /** | |
| 40 | + * 创建时间 | |
| 41 | + */ | |
| 42 | + private Date createTime; | |
| 43 | + /** | |
| 44 | + * 最后更新时间 | |
| 45 | + */ | |
| 46 | + private Date updateTime; | |
| 47 | + | |
| 48 | +} | |
| 0 | 49 | \ No newline at end of file | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeCreateBO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.experimental.Accessors; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Data | |
| 10 | +@Accessors(chain = true) | |
| 11 | +public class ErrorCodeCreateBO { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 错误码编码 | |
| 15 | + */ | |
| 16 | + @NotNull(message = "错误码编码不能为空") | |
| 17 | + private Integer code; | |
| 18 | + /** | |
| 19 | + * 错误码错误提示 | |
| 20 | + */ | |
| 21 | + @NotEmpty(message = "错误码错误提示不能为空") | |
| 22 | + private String message; | |
| 23 | + /** | |
| 24 | + * 错误码类型 | |
| 25 | + */ | |
| 26 | + @NotNull(message = "错误码类型不能为空") | |
| 27 | + private Integer type; | |
| 28 | + /** | |
| 29 | + * 错误码分组 | |
| 30 | + */ | |
| 31 | + private String group; | |
| 32 | + /** | |
| 33 | + * 错误码备注 | |
| 34 | + */ | |
| 35 | + private String memo; | |
| 36 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodePageBO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.PageParam; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.experimental.Accessors; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 错误码分页 BO | |
| 10 | + */ | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@Accessors(chain = true) | |
| 14 | +public class ErrorCodePageBO extends PageParam { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 错误码编码 | |
| 18 | + */ | |
| 19 | + private Integer code; | |
| 20 | + /** | |
| 21 | + * 错误码错误提示 | |
| 22 | + */ | |
| 23 | + private String message; | |
| 24 | + /** | |
| 25 | + * 错误码分组 | |
| 26 | + */ | |
| 27 | + private String group; | |
| 28 | + | |
| 29 | +} | |
| 0 | 30 | \ No newline at end of file | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeUpdateBO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | +import lombok.experimental.Accessors; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotEmpty; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 错误码更新 BO | |
| 11 | + */ | |
| 12 | +@Data | |
| 13 | +@Accessors(chain = true) | |
| 14 | +public class ErrorCodeUpdateBO { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 错误码编号 | |
| 18 | + */ | |
| 19 | + @NotNull(message = "错误码编号不能为空") | |
| 20 | + private Integer id; | |
| 21 | + /** | |
| 22 | + * 错误码编码 | |
| 23 | + */ | |
| 24 | + @NotNull(message = "错误码编码不能为空") | |
| 25 | + private Integer code; | |
| 26 | + /** | |
| 27 | + * 错误码错误提示 | |
| 28 | + */ | |
| 29 | + @NotEmpty(message = "错误码错误提示不能为空") | |
| 30 | + private String message; | |
| 31 | + /** | |
| 32 | + * 错误码类型 | |
| 33 | + */ | |
| 34 | + @NotNull(message = "错误码类型不能为空") | |
| 35 | + private Integer type; | |
| 36 | + /** | |
| 37 | + * 错误码分组 | |
| 38 | + */ | |
| 39 | + private String group; | |
| 40 | + /** | |
| 41 | + * 错误码备注 | |
| 42 | + */ | |
| 43 | + private String memo; | |
| 44 | + | |
| 45 | +} | |
| 0 | 46 | \ No newline at end of file | ... | ... |