增加默认排序效果

v1.4.1
Parker 4 years ago
parent 1d30bf2641
commit c7ae78342f

@ -1,5 +1,6 @@
package org.opsli.api.base.warpper;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.baomidou.mybatisplus.annotation.TableId;
@ -80,7 +81,7 @@ public abstract class ApiWrapper implements Serializable {
/** 乐观锁 版本 */
@ApiModelProperty(value = "版本")
@ExcelProperty(value = "版本", order = 1005)
@ExcelIgnore
@CellStyleFormat
@Version
private Integer version;

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.constants.MyBatisConstants;
import org.opsli.common.utils.HumpUtil;
import org.opsli.core.base.entity.BaseEntity;
@ -103,6 +104,8 @@ public class PageQueryBuilder<E extends ApiWrapper,T extends BaseEntity>{
if(this.parameterMap == null){
return queryWrapper;
}
// order 排序次数 如果为0 则默认按照修改时间来排序
int orderCount = 0;
for (Map.Entry<String, String[]> stringEntry : this.parameterMap.entrySet()) {
String keys = stringEntry.getKey();
String[] values = stringEntry.getValue();
@ -130,9 +133,17 @@ public class PageQueryBuilder<E extends ApiWrapper,T extends BaseEntity>{
String value = values[0];
// 赋值
this.handlerValue(queryWrapper, handle, key ,value);
// 如果有排序 就+1
if(ORDER.equals(handle)){
orderCount++;
}
}
}
}
// 如果没有排序 默认按照 修改时间倒叙排序
if(orderCount == 0){
queryWrapper.orderByDesc(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_UPDATE_TIME));
}
return queryWrapper;
}

Loading…
Cancel
Save