From 0d04bc5d8080b82338302fba0a59fccff2eaedfc Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期日, 06 七月 2025 11:28:29 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java | 39 +++++++++++++++++++++++++++++++++------ 1 files changed, 33 insertions(+), 6 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java index 9b924f1..83c0a9e 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java @@ -5,13 +5,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.common.DateUtils; -import com.zy.asrs.wcs.utils.Utils; +import com.zy.asrs.wcs.utils.CommonUtils; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Consumer; /** * Created by vincent on 2/13/2024 @@ -65,8 +66,16 @@ return this.buildWrapper(false); } - @SuppressWarnings("all") + public QueryWrapper<T> buildWrapper(Consumer<QueryWrapper<T>> consumer) { + return this.buildWrapper(false, consumer); + } + public QueryWrapper<T> buildWrapper(boolean like) { + return this.buildWrapper(like, null); + } + + @SuppressWarnings("all") + public QueryWrapper<T> buildWrapper(boolean like, Consumer<QueryWrapper<T>> consumer) { QueryWrapper<T> queryWrapper = new QueryWrapper<>(); Map<String, Object> map = where.getMap(); for (String key : map.keySet()) { @@ -80,14 +89,14 @@ if (null != list) { key = key.replaceAll("Range", ""); if (this.isToUnderlineCase) { - key = Utils.toSymbolCase(key, '_'); + key = CommonUtils.toSymbolCase(key, '_'); } queryWrapper.ge(key, DateUtils.convert(list.get(0))); queryWrapper.le(key, DateUtils.convert(list.get(1))); } } else { if (this.isToUnderlineCase) { - key = Utils.toSymbolCase(key, '_'); + key = CommonUtils.toSymbolCase(key, '_'); } if (like) { queryWrapper.like(key, val); @@ -98,12 +107,16 @@ } } + if (null != consumer) { + consumer.accept(queryWrapper); + } + Field[] fields = null; if (!Cools.isEmpty(cls)) { fields = Cools.getAllFields(cls); for (Field field : fields) { if ("createTime".equals(field.getName())) { - queryWrapper.orderByDesc(Utils.toSymbolCase(field.getName(), '_')); + queryWrapper.orderByDesc(CommonUtils.toSymbolCase(field.getName(), '_')); } } } @@ -124,7 +137,7 @@ } } - String column = Utils.toSymbolCase(field.getName(), '_'); + String column = CommonUtils.toSymbolCase(field.getName(), '_'); columns.add(column); } if (!columns.isEmpty()) { @@ -143,4 +156,18 @@ return queryWrapper; } + public Map<String, Object> pickOutMap() { + return pickOutMap(false); + } + + public Map<String, Object> pickOutMap(boolean mergeCondition) { + Map<String, Object> map = where.getMap(); + if (mergeCondition) { + if (!Cools.isEmpty(where.getCondition())) { + map.put("condition", where.getCondition()); + } + } + return map; + } + } -- Gitblit v1.9.1