提交 b45739d1 authored 作者: YunaiV's avatar YunaiV

错误码模块,代码 REVIEW

上级 b2279281
package cn.iocoder.mall.order.rest.request.users; package cn.iocoder.mall.order.rest.request.users;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/** /**
* 订单售后 * 订单售后
* *
...@@ -26,6 +27,8 @@ public class OrderReturnApplyRequest implements Serializable { ...@@ -26,6 +27,8 @@ public class OrderReturnApplyRequest implements Serializable {
* *
* - 1、退货退款 * - 1、退货退款
* - 2、退款 * - 2、退款
*
* / TODO FROM 芋艿 to xiaofeng:可以瞅瞅 @InEnum 注解,直接校验退货类型
*/ */
@NotNull(message = "退货类型不能为空!") @NotNull(message = "退货类型不能为空!")
private Integer returnType; private Integer returnType;
......
...@@ -14,6 +14,7 @@ import java.util.List; ...@@ -14,6 +14,7 @@ import java.util.List;
@Configuration @Configuration
public class ServiceExceptionConfiguration { public class ServiceExceptionConfiguration {
// TODO FROM 芋艿 to 鱿鱼须:这块的实现,微信一起沟通下哈。大体是说,要调用 RPC 接口,不然别的模块无法使用哟。最终,我们是要做成 starter,提供给各个模块用。
@Autowired @Autowired
private ErrorCodeService errorCodeService; private ErrorCodeService errorCodeService;
......
...@@ -30,4 +30,8 @@ public class ErrorCodeDO extends DeletableDO { ...@@ -30,4 +30,8 @@ public class ErrorCodeDO extends DeletableDO {
* 错误码类型 * 错误码类型
*/ */
private Integer type; private Integer type;
// TODO FROM 芋艿 to 鱿鱼丝:增加一个分组字段。方便做归类
// TODO FROM 芋艿 to 鱿鱼丝:增加个备注字段,方便做备注哈。
} }
...@@ -16,6 +16,7 @@ public class ErrorCodeUpdateDTO { ...@@ -16,6 +16,7 @@ public class ErrorCodeUpdateDTO {
/** /**
* 错误码编号,内置错误码的id是没有的 * 错误码编号,内置错误码的id是没有的
*/ */
// TODO FROM 芋艿 to 鱿鱼丝:必要的参数校验噢
private Integer id; private Integer id;
@NotNull(message = "错误码编码不能为空") @NotNull(message = "错误码编码不能为空")
......
...@@ -37,6 +37,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService { ...@@ -37,6 +37,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
@Override @Override
public List<ErrorCodeBO> getErrorCodeList() { public List<ErrorCodeBO> getErrorCodeList() {
// TODO FROM 芋艿 to 鱿鱼丝:QueryWrapperX 只存在 mapper 里,不直接体现在 Service
List<ErrorCodeDO> list = errorCodeMapper.selectList(new QueryWrapperX<ErrorCodeDO>()); List<ErrorCodeDO> list = errorCodeMapper.selectList(new QueryWrapperX<ErrorCodeDO>());
return ErrorCodeConvert.INSTANCE.convertList(list); return ErrorCodeConvert.INSTANCE.convertList(list);
} }
...@@ -44,6 +45,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService { ...@@ -44,6 +45,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
@Override @Override
public List<ErrorCodeBO> getErrorCodeListAll() { public List<ErrorCodeBO> getErrorCodeListAll() {
List<ErrorCodeDO> list = errorCodeMapper.selectList(new QueryWrapperX<ErrorCodeDO>()); List<ErrorCodeDO> list = errorCodeMapper.selectList(new QueryWrapperX<ErrorCodeDO>());
// TODO FROM 芋艿 to 鱿鱼丝:这块微信交流一波哈。
for (SystemErrorCodeEnum item : SystemErrorCodeEnum.values()) { for (SystemErrorCodeEnum item : SystemErrorCodeEnum.values()) {
list.add(new ErrorCodeDO().setId(0).setCode(item.getCode()). list.add(new ErrorCodeDO().setId(0).setCode(item.getCode()).
setMessage(item.getMessage()).setType(ErrorCodeTypeEnum.SYSTEM.getType())); setMessage(item.getMessage()).setType(ErrorCodeTypeEnum.SYSTEM.getType()));
...@@ -103,6 +105,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService { ...@@ -103,6 +105,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
if (errorCodeDO == null) { if (errorCodeDO == null) {
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.ERROR_CODE_NOT_EXISTS); throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.ERROR_CODE_NOT_EXISTS);
} }
// TODO FROM 芋艿 to 鱿鱼丝:不能删除内置错误码
// 更新到数据库,标记删除 // 更新到数据库,标记删除
errorCodeMapper.deleteById(errorCodeDO.getId()); errorCodeMapper.deleteById(errorCodeDO.getId());
// TODO: 2020-05-10 刷新对外提供的错误码列表 // TODO: 2020-05-10 刷新对外提供的错误码列表
...@@ -125,13 +128,15 @@ public class ErrorCodeServiceImpl implements ErrorCodeService { ...@@ -125,13 +128,15 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
} }
private PageResult listToPageList(int currentPage, int rows, List list){ private PageResult listToPageList(int currentPage, int rows, List list){
// TODO FROM 芋艿 to 鱿鱼须:可以直接使用数据库分页哇
currentPage = currentPage * rows; currentPage = currentPage * rows;
Integer sum = list.size(); Integer sum = list.size(); // TODO FROM 芋艿 to 鱿鱼须:这里 int 就可以啦。一般情况下,如果 IDEA 提示警告,要尽量去掉噢。
if (currentPage + rows > sum){ if (currentPage + rows > sum){
list = list.subList(currentPage, sum); list = list.subList(currentPage, sum);
}else { }else {
list = list.subList(currentPage, currentPage + rows); list = list.subList(currentPage, currentPage + rows);
} }
// TODO FROM 芋艿 to 鱿鱼丝:泛型噢
return new PageResult().setList(list).setTotal(sum); return new PageResult().setList(list).setTotal(sum);
} }
} }
...@@ -27,9 +27,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -27,9 +27,9 @@ import org.springframework.web.bind.annotation.*;
* @author youyusi * @author youyusi
*/ */
@RestController @RestController
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/errorcode") @RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/errorcode") // TODO FROM 芋艿 to 鱿鱼须:error-code
@Api("错误码") @Api("错误码")
public class SystemErrorCodeController { public class SystemErrorCodeController { // TODO FROM 芋艿 to 鱿鱼须:变量要空行
@Autowired @Autowired
private ErrorCodeService errorCodeService; private ErrorCodeService errorCodeService;
......
...@@ -12,4 +12,7 @@ import lombok.experimental.Accessors; ...@@ -12,4 +12,7 @@ import lombok.experimental.Accessors;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class ErrorCodePageRequest { public class ErrorCodePageRequest {
// TODO FROM 芋艿 to 鱿鱼须:分页参数?
// TODO FROM 芋艿 to 鱿鱼须:对于 rest 的接口,要区分下是给 Admins 管理员还是 Users 用户的
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论