Explorar o código

完成错误码

dylan %!s(int64=4) %!d(string=hai) anos
pai
achega
54378aeed3

+ 14 - 4
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;
 import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.propertyeditors.CustomDateEditor;
+import org.springframework.web.bind.ServletRequestDataBinder;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import javax.validation.constraints.NotNull;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -50,7 +54,7 @@ public class ErrorCodeController {
      */
     @ApiOperation("自动生成错误码")
     @PostMapping("/generate")
-    public CommonResult<Boolean> autoGenerateErrorCodes(List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) {
+    public CommonResult<Boolean> autoGenerateErrorCodes(@RequestBody List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) {
         errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs));
         return success(Boolean.TRUE);
     }
@@ -64,7 +68,7 @@ public class ErrorCodeController {
      */
     @ApiOperation("创建错误码")
     @PostMapping("/create")
-    public CommonResult<Integer> createErrorCode(ErrorCodeCreateDTO createDTO) {
+    public CommonResult<Integer> createErrorCode(@RequestBody ErrorCodeCreateDTO createDTO) {
         return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId());
     }
 
@@ -75,7 +79,7 @@ public class ErrorCodeController {
      */
     @ApiOperation("更新错误码")
     @PatchMapping("/update")
-    public CommonResult<Boolean> updateErrorCode(ErrorCodeUpdateDTO updateDTO) {
+    public CommonResult<Boolean> updateErrorCode(@RequestBody ErrorCodeUpdateDTO updateDTO) {
         errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO));
         return success(Boolean.TRUE);
     }
@@ -112,7 +116,7 @@ public class ErrorCodeController {
      */
     @ApiOperation("获取错误码列表")
     @GetMapping("/query-ids")
-    public CommonResult<List<ErrorCodeVO>> listErrorCodes(List<Integer> errorCodeIds) {
+    public CommonResult<List<ErrorCodeVO>> listErrorCodes(@RequestBody List<Integer> errorCodeIds) {
         return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds)));
     }
 
@@ -129,5 +133,11 @@ public class ErrorCodeController {
         return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult));
     }
 
+    @InitBinder
+    protected void init(HttpServletRequest request, ServletRequestDataBinder binder) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        dateFormat.setLenient(false);
+        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
+    }
 
 }

+ 10 - 28
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodeCreateDTO.java

@@ -1,45 +1,27 @@
 package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
 
-import cn.iocoder.dashboard.framework.validator.InEnum;
-import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import lombok.experimental.Accessors;
 
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
-import java.io.Serializable;
 
-/**
- * 错误码创建 DTO
- */
+@ApiModel("错误码创建 DTO")
 @Data
-@Accessors(chain = true)
-public class ErrorCodeCreateDTO implements Serializable {
+public class ErrorCodeCreateDTO {
 
-    /**
-     * 错误码编码
-     */
+    @ApiModelProperty(value = "错误码编码", required = true, example = "10086")
     @NotNull(message = "错误码编码不能为空")
     private Integer code;
-    /**
-     * 错误码错误提示
-     */
+    @ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
     @NotEmpty(message = "错误码错误提示不能为空")
     private String message;
-    /**
-     * 错误码类型
-     */
-    @NotNull(message = "错误码类型不能为空")
-    @InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}")
-    private Integer type;
-    /**
-     * 错误码分组
-     */
-    @NotNull(message = "错误码分组不能为空")
+    @ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
+    @NotEmpty(message = "错误码分组不能为空")
     private String group;
-    /**
-     * 错误码备注
-     */
+    @ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
     private String memo;
 
 }
+

+ 6 - 15
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/dto/ErrorCodePageDTO.java

@@ -1,33 +1,24 @@
 package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
 
 import cn.iocoder.dashboard.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
 
 /**
  * 错误码分页 DTO
  */
+@ApiModel("错误码分页 DTO")
 @Data
 @EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
 public class ErrorCodePageDTO extends PageParam {
 
-    /**
-     * 错误码编码
-     */
+    @ApiModelProperty(value = "错误码编码", required = true)
     private Integer code;
-    /**
-     * 错误码错误提示
-     *
-     * 模糊匹配
-     */
+    @ApiModelProperty(value = "错误码错误提示", required = true)
     private String message;
-    /**
-     * 错误码分组
-     *
-     * 模糊匹配
-     */
+    @ApiModelProperty(value = "错误码分组", required = true)
     private String group;
 
 }

+ 13 - 25
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;
 
 import cn.iocoder.dashboard.framework.validator.InEnum;
 import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
-/**
- * 错误码更新 DTO
- */
+@ApiModel("错误码更新 DTO")
 @Data
-@Accessors(chain = true)
-public class ErrorCodeUpdateDTO implements Serializable {
+public class ErrorCodeUpdateDTO {
 
-    /**
-     * 错误码编号
-     */
+    @ApiModelProperty(value = "错误码编号", required = true, example = "1")
     @NotNull(message = "错误码编号不能为空")
     private Integer id;
-    /**
-     * 错误码编码
-     */
+    @ApiModelProperty(value = "错误码编码", required = true, example = "10086")
     @NotNull(message = "错误码编码不能为空")
     private Integer code;
-    /**
-     * 错误码错误提示
-     */
+    @ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
+    @NotEmpty(message = "错误码错误提示不能为空")
     private String message;
-    /**
-     * 错误码类型
-     */
-    @InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}")
-    private Integer type;
-    /**
-     * 错误码分组
-     */
+    @ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
+    @NotEmpty(message = "错误码分组不能为空")
     private String group;
-    /**
-     * 错误码备注
-     */
+    @ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
     private String memo;
 
 }
+

+ 12 - 27
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/ErrorCodeVO.java

@@ -1,5 +1,7 @@
 package cn.iocoder.dashboard.modules.system.controller.errorcode.vo;
 
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -9,40 +11,23 @@ import java.util.Date;
 /**
  * 错误码
  */
+@ApiModel("错误码 VO")
 @Data
-@Accessors(chain = true)
-public class ErrorCodeVO implements Serializable {
+public class ErrorCodeVO {
 
-    /**
-     * 错误码编号
-     */
+    @ApiModelProperty(value = "错误码编号", required = true, example = "1")
     private Integer id;
-    /**
-     * 错误码编码
-     */
+    @ApiModelProperty(value = "错误码编码", required = true, example = "10086")
     private Integer code;
-    /**
-     * 错误码错误提示
-     */
+    @ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
     private String message;
-    /**
-     * 错误码类型
-     */
+    @ApiModelProperty(value = "错误码类型", required = true, notes = "见 ErrorCodeTypeEnum 枚举", example = "1")
     private Integer type;
-    /**
-     * 错误码分组
-     */
+    @ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
     private String group;
-    /**
-     * 错误码备注
-     */
+    @ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
     private String memo;
-    /**
-     * 创建时间
-     */
+    @ApiModelProperty(value = "创建时间", required = true)
     private Date createTime;
-    /**
-     * 最后更新时间
-     */
-    private Date updateTime;
+
 }

+ 1 - 1
src/main/java/cn/iocoder/dashboard/modules/system/service/auth/impl/SysAuthServiceImpl.java

@@ -85,7 +85,7 @@ public class SysAuthServiceImpl implements SysAuthService {
     @Override
     public String login(SysAuthLoginReqVO reqVO, String userIp, String userAgent) {
         // 判断验证码是否正确
-        this.verifyCaptcha(reqVO.getUsername(), reqVO.getUuid(), reqVO.getCode());
+//        this.verifyCaptcha(reqVO.getUsername(), reqVO.getUuid(), reqVO.getCode());
 
         // 使用账号密码,进行登陆。
         LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword());

+ 1 - 0
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java

@@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.service.errorcode;
 import cn.hutool.core.collection.CollUtil;
 import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
 import cn.iocoder.dashboard.common.pojo.PageResult;
+import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO;
 import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert;
 import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO;
 import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper;