mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-04-09 20:13:16 +08:00
!837 [mod]分页查询接口使用R类型返回:数据放入data中
* [mod]将PageResult从common-mybatis挪到common-core中 * [mod]TableDataInfo修改为PageResult * [mod]分页查询接口使用R类型返回:数据放入data中
This commit is contained in:
@@ -11,7 +11,7 @@ import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.generator.domain.GenTable;
|
||||
@@ -47,8 +47,8 @@ public class GenController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("tool:gen:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) {
|
||||
return genTableService.selectPageGenTableList(genTable, pageQuery);
|
||||
public R<PageResult<GenTable>> genList(GenTable genTable, PageQuery pageQuery) {
|
||||
return R.ok(genTableService.selectPageGenTableList(genTable, pageQuery));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,8 +80,8 @@ public class GenController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("tool:gen:list")
|
||||
@GetMapping("/db/list")
|
||||
public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) {
|
||||
return genTableService.selectPageDbTableList(genTable, pageQuery);
|
||||
public R<PageResult<GenTable>> dataList(GenTable genTable, PageQuery pageQuery) {
|
||||
return R.ok(genTableService.selectPageDbTableList(genTable, pageQuery));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,9 +92,9 @@ public class GenController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("tool:gen:list")
|
||||
@GetMapping(value = "/column/{tableId}")
|
||||
public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) {
|
||||
public R<PageResult<GenTableColumn>> columnList(@PathVariable("tableId") Long tableId) {
|
||||
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
||||
return TableDataInfo.build(list);
|
||||
return R.ok(PageResult.build(list));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.mybatis.utils.IdGeneratorUtil;
|
||||
import org.dromara.generator.constant.GenConstants;
|
||||
import org.dromara.generator.domain.GenTable;
|
||||
@@ -97,9 +97,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
* @return 业务表分页结果
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) {
|
||||
public PageResult<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) {
|
||||
Page<GenTable> page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable));
|
||||
return TableDataInfo.build(page);
|
||||
return PageResult.build(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,14 +130,14 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
*/
|
||||
@DS("#genTable.dataName")
|
||||
@Override
|
||||
public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) {
|
||||
public PageResult<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) {
|
||||
// 获取查询条件
|
||||
String tableName = genTable.getTableName();
|
||||
String tableComment = genTable.getTableComment();
|
||||
|
||||
LinkedHashMap<String, Table<?>> tablesMap = ServiceProxy.metadata().tables();
|
||||
if (CollUtil.isEmpty(tablesMap)) {
|
||||
return TableDataInfo.build();
|
||||
return PageResult.build();
|
||||
}
|
||||
List<String> tableNames = baseMapper.selectTableNameList(genTable.getDataName());
|
||||
String[] tableArrays;
|
||||
@@ -179,7 +179,13 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
return gen;
|
||||
}).sorted(Comparator.comparing(GenTable::getCreateTime).reversed())
|
||||
.toList();
|
||||
return TableDataInfo.build(tables, pageQuery.build());
|
||||
// 根据原始数据列表和分页参数,构建表格分页数据对象(用于假分页)
|
||||
if (CollUtil.isEmpty(tables)) {
|
||||
return PageResult.build();
|
||||
}
|
||||
Page<Object> page = pageQuery.build();
|
||||
List<GenTable> pageList = CollUtil.page((int) page.getCurrent() - 1, (int) page.getSize(), tables);
|
||||
return PageResult.build(pageList, tables.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.dromara.generator.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.generator.domain.GenTable;
|
||||
import org.dromara.generator.domain.GenTableColumn;
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface IGenTableService {
|
||||
* @param pageQuery 分页参数
|
||||
* @return 业务分页集合
|
||||
*/
|
||||
TableDataInfo<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery);
|
||||
PageResult<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
@@ -39,7 +39,7 @@ public interface IGenTableService {
|
||||
* @param pageQuery 分页参数
|
||||
* @return 数据库表分页集合
|
||||
*/
|
||||
TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery);
|
||||
PageResult<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
|
||||
@@ -21,7 +21,7 @@ import ${packageName}.domain.vo.${ClassName}Vo;
|
||||
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
#if($table.crud)
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
#elseif($table.tree)
|
||||
#end
|
||||
|
||||
@@ -45,8 +45,8 @@ public class ${ClassName}Controller extends BaseController {
|
||||
@SaCheckPermission("${permissionPrefix}:list")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud)
|
||||
public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo bo, PageQuery pageQuery) {
|
||||
return ${className}Service.queryPageList(bo, pageQuery);
|
||||
public R<PageResult<${ClassName}Vo>> list(${ClassName}Bo bo, PageQuery pageQuery) {
|
||||
return R.ok(${className}Service.queryPageList(bo, pageQuery));
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public R<List<${ClassName}Vo>> list(${ClassName}Bo bo) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package ${packageName}.service;
|
||||
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||
#if($table.crud)
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
#end
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface I${ClassName}Service {
|
||||
* @param pageQuery 分页参数
|
||||
* @return ${functionName}分页列表
|
||||
*/
|
||||
TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery);
|
||||
PageResult<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery);
|
||||
#end
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@ package ${packageName}.service.impl;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
#if($table.crud)
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
#end
|
||||
@@ -55,10 +55,10 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
* @return ${functionName}分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) {
|
||||
public PageResult<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
|
||||
Page<${ClassName}Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
return PageResult.build(result.getRecords(), result.getTotal());
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from '@/api/${moduleName}/${businessName}/types';
|
||||
import { PageResult } from '@/api/types';
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
@@ -8,7 +9,7 @@ import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from '@/
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const list${BusinessName} = (query?: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> => {
|
||||
export const list${BusinessName} = (query?: ${BusinessName}Query): AxiosPromise<PageResult<${BusinessName}VO>> => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
|
||||
@@ -351,8 +351,8 @@ const getList = async () => {
|
||||
#end
|
||||
#end
|
||||
const res = await list${BusinessName}(queryParams.value);
|
||||
${businessName}List.value = res.rows;
|
||||
total.value = res.total;
|
||||
${businessName}List.value = res.data?.rows;
|
||||
total.value = res.data?.total;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user