优化:基于阿里巴巴 Java 开发手册(黄山版)优化常量

1.编程规约>常量定义>第1条:
【强制】不允许任何魔法值(即未经预先定义的常量)直接出现在代码中。
This commit is contained in:
2023-03-04 14:35:45 +08:00
parent c4d9bd3a75
commit 89a327920e
11 changed files with 65 additions and 26 deletions

View File

@@ -30,7 +30,7 @@ import org.springframework.data.domain.Sort;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import top.charles7c.cnadmin.common.constant.CharConsts;
import top.charles7c.cnadmin.common.constant.StringConsts;
/**
* 排序查询条件
@@ -62,10 +62,10 @@ public class SortQuery implements Serializable {
}
List<Sort.Order> orders = new ArrayList<>(sort.length);
if (StrUtil.contains(sort[0], CharConsts.COMMA)) {
if (StrUtil.contains(sort[0], StringConsts.COMMA)) {
// e.g "sort=published,desc&sort=title,asc"
for (String s : sort) {
List<String> sortList = StrUtil.splitTrim(s, CharConsts.COMMA);
List<String> sortList = StrUtil.splitTrim(s, StringConsts.COMMA);
Sort.Order order =
new Sort.Order(Sort.Direction.valueOf(sortList.get(1).toUpperCase()), sortList.get(0));
orders.add(order);