From c7ae78342fc124d47b4796c0a12f803b89581fe8 Mon Sep 17 00:00:00 2001 From: Parker Date: Sun, 20 Sep 2020 23:42:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/opsli/api/base/warpper/ApiWrapper.java | 3 ++- .../org/opsli/core/persistence/PageQueryBuilder.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/opsli-api/src/main/java/org/opsli/api/base/warpper/ApiWrapper.java b/opsli-api/src/main/java/org/opsli/api/base/warpper/ApiWrapper.java index 3f3d3e7..122540e 100644 --- a/opsli-api/src/main/java/org/opsli/api/base/warpper/ApiWrapper.java +++ b/opsli-api/src/main/java/org/opsli/api/base/warpper/ApiWrapper.java @@ -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; diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/PageQueryBuilder.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/PageQueryBuilder.java index f55d58f..4118ccc 100644 --- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/PageQueryBuilder.java +++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/persistence/PageQueryBuilder.java @@ -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{ if(this.parameterMap == null){ return queryWrapper; } + // order 排序次数 如果为0 则默认按照修改时间来排序 + int orderCount = 0; for (Map.Entry stringEntry : this.parameterMap.entrySet()) { String keys = stringEntry.getKey(); String[] values = stringEntry.getValue(); @@ -130,9 +133,17 @@ public class PageQueryBuilder{ 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; }