错误码的 Starter 的初始化,完成

This commit is contained in:
YunaiV
2020-07-20 19:18:27 +08:00
parent 0df486a677
commit 187b17ed01
50 changed files with 1249 additions and 611 deletions

View File

@@ -0,0 +1,67 @@
package cn.iocoder.mall.managementweb.controller.errorcode;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeCreateDTO;
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodePageDTO;
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeUpdateDTO;
import cn.iocoder.mall.managementweb.controller.errorcode.vo.ErrorCodeVO;
import cn.iocoder.mall.managementweb.manager.errorcode.ErrorCodeManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 错误码 Controller
*/
@RestController
@RequestMapping("/error-code")
@Api(tags = "错误码")
@Validated
public class ErrorCodeController {
@Autowired
private ErrorCodeManager errorCodeManager;
@PostMapping("/create")
@ApiOperation("创建错误码")
public CommonResult<Integer> createErrorCode(@Valid ErrorCodeCreateDTO createDTO) {
return success(errorCodeManager.createErrorCode(createDTO));
}
@PostMapping("/update")
@ApiOperation("更新错误码")
public CommonResult<Boolean> updateErrorCode(@Valid ErrorCodeUpdateDTO updateDTO) {
errorCodeManager.updateErrorCode(updateDTO);
return success(true);
}
@PostMapping("/delete")
@ApiOperation("删除错误码")
@ApiImplicitParam(name = "errorCodeId", value = "错误码编号", required = true)
public CommonResult<Boolean> deleteErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) {
errorCodeManager.deleteErrorCode(errorCodeId);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得错误码")
@ApiImplicitParam(name = "errorCodeId", value = "错误码编号", required = true)
public CommonResult<ErrorCodeVO> getErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) {
return success(errorCodeManager.getErrorCode(errorCodeId));
}
@GetMapping("/page")
@ApiOperation("获得错误码分页")
public CommonResult<PageResult<ErrorCodeVO>> pageErrorCode(ErrorCodePageDTO pageDTO) {
return success(errorCodeManager.pageErrorCode(pageDTO));
}
}

View File

@@ -0,0 +1,26 @@
package cn.iocoder.mall.managementweb.controller.errorcode.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("错误码创建 DTO")
@Data
public class ErrorCodeCreateDTO {
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
@NotNull(message = "错误码编码不能为空")
private Integer code;
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
@NotEmpty(message = "错误码错误提示不能为空")
private String message;
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
@NotEmpty(message = "错误码分组不能为空")
private String group;
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
private String memo;
}

View File

@@ -0,0 +1,21 @@
package cn.iocoder.mall.managementweb.controller.errorcode.dto;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("错误码分页 DTO")
@Data
@EqualsAndHashCode(callSuper = 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

@@ -0,0 +1,29 @@
package cn.iocoder.mall.managementweb.controller.errorcode.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("错误码更新 DTO")
@Data
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;
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
@NotEmpty(message = "错误码分组不能为空")
private String group;
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
private String memo;
}

View File

@@ -0,0 +1,28 @@
package cn.iocoder.mall.managementweb.controller.errorcode.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@ApiModel("错误码 VO")
@Data
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;
}