#
luxiaotao1123
2024-02-13 edfa49f201d3fc8fc6b51b700e91f80246660855
#
7个文件已修改
3个文件已添加
252 ■■■■■ 已修改文件
zy-asrs-framework/src/main/java/com/zy/asrs/framework/domain/QueryType.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/CoolGenerator.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/BaseParam.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Dept.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Host.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Menu.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Role.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/User.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-framework/src/main/java/com/zy/asrs/framework/domain/QueryType.java
New file
@@ -0,0 +1,42 @@
package com.zy.asrs.framework.domain;
/**
 * 查询方式
 *
 * @author vincent
 * @since 2021-09-01 20:48:16
 */
public enum QueryType {
    // 等于
    EQ,
    // 不等于
    NE,
    // 大于
    GT,
    // 大于等于
    GE,
    // 小于
    LT,
    // 小于等于
    LE,
    // 包含
    LIKE,
    // 不包含
    NOT_LIKE,
    // 结尾等于
    LIKE_LEFT,
    // 开头等于
    LIKE_RIGHT,
    // 为NULL
    IS_NULL,
    // 不为空
    IS_NOT_NULL,
    // IN
    IN,
    // NOT IN
    NOT_IN,
    // IN条件解析逗号分割
    IN_STR,
    // NOT IN条件解析逗号分割
    NOT_IN_STR
}
zy-asrs-framework/src/main/java/com/zy/asrs/framework/generators/CoolGenerator.java
@@ -406,6 +406,12 @@
            }
            if (column.getName().equals("deleted")) {
                entityIm.append("import com.baomidou.mybatisplus.annotation.TableLogic;\n");
                sb.append("    ")
                        .append("@TableLogic\n");
            }
            if ("Date".equals(column.getType())){
                if (setDateTimeFormat){
                    entityIm.append("import org.springframework.format.annotation.DateTimeFormat;").append("\n");
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/BaseParam.java
New file
@@ -0,0 +1,31 @@
package com.zy.asrs.wcs.common.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
/**
 * Created by vincent on 2/13/2024
 */
@Data
public class BaseParam implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Integer pageIdx;
    @TableField(exist = false)
    private Integer pageSize;
    @TableField(exist = false)
    private String timeStart;
    @TableField(exist = false)
    private String timeEnd;
    @TableField(exist = false)
    private String condition;
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/domain/PageParam.java
New file
@@ -0,0 +1,154 @@
package com.zy.asrs.wcs.common.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
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.QueryType;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
 * Created by vincent on 2/13/2024
 */
public class PageParam<T, U extends BaseParam> extends Page<T> {
    private static final long serialVersionUID = 1L;
    private final U where;
    public PageParam() {
        this(null);
    }
    public PageParam(U where) {
        super();
        this.where = where;
        if (where != null) {
            if (where.getPageIdx() != null) {
                setCurrent(where.getPageIdx());
            }
            if (where.getPageSize() != null) {
                setSize(where.getPageSize());
            }
        }
    }
    public QueryWrapper<T> getWrapper(String... excludes) {
        return buildWrapper(null, Arrays.asList(excludes));
    }
    private QueryWrapper<T> buildWrapper(List<String> columns, List<String> excludes) {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        Map<String, Object> map = Cools.conver(where);
        for (String fieldName : map.keySet()) {
            Object fieldValue = map.get(fieldName);
            Field field = Cools.getField(where.getClass(), fieldName);
            assert field != null;
            // 过滤不包含的字段
            if (columns != null && !columns.contains(fieldName)) {
                continue;
            }
            // 过滤排除的字段
            if (excludes != null && excludes.contains(fieldName)) {
                continue;
            }
            // 过滤逻辑删除字段
            if (field.getAnnotation(TableLogic.class) != null) {
                continue;
            }
            // 过滤租户id字段
            if (fieldName.equals("hostId")) {
                continue;
            }
            // 获取注解指定的查询字段及查询方式
            QueryType queryType = QueryType.LIKE;
            QueryField queryField = field.getAnnotation(QueryField.class);
            if (queryField != null) {
                if (!Cools.isEmpty(queryField.value())) {
                    fieldName = queryField.value();
                }
                if (queryField.type() != null) {
                    queryType = queryField.type();
                }
            } else {
                // 过滤非本表的字段
                TableField tableField = field.getAnnotation(TableField.class);
                if (tableField != null && !tableField.exist()) {
                    continue;
                }
            }
            // 字段名驼峰转下划线
            if (this.isToUnderlineCase) {
                fieldName = Utils.toSymbolCase(fieldName, '_');
            }
            switch (queryType) {
                case EQ:
                    queryWrapper.eq(fieldName, fieldValue);
                    break;
                case NE:
                    queryWrapper.ne(fieldName, fieldValue);
                    break;
                case GT:
                    queryWrapper.gt(fieldName, fieldValue);
                    break;
                case GE:
                    queryWrapper.ge(fieldName, fieldValue);
                    break;
                case LT:
                    queryWrapper.lt(fieldName, fieldValue);
                    break;
                case LE:
                    queryWrapper.le(fieldName, fieldValue);
                    break;
                case LIKE:
                    queryWrapper.like(fieldName, fieldValue);
                    break;
                case NOT_LIKE:
                    queryWrapper.notLike(fieldName, fieldValue);
                    break;
                case LIKE_LEFT:
                    queryWrapper.likeLeft(fieldName, fieldValue);
                    break;
                case LIKE_RIGHT:
                    queryWrapper.likeRight(fieldName, fieldValue);
                    break;
                case IS_NULL:
                    queryWrapper.isNull(fieldName);
                    break;
                case IS_NOT_NULL:
                    queryWrapper.isNotNull(fieldName);
                    break;
                case IN:
                    queryWrapper.in(fieldName, fieldValue);
                    break;
                case NOT_IN:
                    queryWrapper.notIn(fieldName, fieldValue);
                    break;
                case IN_STR:
                    if (fieldValue instanceof String) {
                        queryWrapper.in(fieldName, Arrays.asList(((String) fieldValue).split(",")));
                    }
                    break;
                case NOT_IN_STR:
                    if (fieldValue instanceof String) {
                        queryWrapper.notIn(fieldName, Arrays.asList(((String) fieldValue).split(",")));
                    }
                    break;
            }
        }
        return queryWrapper;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java
@@ -25,6 +25,7 @@
    @OperationLog
    @PostMapping("/role/page")
    public R updateInfo(@RequestBody PageParam param) {
        System.out.println(param.get("condition"));
        List<Role> list = roleService.list();
        return R.ok().add(list);
    }
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Dept.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
@@ -116,6 +117,7 @@
     * 是否删除 1: 是  0: 否  
     */
    @ApiModelProperty(value= "是否删除 1: 是  0: 否  ")
    @TableLogic
    private Integer deleted;
    /**
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Host.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zy.asrs.framework.common.Cools;
import io.swagger.annotations.ApiModelProperty;
@@ -41,6 +42,7 @@
     * 是否删除 1: 是  0: 否  
     */
    @ApiModelProperty(value= "是否删除 1: 是  0: 否  ")
    @TableLogic
    private Integer deleted;
    /**
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Menu.java
@@ -1,9 +1,6 @@
package com.zy.asrs.wcs.sys.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.wcs.sys.service.HostService;
@@ -134,6 +131,7 @@
     * 是否删除 1: 是  0: 否  
     */
    @ApiModelProperty(value= "是否删除 1: 是  0: 否  ")
    @TableLogic
    private Integer deleted;
    /**
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/Role.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
@@ -55,6 +56,7 @@
     * 是否删除 1: 是  0: 否  
     */
    @ApiModelProperty(value= "是否删除 1: 是  0: 否  ")
    @TableLogic
    private Integer deleted;
    /**
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/entity/User.java
@@ -1,9 +1,6 @@
package com.zy.asrs.wcs.sys.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.wcs.sys.service.DeptService;
@@ -132,6 +129,7 @@
     * 是否删除 1: 是  0: 否  
     */
    @ApiModelProperty(value= "是否删除 1: 是  0: 否  ")
    @TableLogic
    private Integer deleted;
    /**