修改1:分页返回体TableDataInfo改成泛型类TableDataInfo<T>,方便集成3方API接口文档展示字段信息

修改点2:BaseController新增一个分页方法getDataTableByFunction,方便控制层少写一个startPage();当然啦,pagehelper分页查询不起作用的情况你知道的话最好啦,以免造成bug
pull/518/head
zhangxiaoxiang 2024-09-01 10:38:58 +08:00
parent d9fbae538b
commit 5d3580cbcf
2 changed files with 23 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package com.ruoyi.common.core.controller;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
import java.util.function.Supplier;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@ -27,7 +28,7 @@ import com.ruoyi.common.utils.sql.SqlUtil;
/**
* web
*
*
* @author ruoyi
*/
public class BaseController
@ -117,9 +118,21 @@ public class BaseController
return rspData;
}
/**
*
*
* @param supplier
* @return
*/
protected TableDataInfo getDataTableByFunction(Supplier<List<?>> supplier)
{
startPage();
return getDataTable(supplier.get());
}
/**
*
*
*
* @param rows
* @return
*/
@ -130,7 +143,7 @@ public class BaseController
/**
*
*
*
* @param result
* @return
*/

View File

@ -5,10 +5,10 @@ import java.util.List;
/**
*
*
*
* @author ruoyi
*/
public class TableDataInfo implements Serializable
public class TableDataInfo<T> implements Serializable
{
private static final long serialVersionUID = 1L;
@ -16,7 +16,7 @@ public class TableDataInfo implements Serializable
private long total;
/** 列表数据 */
private List<?> rows;
private List<T> rows;
/** 消息状态码 */
private int code;
@ -33,11 +33,11 @@ public class TableDataInfo implements Serializable
/**
*
*
*
* @param list
* @param total
*/
public TableDataInfo(List<?> list, int total)
public TableDataInfo(List<T> list, int total)
{
this.rows = list;
this.total = total;
@ -58,7 +58,7 @@ public class TableDataInfo implements Serializable
return rows;
}
public void setRows(List<?> rows)
public void setRows(List<T> rows)
{
this.rows = rows;
}
@ -82,4 +82,4 @@ public class TableDataInfo implements Serializable
{
this.msg = msg;
}
}
}