mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 简化查询代码生成列表功能
This commit is contained in:
		@@ -1,6 +1,8 @@
 | 
				
			|||||||
package com.ruoyi.generator.mapper;
 | 
					package com.ruoyi.generator.mapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 | 
					import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.conditions.Wrapper;
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.toolkit.Constants;
 | 
				
			||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
					import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
				
			||||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
 | 
					import com.ruoyi.common.core.mapper.BaseMapperPlus;
 | 
				
			||||||
import com.ruoyi.generator.domain.GenTable;
 | 
					import com.ruoyi.generator.domain.GenTable;
 | 
				
			||||||
@@ -16,26 +18,15 @@ import java.util.List;
 | 
				
			|||||||
@InterceptorIgnore(dataPermission = "true")
 | 
					@InterceptorIgnore(dataPermission = "true")
 | 
				
			||||||
public interface GenTableMapper extends BaseMapperPlus<GenTableMapper, GenTable, GenTable> {
 | 
					public interface GenTableMapper extends BaseMapperPlus<GenTableMapper, GenTable, GenTable> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Page<GenTable> selectPageDbTableList(@Param("page") Page<GenTable> page, @Param(Constants.WRAPPER) Wrapper<Object> queryWrapper);
 | 
				
			||||||
    Page<GenTable> selectPageGenTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Page<GenTable> selectPageDbTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 查询业务列表
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param genTable 业务信息
 | 
					 | 
				
			||||||
     * @return 业务集合
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    List<GenTable> selectGenTableList(GenTable genTable);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询据库列表
 | 
					     * 查询据库列表
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param genTable 业务信息
 | 
					     * @param queryWrapper 查询条件
 | 
				
			||||||
     * @return 数据库表集合
 | 
					     * @return 数据库表集合
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    List<GenTable> selectDbTableList(GenTable genTable);
 | 
					    List<GenTable> selectDbTableList(@Param(Constants.WRAPPER) Wrapper<Object> queryWrapper);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询据库列表
 | 
					     * 查询据库列表
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,10 @@ import cn.hutool.core.collection.CollUtil;
 | 
				
			|||||||
import cn.hutool.core.io.IoUtil;
 | 
					import cn.hutool.core.io.IoUtil;
 | 
				
			||||||
import cn.hutool.core.lang.Dict;
 | 
					import cn.hutool.core.lang.Dict;
 | 
				
			||||||
import cn.hutool.core.util.ObjectUtil;
 | 
					import cn.hutool.core.util.ObjectUtil;
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.conditions.Wrapper;
 | 
				
			||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
					import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
				
			||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
					import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
				
			||||||
import com.ruoyi.common.constant.Constants;
 | 
					import com.ruoyi.common.constant.Constants;
 | 
				
			||||||
import com.ruoyi.common.constant.GenConstants;
 | 
					import com.ruoyi.common.constant.GenConstants;
 | 
				
			||||||
@@ -69,13 +72,7 @@ public class GenTableServiceImpl implements IGenTableService {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) {
 | 
					    public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) {
 | 
				
			||||||
        Page<GenTable> page = baseMapper.selectPageGenTableList(pageQuery.build(), genTable);
 | 
					        Page<GenTable> page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable));
 | 
				
			||||||
        return TableDataInfo.build(page);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) {
 | 
					 | 
				
			||||||
        Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable);
 | 
					 | 
				
			||||||
        return TableDataInfo.build(page);
 | 
					        return TableDataInfo.build(page);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,7 +84,24 @@ public class GenTableServiceImpl implements IGenTableService {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<GenTable> selectGenTableList(GenTable genTable) {
 | 
					    public List<GenTable> selectGenTableList(GenTable genTable) {
 | 
				
			||||||
        return baseMapper.selectGenTableList(genTable);
 | 
					        return baseMapper.selectList(this.buildGenTableQueryWrapper(genTable));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private QueryWrapper<GenTable> buildGenTableQueryWrapper(GenTable genTable) {
 | 
				
			||||||
 | 
					        Map<String, Object> params = genTable.getParams();
 | 
				
			||||||
 | 
					        QueryWrapper<GenTable> wrapper = Wrappers.query();
 | 
				
			||||||
 | 
					        wrapper.like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName()))
 | 
				
			||||||
 | 
					            .like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment()))
 | 
				
			||||||
 | 
					            .between(params.get("beginTime") != null && params.get("endTime") != null,
 | 
				
			||||||
 | 
					                "create_time", params.get("beginTime"), params.get("endTime"));
 | 
				
			||||||
 | 
					        return wrapper;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) {
 | 
				
			||||||
 | 
					        Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), this.buildDbTableQueryWrapper(genTable));
 | 
				
			||||||
 | 
					        return TableDataInfo.build(page);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -98,7 +112,22 @@ public class GenTableServiceImpl implements IGenTableService {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<GenTable> selectDbTableList(GenTable genTable) {
 | 
					    public List<GenTable> selectDbTableList(GenTable genTable) {
 | 
				
			||||||
        return baseMapper.selectDbTableList(genTable);
 | 
					        return baseMapper.selectDbTableList(this.buildDbTableQueryWrapper(genTable));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Wrapper<Object> buildDbTableQueryWrapper(GenTable genTable) {
 | 
				
			||||||
 | 
					        Map<String, Object> params = genTable.getParams();
 | 
				
			||||||
 | 
					        QueryWrapper<Object> wrapper = Wrappers.query();
 | 
				
			||||||
 | 
					        wrapper.apply("table_schema = (select database())")
 | 
				
			||||||
 | 
					            .notLike("table_name", "xxl_job_%")
 | 
				
			||||||
 | 
					            .notLike("table_name", "gen_%")
 | 
				
			||||||
 | 
					            .notInSql("table_name", "select table_name from gen_table")
 | 
				
			||||||
 | 
					            .like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName()))
 | 
				
			||||||
 | 
					            .like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment()))
 | 
				
			||||||
 | 
					            .between(params.get("beginTime") != null && params.get("endTime") != null,
 | 
				
			||||||
 | 
					                "create_time", params.get("beginTime"), params.get("endTime"))
 | 
				
			||||||
 | 
					            .orderByDesc("create_time");
 | 
				
			||||||
 | 
					        return wrapper;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,73 +53,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			|||||||
        <result property="updateTime"     column="update_time"    />
 | 
					        <result property="updateTime"     column="update_time"    />
 | 
				
			||||||
    </resultMap>
 | 
					    </resultMap>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <sql id="selectGenTableVo">
 | 
					 | 
				
			||||||
        select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
 | 
					 | 
				
			||||||
    </sql>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <select id="selectPageGenTableList" parameterType="GenTable" resultMap="GenTableResult">
 | 
					 | 
				
			||||||
        <include refid="selectGenTableVo"/>
 | 
					 | 
				
			||||||
        <where>
 | 
					 | 
				
			||||||
            <if test="genTable.tableName != null and genTable.tableName != ''">
 | 
					 | 
				
			||||||
                AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
 | 
					 | 
				
			||||||
            </if>
 | 
					 | 
				
			||||||
            <if test="genTable.tableComment != null and genTable.tableComment != ''">
 | 
					 | 
				
			||||||
                AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
 | 
					 | 
				
			||||||
            </if>
 | 
					 | 
				
			||||||
            <if test="genTable.params.beginTime != null and genTable.params.endTime != null">
 | 
					 | 
				
			||||||
                AND create_time between #{genTable.params.beginTime} and #{genTable.params.endTime}
 | 
					 | 
				
			||||||
            </if>
 | 
					 | 
				
			||||||
        </where>
 | 
					 | 
				
			||||||
    </select>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <select id="selectPageDbTableList" parameterType="GenTable" resultMap="GenTableResult">
 | 
					    <select id="selectPageDbTableList" parameterType="GenTable" resultMap="GenTableResult">
 | 
				
			||||||
        select table_name, table_comment, create_time, update_time from information_schema.tables
 | 
					        select table_name, table_comment, create_time, update_time
 | 
				
			||||||
        where table_schema = (select database())
 | 
					        from information_schema.tables
 | 
				
			||||||
        AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
 | 
					        ${ew.getCustomSqlSegment}
 | 
				
			||||||
        AND table_name NOT IN (select table_name from gen_table)
 | 
					 | 
				
			||||||
        <if test="genTable.tableName != null and genTable.tableName != ''">
 | 
					 | 
				
			||||||
            AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
 | 
					 | 
				
			||||||
        </if>
 | 
					 | 
				
			||||||
        <if test="genTable.tableComment != null and genTable.tableComment != ''">
 | 
					 | 
				
			||||||
            AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
 | 
					 | 
				
			||||||
        </if>
 | 
					 | 
				
			||||||
        <if test="genTable.params.beginTime != null and genTable.params.endTime != null">
 | 
					 | 
				
			||||||
            AND create_time between #{genTable.params.beginTime} and #{genTable.params.endTime}
 | 
					 | 
				
			||||||
        </if>
 | 
					 | 
				
			||||||
        order by create_time desc
 | 
					 | 
				
			||||||
    </select>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
 | 
					 | 
				
			||||||
        <include refid="selectGenTableVo"/>
 | 
					 | 
				
			||||||
        <where>
 | 
					 | 
				
			||||||
            <if test="tableName != null and tableName != ''">
 | 
					 | 
				
			||||||
                AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
 | 
					 | 
				
			||||||
            </if>
 | 
					 | 
				
			||||||
            <if test="tableComment != null and tableComment != ''">
 | 
					 | 
				
			||||||
                AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
 | 
					 | 
				
			||||||
            </if>
 | 
					 | 
				
			||||||
            <if test="params.beginTime != null and params.endTime != null">
 | 
					 | 
				
			||||||
                AND create_time between #{params.beginTime} and #{params.endTime}
 | 
					 | 
				
			||||||
            </if>
 | 
					 | 
				
			||||||
        </where>
 | 
					 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
 | 
					    <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
 | 
				
			||||||
        select table_name, table_comment, create_time, update_time from information_schema.tables
 | 
					        select table_name, table_comment, create_time, update_time
 | 
				
			||||||
        where table_schema = (select database())
 | 
					        from information_schema.tables
 | 
				
			||||||
        AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
 | 
					        ${ew.getCustomSqlSegment}
 | 
				
			||||||
        AND table_name NOT IN (select table_name from gen_table)
 | 
					 | 
				
			||||||
        <if test="tableName != null and tableName != ''">
 | 
					 | 
				
			||||||
            AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
 | 
					 | 
				
			||||||
        </if>
 | 
					 | 
				
			||||||
        <if test="tableComment != null and tableComment != ''">
 | 
					 | 
				
			||||||
            AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
 | 
					 | 
				
			||||||
        </if>
 | 
					 | 
				
			||||||
        <if test="params.beginTime != null and params.endTime != null">
 | 
					 | 
				
			||||||
            AND create_time between #{params.beginTime} and #{params.endTime}
 | 
					 | 
				
			||||||
        </if>
 | 
					 | 
				
			||||||
        order by create_time desc
 | 
					 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <select id="selectDbTableListByNames" resultMap="GenTableResult">
 | 
					    <select id="selectDbTableListByNames" resultMap="GenTableResult">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user