mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 使用 MP 分页工具 重构业务
This commit is contained in:
@ -1,32 +1,26 @@
|
||||
package com.ruoyi.generator.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
import com.ruoyi.generator.service.IGenTableColumnService;
|
||||
import com.ruoyi.generator.service.IGenTableService;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 代码生成 操作处理
|
||||
@ -50,9 +44,7 @@ public class GenController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo genList(GenTable genTable)
|
||||
{
|
||||
startPage();
|
||||
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
||||
return getDataTable(list);
|
||||
return genTableService.selectPageGenTableList(genTable);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,9 +71,7 @@ public class GenController extends BaseController
|
||||
@GetMapping("/db/list")
|
||||
public TableDataInfo dataList(GenTable genTable)
|
||||
{
|
||||
startPage();
|
||||
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
||||
return getDataTable(list);
|
||||
return genTableService.selectPageDbTableList(genTable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.generator.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
|
||||
import java.util.List;
|
||||
@ -11,6 +12,12 @@ import java.util.List;
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface GenTableMapper extends BaseMapper<GenTable> {
|
||||
|
||||
|
||||
Page<GenTable> selectPageGenTableList(Page<GenTable> page, GenTable genTable);
|
||||
|
||||
Page<GenTable> selectPageDbTableList(Page<GenTable> page, GenTable genTable);
|
||||
|
||||
/**
|
||||
* 查询业务列表
|
||||
*
|
||||
|
@ -10,7 +10,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.GenConstants;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
@ -66,6 +68,16 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
return genTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable) {
|
||||
return PageUtils.buildDataInfo(baseMapper.selectPageGenTableList(PageUtils.buildPage(), genTable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable) {
|
||||
return PageUtils.buildDataInfo(baseMapper.selectPageDbTableList(PageUtils.buildPage(), genTable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询业务列表
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.ruoyi.generator.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.page.IServicePlus;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,7 +10,7 @@ import java.util.List;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface IGenTableColumnService extends IService<GenTableColumn> {
|
||||
public interface IGenTableColumnService extends IServicePlus<GenTableColumn> {
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.generator.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.page.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
|
||||
import java.util.List;
|
||||
@ -11,7 +12,14 @@ import java.util.Map;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface IGenTableService extends IService<GenTable> {
|
||||
public interface IGenTableService extends IServicePlus<GenTable> {
|
||||
|
||||
|
||||
TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable);
|
||||
|
||||
|
||||
TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable);
|
||||
|
||||
/**
|
||||
* 查询业务列表
|
||||
*
|
||||
|
@ -56,8 +56,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
|
||||
<select id="selectPageGenTableList" 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.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPageDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
|
||||
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.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
<include refid="selectGenTableVo"/>
|
||||
<where>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
|
Reference in New Issue
Block a user