完成错误码

pull/2/head
dylan 2021-03-15 21:51:00 +08:00
parent 4c3997b628
commit 54378aeed3
7 changed files with 57 additions and 100 deletions

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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());

View File

@ -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;