脚手架完善
This commit is contained in:
@@ -1,13 +1,8 @@
|
|||||||
package com.czg.core.page;
|
package com.czg.core.page;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页数据
|
* 分页数据
|
||||||
*
|
*
|
||||||
@@ -26,40 +21,8 @@ public class PageDomain {
|
|||||||
private Integer size;
|
private Integer size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序列,多个用逗号隔开
|
* 组合后的排序规则,例如:user_name asc,user_age desc (前端来处理排序字段驼峰转下划线)
|
||||||
*/
|
|
||||||
private String orderField;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序方式,多个用逗号分隔,asc:升序,desc:降序
|
|
||||||
*/
|
|
||||||
private String order;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组合后的排序规则
|
|
||||||
*/
|
*/
|
||||||
private String orderBy;
|
private String orderBy;
|
||||||
|
|
||||||
|
|
||||||
public String getOrderBy() {
|
|
||||||
if (StrUtil.isEmpty(orderField)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (StrUtil.isEmpty(orderBy)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
String[] orderFields = orderField.split(",");
|
|
||||||
String[] orders = orderBy.split(",");
|
|
||||||
if (orderFields.length != orders.length) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
List<String> orderBy = new ArrayList<>();
|
|
||||||
for (int i = 0; i < orderFields.length; i++) {
|
|
||||||
String orderField = orderFields[i];
|
|
||||||
String order = orders[i];
|
|
||||||
orderBy.add(StrUtil.toUnderlineCase(orderField) + " " + order);
|
|
||||||
}
|
|
||||||
return CollUtil.join(orderBy, ",");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user