Commit 54378aeed336c0059d475c887e4be06fdf1d2ab2
1 parent
4c3997b6
完成错误码
Showing
7 changed files
with
57 additions
and
100 deletions
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/ErrorCodeController.java
| @@ -12,10 +12,14 @@ import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; | @@ -12,10 +12,14 @@ import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; | ||
| 12 | import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; | 12 | import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; |
| 13 | import io.swagger.annotations.Api; | 13 | import io.swagger.annotations.Api; |
| 14 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; |
| 15 | +import org.springframework.beans.propertyeditors.CustomDateEditor; | ||
| 16 | +import org.springframework.web.bind.ServletRequestDataBinder; | ||
| 15 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
| 16 | 18 | ||
| 17 | import javax.annotation.Resource; | 19 | import javax.annotation.Resource; |
| 20 | +import javax.servlet.http.HttpServletRequest; | ||
| 18 | import javax.validation.constraints.NotNull; | 21 | import javax.validation.constraints.NotNull; |
| 22 | +import java.text.SimpleDateFormat; | ||
| 19 | import java.util.Date; | 23 | import java.util.Date; |
| 20 | import java.util.List; | 24 | import java.util.List; |
| 21 | 25 | ||
| @@ -50,7 +54,7 @@ public class ErrorCodeController { | @@ -50,7 +54,7 @@ public class ErrorCodeController { | ||
| 50 | */ | 54 | */ |
| 51 | @ApiOperation("自动生成错误码") | 55 | @ApiOperation("自动生成错误码") |
| 52 | @PostMapping("/generate") | 56 | @PostMapping("/generate") |
| 53 | - public CommonResult<Boolean> autoGenerateErrorCodes(List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { | 57 | + public CommonResult<Boolean> autoGenerateErrorCodes(@RequestBody List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { |
| 54 | errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); | 58 | errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); |
| 55 | return success(Boolean.TRUE); | 59 | return success(Boolean.TRUE); |
| 56 | } | 60 | } |
| @@ -64,7 +68,7 @@ public class ErrorCodeController { | @@ -64,7 +68,7 @@ public class ErrorCodeController { | ||
| 64 | */ | 68 | */ |
| 65 | @ApiOperation("创建错误码") | 69 | @ApiOperation("创建错误码") |
| 66 | @PostMapping("/create") | 70 | @PostMapping("/create") |
| 67 | - public CommonResult<Integer> createErrorCode(ErrorCodeCreateDTO createDTO) { | 71 | + public CommonResult<Integer> createErrorCode(@RequestBody ErrorCodeCreateDTO createDTO) { |
| 68 | return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId()); | 72 | return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId()); |
| 69 | } | 73 | } |
| 70 | 74 | ||
| @@ -75,7 +79,7 @@ public class ErrorCodeController { | @@ -75,7 +79,7 @@ public class ErrorCodeController { | ||
| 75 | */ | 79 | */ |
| 76 | @ApiOperation("更新错误码") | 80 | @ApiOperation("更新错误码") |
| 77 | @PatchMapping("/update") | 81 | @PatchMapping("/update") |
| 78 | - public CommonResult<Boolean> updateErrorCode(ErrorCodeUpdateDTO updateDTO) { | 82 | + public CommonResult<Boolean> updateErrorCode(@RequestBody ErrorCodeUpdateDTO updateDTO) { |
| 79 | errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)); | 83 | errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)); |
| 80 | return success(Boolean.TRUE); | 84 | return success(Boolean.TRUE); |
| 81 | } | 85 | } |
| @@ -112,7 +116,7 @@ public class ErrorCodeController { | @@ -112,7 +116,7 @@ public class ErrorCodeController { | ||
| 112 | */ | 116 | */ |
| 113 | @ApiOperation("获取错误码列表") | 117 | @ApiOperation("获取错误码列表") |
| 114 | @GetMapping("/query-ids") | 118 | @GetMapping("/query-ids") |
| 115 | - public CommonResult<List<ErrorCodeVO>> listErrorCodes(List<Integer> errorCodeIds) { | 119 | + public CommonResult<List<ErrorCodeVO>> listErrorCodes(@RequestBody List<Integer> errorCodeIds) { |
| 116 | return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds))); | 120 | return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds))); |
| 117 | } | 121 | } |
| 118 | 122 | ||
| @@ -129,5 +133,11 @@ public class ErrorCodeController { | @@ -129,5 +133,11 @@ public class ErrorCodeController { | ||
| 129 | return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult)); | 133 | return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult)); |
| 130 | } | 134 | } |
| 131 | 135 | ||
| 136 | + @InitBinder | ||
| 137 | + protected void init(HttpServletRequest request, ServletRequestDataBinder binder) { | ||
| 138 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 139 | + dateFormat.setLenient(false); | ||
| 140 | + binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); | ||
| 141 | + } | ||
| 132 | 142 | ||
| 133 | } | 143 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodeCreateDTO.java
| 1 | package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | 1 | package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.dashboard.framework.validator.InEnum; | ||
| 4 | -import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | 3 | +import io.swagger.annotations.ApiModel; |
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | -import lombok.experimental.Accessors; | ||
| 7 | 6 | ||
| 8 | import javax.validation.constraints.NotEmpty; | 7 | import javax.validation.constraints.NotEmpty; |
| 9 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 10 | -import java.io.Serializable; | ||
| 11 | 9 | ||
| 12 | -/** | ||
| 13 | - * 错误码创建 DTO | ||
| 14 | - */ | 10 | +@ApiModel("错误码创建 DTO") |
| 15 | @Data | 11 | @Data |
| 16 | -@Accessors(chain = true) | ||
| 17 | -public class ErrorCodeCreateDTO implements Serializable { | 12 | +public class ErrorCodeCreateDTO { |
| 18 | 13 | ||
| 19 | - /** | ||
| 20 | - * 错误码编码 | ||
| 21 | - */ | 14 | + @ApiModelProperty(value = "错误码编码", required = true, example = "10086") |
| 22 | @NotNull(message = "错误码编码不能为空") | 15 | @NotNull(message = "错误码编码不能为空") |
| 23 | private Integer code; | 16 | private Integer code; |
| 24 | - /** | ||
| 25 | - * 错误码错误提示 | ||
| 26 | - */ | 17 | + @ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑") |
| 27 | @NotEmpty(message = "错误码错误提示不能为空") | 18 | @NotEmpty(message = "错误码错误提示不能为空") |
| 28 | private String message; | 19 | 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 = "错误码分组不能为空") | 20 | + @ApiModelProperty(value = "错误码分组", required = true, example = "user-service") |
| 21 | + @NotEmpty(message = "错误码分组不能为空") | ||
| 39 | private String group; | 22 | private String group; |
| 40 | - /** | ||
| 41 | - * 错误码备注 | ||
| 42 | - */ | 23 | + @ApiModelProperty(value = "错误码备注", example = "我就是一个备注") |
| 43 | private String memo; | 24 | private String memo; |
| 44 | 25 | ||
| 45 | } | 26 | } |
| 27 | + |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodePageDTO.java
| 1 | package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | 1 | package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; |
| 2 | 2 | ||
| 3 | import cn.iocoder.dashboard.common.pojo.PageParam; | 3 | import cn.iocoder.dashboard.common.pojo.PageParam; |
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 4 | import lombok.Data; | 6 | import lombok.Data; |
| 5 | import lombok.EqualsAndHashCode; | 7 | import lombok.EqualsAndHashCode; |
| 6 | -import lombok.experimental.Accessors; | ||
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| 9 | * 错误码分页 DTO | 10 | * 错误码分页 DTO |
| 10 | */ | 11 | */ |
| 12 | +@ApiModel("错误码分页 DTO") | ||
| 11 | @Data | 13 | @Data |
| 12 | @EqualsAndHashCode(callSuper = true) | 14 | @EqualsAndHashCode(callSuper = true) |
| 13 | -@Accessors(chain = true) | ||
| 14 | public class ErrorCodePageDTO extends PageParam { | 15 | public class ErrorCodePageDTO extends PageParam { |
| 15 | 16 | ||
| 16 | - /** | ||
| 17 | - * 错误码编码 | ||
| 18 | - */ | 17 | + @ApiModelProperty(value = "错误码编码", required = true) |
| 19 | private Integer code; | 18 | private Integer code; |
| 20 | - /** | ||
| 21 | - * 错误码错误提示 | ||
| 22 | - * | ||
| 23 | - * 模糊匹配 | ||
| 24 | - */ | 19 | + @ApiModelProperty(value = "错误码错误提示", required = true) |
| 25 | private String message; | 20 | private String message; |
| 26 | - /** | ||
| 27 | - * 错误码分组 | ||
| 28 | - * | ||
| 29 | - * 模糊匹配 | ||
| 30 | - */ | 21 | + @ApiModelProperty(value = "错误码分组", required = true) |
| 31 | private String group; | 22 | private String group; |
| 32 | 23 | ||
| 33 | } | 24 | } |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodeUpdateDTO.java
| @@ -2,45 +2,33 @@ package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | @@ -2,45 +2,33 @@ package cn.iocoder.dashboard.modules.system.controller.errorcode.dto; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.dashboard.framework.validator.InEnum; | 3 | import cn.iocoder.dashboard.framework.validator.InEnum; |
| 4 | import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | 4 | import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; |
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | import lombok.Data; | 7 | import lombok.Data; |
| 6 | import lombok.experimental.Accessors; | 8 | import lombok.experimental.Accessors; |
| 7 | 9 | ||
| 10 | +import javax.validation.constraints.NotEmpty; | ||
| 8 | import javax.validation.constraints.NotNull; | 11 | import javax.validation.constraints.NotNull; |
| 9 | import java.io.Serializable; | 12 | import java.io.Serializable; |
| 10 | 13 | ||
| 11 | -/** | ||
| 12 | - * 错误码更新 DTO | ||
| 13 | - */ | 14 | +@ApiModel("错误码更新 DTO") |
| 14 | @Data | 15 | @Data |
| 15 | -@Accessors(chain = true) | ||
| 16 | -public class ErrorCodeUpdateDTO implements Serializable { | 16 | +public class ErrorCodeUpdateDTO { |
| 17 | 17 | ||
| 18 | - /** | ||
| 19 | - * 错误码编号 | ||
| 20 | - */ | 18 | + @ApiModelProperty(value = "错误码编号", required = true, example = "1") |
| 21 | @NotNull(message = "错误码编号不能为空") | 19 | @NotNull(message = "错误码编号不能为空") |
| 22 | private Integer id; | 20 | private Integer id; |
| 23 | - /** | ||
| 24 | - * 错误码编码 | ||
| 25 | - */ | 21 | + @ApiModelProperty(value = "错误码编码", required = true, example = "10086") |
| 26 | @NotNull(message = "错误码编码不能为空") | 22 | @NotNull(message = "错误码编码不能为空") |
| 27 | private Integer code; | 23 | private Integer code; |
| 28 | - /** | ||
| 29 | - * 错误码错误提示 | ||
| 30 | - */ | 24 | + @ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑") |
| 25 | + @NotEmpty(message = "错误码错误提示不能为空") | ||
| 31 | private String message; | 26 | private String message; |
| 32 | - /** | ||
| 33 | - * 错误码类型 | ||
| 34 | - */ | ||
| 35 | - @InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}") | ||
| 36 | - private Integer type; | ||
| 37 | - /** | ||
| 38 | - * 错误码分组 | ||
| 39 | - */ | 27 | + @ApiModelProperty(value = "错误码分组", required = true, example = "user-service") |
| 28 | + @NotEmpty(message = "错误码分组不能为空") | ||
| 40 | private String group; | 29 | private String group; |
| 41 | - /** | ||
| 42 | - * 错误码备注 | ||
| 43 | - */ | 30 | + @ApiModelProperty(value = "错误码备注", example = "我就是一个备注") |
| 44 | private String memo; | 31 | private String memo; |
| 45 | 32 | ||
| 46 | } | 33 | } |
| 34 | + |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/ErrorCodeVO.java
| 1 | package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; | 1 | package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; |
| 2 | 2 | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 3 | import lombok.Data; | 5 | import lombok.Data; |
| 4 | import lombok.experimental.Accessors; | 6 | import lombok.experimental.Accessors; |
| 5 | 7 | ||
| @@ -9,40 +11,23 @@ import java.util.Date; | @@ -9,40 +11,23 @@ import java.util.Date; | ||
| 9 | /** | 11 | /** |
| 10 | * 错误码 | 12 | * 错误码 |
| 11 | */ | 13 | */ |
| 14 | +@ApiModel("错误码 VO") | ||
| 12 | @Data | 15 | @Data |
| 13 | -@Accessors(chain = true) | ||
| 14 | -public class ErrorCodeVO implements Serializable { | 16 | +public class ErrorCodeVO { |
| 15 | 17 | ||
| 16 | - /** | ||
| 17 | - * 错误码编号 | ||
| 18 | - */ | 18 | + @ApiModelProperty(value = "错误码编号", required = true, example = "1") |
| 19 | private Integer id; | 19 | private Integer id; |
| 20 | - /** | ||
| 21 | - * 错误码编码 | ||
| 22 | - */ | 20 | + @ApiModelProperty(value = "错误码编码", required = true, example = "10086") |
| 23 | private Integer code; | 21 | private Integer code; |
| 24 | - /** | ||
| 25 | - * 错误码错误提示 | ||
| 26 | - */ | 22 | + @ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑") |
| 27 | private String message; | 23 | private String message; |
| 28 | - /** | ||
| 29 | - * 错误码类型 | ||
| 30 | - */ | 24 | + @ApiModelProperty(value = "错误码类型", required = true, notes = "见 ErrorCodeTypeEnum 枚举", example = "1") |
| 31 | private Integer type; | 25 | private Integer type; |
| 32 | - /** | ||
| 33 | - * 错误码分组 | ||
| 34 | - */ | 26 | + @ApiModelProperty(value = "错误码分组", required = true, example = "user-service") |
| 35 | private String group; | 27 | private String group; |
| 36 | - /** | ||
| 37 | - * 错误码备注 | ||
| 38 | - */ | 28 | + @ApiModelProperty(value = "错误码备注", example = "我就是一个备注") |
| 39 | private String memo; | 29 | private String memo; |
| 40 | - /** | ||
| 41 | - * 创建时间 | ||
| 42 | - */ | 30 | + @ApiModelProperty(value = "创建时间", required = true) |
| 43 | private Date createTime; | 31 | private Date createTime; |
| 44 | - /** | ||
| 45 | - * 最后更新时间 | ||
| 46 | - */ | ||
| 47 | - private Date updateTime; | 32 | + |
| 48 | } | 33 | } |
src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysAuthServiceImpl.java
| @@ -85,7 +85,7 @@ public class SysAuthServiceImpl implements SysAuthService { | @@ -85,7 +85,7 @@ public class SysAuthServiceImpl implements SysAuthService { | ||
| 85 | @Override | 85 | @Override |
| 86 | public String login(SysAuthLoginReqVO reqVO, String userIp, String userAgent) { | 86 | public String login(SysAuthLoginReqVO reqVO, String userIp, String userAgent) { |
| 87 | // 判断验证码是否正确 | 87 | // 判断验证码是否正确 |
| 88 | - this.verifyCaptcha(reqVO.getUsername(), reqVO.getUuid(), reqVO.getCode()); | 88 | +// this.verifyCaptcha(reqVO.getUsername(), reqVO.getUuid(), reqVO.getCode()); |
| 89 | 89 | ||
| 90 | // 使用账号密码,进行登陆。 | 90 | // 使用账号密码,进行登陆。 |
| 91 | LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword()); | 91 | LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword()); |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java
| @@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.service.errorcode; | @@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.service.errorcode; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | 4 | import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; |
| 5 | import cn.iocoder.dashboard.common.pojo.PageResult; | 5 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 6 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | ||
| 6 | import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; | 7 | 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.dataobject.errorcode.ErrorCodeDO; |
| 8 | import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper; | 9 | import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper; |