#
luxiaotao1123
2024-02-13 c1657f830ddd01fbe421c46ea2e139e1f7dd7567
#
1个文件已添加
1个文件已修改
51 ■■■■■ 已修改文件
zy-asrs-framework/src/main/java/com/zy/asrs/framework/domain/QueryField.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-framework/src/main/java/com/zy/asrs/framework/domain/QueryField.java
New file
@@ -0,0 +1,22 @@
package com.zy.asrs.framework.domain;
import java.lang.annotation.*;
/**
 * 查询条件注解
 *
 * @author vincent
 * @since 2021-09-01 20:48:16
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
public @interface QueryField {
    // 字段名称
    String value() default "";
    // 查询方式
    QueryType type() default QueryType.LIKE;
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java
@@ -5,7 +5,9 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.domain.QueryField;
import com.zy.asrs.framework.domain.QueryType;
import com.zy.asrs.wcs.utils.Utils;
import java.lang.reflect.Field;
import java.util.Arrays;
@@ -21,14 +23,23 @@
    private final U where;
    /**
     * 是否把字段名称驼峰转下划线
     */
    private final boolean isToUnderlineCase;
    public PageParam() {
        this(null);
    }
    public PageParam(U where) {
        this(where, true);
    }
    public PageParam(U where, boolean isToUnderlineCase) {
        super();
        this.where = where;
        this.isToUnderlineCase = isToUnderlineCase;
        if (where != null) {
            if (where.getPageIdx() != null) {
                setCurrent(where.getPageIdx());
@@ -39,9 +50,20 @@
        }
    }
    /**
     * @param excludes 不包含的字段
     */
    public QueryWrapper<T> getWrapper(String... excludes) {
        return buildWrapper(null, Arrays.asList(excludes));
    }
    /**
     * @param columns 只包含的字段
     */
    public QueryWrapper<T> getWrapperWith(String... columns) {
        return buildWrapper(Arrays.asList(columns), null);
    }
    private QueryWrapper<T> buildWrapper(List<String> columns, List<String> excludes) {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
@@ -77,9 +99,8 @@
                if (!Cools.isEmpty(queryField.value())) {
                    fieldName = queryField.value();
                }
                if (queryField.type() != null) {
                    queryType = queryField.type();
                }
                queryField.type();
                queryType = queryField.type();
            } else {
                // 过滤非本表的字段
                TableField tableField = field.getAnnotation(TableField.class);