完成错误码
parent
4c3997b628
commit
54378aeed3
|
@ -12,10 +12,14 @@ import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService;
|
||||||
import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO;
|
import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||||
|
import org.springframework.web.bind.ServletRequestDataBinder;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -50,7 +54,7 @@ public class ErrorCodeController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation("自动生成错误码")
|
@ApiOperation("自动生成错误码")
|
||||||
@PostMapping("/generate")
|
@PostMapping("/generate")
|
||||||
public CommonResult<Boolean> autoGenerateErrorCodes(List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) {
|
public CommonResult<Boolean> autoGenerateErrorCodes(@RequestBody List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) {
|
||||||
errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs));
|
errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs));
|
||||||
return success(Boolean.TRUE);
|
return success(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +68,7 @@ public class ErrorCodeController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation("创建错误码")
|
@ApiOperation("创建错误码")
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public CommonResult<Integer> createErrorCode(ErrorCodeCreateDTO createDTO) {
|
public CommonResult<Integer> createErrorCode(@RequestBody ErrorCodeCreateDTO createDTO) {
|
||||||
return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId());
|
return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +79,7 @@ public class ErrorCodeController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation("更新错误码")
|
@ApiOperation("更新错误码")
|
||||||
@PatchMapping("/update")
|
@PatchMapping("/update")
|
||||||
public CommonResult<Boolean> updateErrorCode(ErrorCodeUpdateDTO updateDTO) {
|
public CommonResult<Boolean> updateErrorCode(@RequestBody ErrorCodeUpdateDTO updateDTO) {
|
||||||
errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO));
|
errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO));
|
||||||
return success(Boolean.TRUE);
|
return success(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +116,7 @@ public class ErrorCodeController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取错误码列表")
|
@ApiOperation("获取错误码列表")
|
||||||
@GetMapping("/query-ids")
|
@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)));
|
return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,5 +133,11 @@ public class ErrorCodeController {
|
||||||
return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,27 @@
|
||||||
package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
|
package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.framework.validator.InEnum;
|
import io.swagger.annotations.ApiModel;
|
||||||
import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
@ApiModel("错误码创建 DTO")
|
||||||
* 错误码创建 DTO
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
public class ErrorCodeCreateDTO {
|
||||||
public class ErrorCodeCreateDTO implements Serializable {
|
|
||||||
|
|
||||||
/**
|
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
|
||||||
* 错误码编码
|
|
||||||
*/
|
|
||||||
@NotNull(message = "错误码编码不能为空")
|
@NotNull(message = "错误码编码不能为空")
|
||||||
private Integer code;
|
private Integer code;
|
||||||
/**
|
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
|
||||||
* 错误码错误提示
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "错误码错误提示不能为空")
|
@NotEmpty(message = "错误码错误提示不能为空")
|
||||||
private String message;
|
private String message;
|
||||||
/**
|
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
|
||||||
* 错误码类型
|
@NotEmpty(message = "错误码分组不能为空")
|
||||||
*/
|
|
||||||
@NotNull(message = "错误码类型不能为空")
|
|
||||||
@InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}")
|
|
||||||
private Integer type;
|
|
||||||
/**
|
|
||||||
* 错误码分组
|
|
||||||
*/
|
|
||||||
@NotNull(message = "错误码分组不能为空")
|
|
||||||
private String group;
|
private String group;
|
||||||
/**
|
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
|
||||||
* 错误码备注
|
|
||||||
*/
|
|
||||||
private String memo;
|
private String memo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,24 @@
|
||||||
package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
|
package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.common.pojo.PageParam;
|
import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误码分页 DTO
|
* 错误码分页 DTO
|
||||||
*/
|
*/
|
||||||
|
@ApiModel("错误码分页 DTO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Accessors(chain = true)
|
|
||||||
public class ErrorCodePageDTO extends PageParam {
|
public class ErrorCodePageDTO extends PageParam {
|
||||||
|
|
||||||
/**
|
@ApiModelProperty(value = "错误码编码", required = true)
|
||||||
* 错误码编码
|
|
||||||
*/
|
|
||||||
private Integer code;
|
private Integer code;
|
||||||
/**
|
@ApiModelProperty(value = "错误码错误提示", required = true)
|
||||||
* 错误码错误提示
|
|
||||||
*
|
|
||||||
* 模糊匹配
|
|
||||||
*/
|
|
||||||
private String message;
|
private String message;
|
||||||
/**
|
@ApiModelProperty(value = "错误码分组", required = true)
|
||||||
* 错误码分组
|
|
||||||
*
|
|
||||||
* 模糊匹配
|
|
||||||
*/
|
|
||||||
private String group;
|
private String group;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,45 +2,33 @@ package cn.iocoder.dashboard.modules.system.controller.errorcode.dto;
|
||||||
|
|
||||||
import cn.iocoder.dashboard.framework.validator.InEnum;
|
import cn.iocoder.dashboard.framework.validator.InEnum;
|
||||||
import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum;
|
import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
@ApiModel("错误码更新 DTO")
|
||||||
* 错误码更新 DTO
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
public class ErrorCodeUpdateDTO {
|
||||||
public class ErrorCodeUpdateDTO implements Serializable {
|
|
||||||
|
|
||||||
/**
|
@ApiModelProperty(value = "错误码编号", required = true, example = "1")
|
||||||
* 错误码编号
|
|
||||||
*/
|
|
||||||
@NotNull(message = "错误码编号不能为空")
|
@NotNull(message = "错误码编号不能为空")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
/**
|
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
|
||||||
* 错误码编码
|
|
||||||
*/
|
|
||||||
@NotNull(message = "错误码编码不能为空")
|
@NotNull(message = "错误码编码不能为空")
|
||||||
private Integer code;
|
private Integer code;
|
||||||
/**
|
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
|
||||||
* 错误码错误提示
|
@NotEmpty(message = "错误码错误提示不能为空")
|
||||||
*/
|
|
||||||
private String message;
|
private String message;
|
||||||
/**
|
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
|
||||||
* 错误码类型
|
@NotEmpty(message = "错误码分组不能为空")
|
||||||
*/
|
|
||||||
@InEnum(value = ErrorCodeTypeEnum.class, message = "错误码类型必须是 {value}")
|
|
||||||
private Integer type;
|
|
||||||
/**
|
|
||||||
* 错误码分组
|
|
||||||
*/
|
|
||||||
private String group;
|
private String group;
|
||||||
/**
|
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
|
||||||
* 错误码备注
|
|
||||||
*/
|
|
||||||
private String memo;
|
private String memo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package cn.iocoder.dashboard.modules.system.controller.errorcode.vo;
|
package cn.iocoder.dashboard.modules.system.controller.errorcode.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@ -9,40 +11,23 @@ import java.util.Date;
|
||||||
/**
|
/**
|
||||||
* 错误码
|
* 错误码
|
||||||
*/
|
*/
|
||||||
|
@ApiModel("错误码 VO")
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
public class ErrorCodeVO {
|
||||||
public class ErrorCodeVO implements Serializable {
|
|
||||||
|
|
||||||
/**
|
@ApiModelProperty(value = "错误码编号", required = true, example = "1")
|
||||||
* 错误码编号
|
|
||||||
*/
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
/**
|
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
|
||||||
* 错误码编码
|
|
||||||
*/
|
|
||||||
private Integer code;
|
private Integer code;
|
||||||
/**
|
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
|
||||||
* 错误码错误提示
|
|
||||||
*/
|
|
||||||
private String message;
|
private String message;
|
||||||
/**
|
@ApiModelProperty(value = "错误码类型", required = true, notes = "见 ErrorCodeTypeEnum 枚举", example = "1")
|
||||||
* 错误码类型
|
|
||||||
*/
|
|
||||||
private Integer type;
|
private Integer type;
|
||||||
/**
|
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
|
||||||
* 错误码分组
|
|
||||||
*/
|
|
||||||
private String group;
|
private String group;
|
||||||
/**
|
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
|
||||||
* 错误码备注
|
|
||||||
*/
|
|
||||||
private String memo;
|
private String memo;
|
||||||
/**
|
@ApiModelProperty(value = "创建时间", required = true)
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
/**
|
|
||||||
* 最后更新时间
|
|
||||||
*/
|
|
||||||
private Date updateTime;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||||
@Override
|
@Override
|
||||||
public String login(SysAuthLoginReqVO reqVO, String userIp, String userAgent) {
|
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());
|
LoginUser loginUser = this.login0(reqVO.getUsername(), reqVO.getPassword());
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.service.errorcode;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
|
||||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
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.convert.errorcode.ErrorCodeConvert;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO;
|
import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO;
|
||||||
import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper;
|
import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper;
|
||||||
|
|
Loading…
Reference in New Issue