错误码模块,代码 REVIEW

This commit is contained in:
YunaiV 2020-05-11 21:45:16 +08:00
parent b227928135
commit b45739d151
7 changed files with 23 additions and 6 deletions

View File

@ -1,11 +1,12 @@
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.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 {
*
* - 1退货退款
* - 2退款
*
* / TODO FROM 芋艿 to xiaofeng可以瞅瞅 @InEnum 注解直接校验退货类型
*/
@NotNull(message = "退货类型不能为空!")
private Integer returnType;

View File

@ -14,6 +14,7 @@ import java.util.List;
@Configuration
public class ServiceExceptionConfiguration {
// TODO FROM 芋艿 to 鱿鱼须这块的实现微信一起沟通下哈大体是说要调用 RPC 接口不然别的模块无法使用哟最终我们是要做成 starter提供给各个模块用
@Autowired
private ErrorCodeService errorCodeService;

View File

@ -30,4 +30,8 @@ public class ErrorCodeDO extends DeletableDO {
* 错误码类型
*/
private Integer type;
// TODO FROM 芋艿 to 鱿鱼丝增加一个分组字段方便做归类
// TODO FROM 芋艿 to 鱿鱼丝增加个备注字段方便做备注哈
}

View File

@ -16,6 +16,7 @@ public class ErrorCodeUpdateDTO {
/**
* 错误码编号,内置错误码的id是没有的
*/
// TODO FROM 芋艿 to 鱿鱼丝必要的参数校验噢
private Integer id;
@NotNull(message = "错误码编码不能为空")

View File

@ -37,6 +37,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
@Override
public List<ErrorCodeBO> getErrorCodeList() {
// TODO FROM 芋艿 to 鱿鱼丝QueryWrapperX 只存在 mapper 不直接体现在 Service
List<ErrorCodeDO> list = errorCodeMapper.selectList(new QueryWrapperX<ErrorCodeDO>());
return ErrorCodeConvert.INSTANCE.convertList(list);
}
@ -44,6 +45,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
@Override
public List<ErrorCodeBO> getErrorCodeListAll() {
List<ErrorCodeDO> list = errorCodeMapper.selectList(new QueryWrapperX<ErrorCodeDO>());
// TODO FROM 芋艿 to 鱿鱼丝这块微信交流一波哈
for (SystemErrorCodeEnum item : SystemErrorCodeEnum.values()) {
list.add(new ErrorCodeDO().setId(0).setCode(item.getCode()).
setMessage(item.getMessage()).setType(ErrorCodeTypeEnum.SYSTEM.getType()));
@ -103,6 +105,7 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
if (errorCodeDO == null) {
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.ERROR_CODE_NOT_EXISTS);
}
// TODO FROM 芋艿 to 鱿鱼丝不能删除内置错误码
// 更新到数据库标记删除
errorCodeMapper.deleteById(errorCodeDO.getId());
// TODO: 2020-05-10 刷新对外提供的错误码列表
@ -125,13 +128,15 @@ public class ErrorCodeServiceImpl implements ErrorCodeService {
}
private PageResult listToPageList(int currentPage, int rows, List list){
// TODO FROM 芋艿 to 鱿鱼须可以直接使用数据库分页哇
currentPage = currentPage * rows;
Integer sum = list.size();
Integer sum = list.size(); // TODO FROM 芋艿 to 鱿鱼须这里 int 就可以啦一般情况下如果 IDEA 提示警告要尽量去掉噢
if (currentPage + rows > sum){
list = list.subList(currentPage, sum);
}else {
list = list.subList(currentPage, currentPage + rows);
}
// TODO FROM 芋艿 to 鱿鱼丝泛型噢
return new PageResult().setList(list).setTotal(sum);
}
}

View File

@ -27,9 +27,9 @@ import org.springframework.web.bind.annotation.*;
* @author youyusi
*/
@RestController
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/errorcode")
@RequestMapping(MallConstants.ROOT_PATH_ADMIN + "/errorcode") // TODO FROM 芋艿 to 鱿鱼须error-code
@Api("错误码")
public class SystemErrorCodeController {
public class SystemErrorCodeController { // TODO FROM 芋艿 to 鱿鱼须变量要空行
@Autowired
private ErrorCodeService errorCodeService;

View File

@ -12,4 +12,7 @@ import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ErrorCodePageRequest {
// TODO FROM 芋艿 to 鱿鱼须分页参数
// TODO FROM 芋艿 to 鱿鱼须对于 rest 的接口要区分下是给 Admins 管理员还是 Users 用户的
}