redis key常量
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
package com.xzzn.common.constant;
|
||||
|
||||
/**
|
||||
* 数据存储 Redis key 常量
|
||||
*
|
||||
* @author xzzn
|
||||
*/
|
||||
public class RedisKeyConstants
|
||||
{
|
||||
/**
|
||||
* pcs数据 redis key
|
||||
*/
|
||||
public static final String PCS = "PCS_";
|
||||
|
||||
/**
|
||||
* pcs branch数据 redis key
|
||||
*/
|
||||
public static final String BRANCH = "BRANCH_";
|
||||
|
||||
/**
|
||||
* stack电池堆数据 redis key
|
||||
*/
|
||||
public static final String STACK = "STACK_";
|
||||
|
||||
/**
|
||||
* cluster电池簇数据 redis key
|
||||
*/
|
||||
public static final String CLUSTER = "CLUSTER_";
|
||||
|
||||
/**
|
||||
* battery单体电池数据 redis key
|
||||
*/
|
||||
public static final String BATTERY = "BATTERY_";
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.xzzn.common.core.controller;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
@ -199,4 +201,35 @@ public class BaseController
|
||||
{
|
||||
return getLoginUser().getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动处理分页
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected TableDataInfo getDataTable2(List<?> list)
|
||||
{
|
||||
List<?> subList = new ArrayList<>();
|
||||
// 分页梳理
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
int pageNum = pageDomain.getPageNum();
|
||||
int pageSize = pageDomain.getPageSize();
|
||||
if (pageNum > 0 && pageSize > 0) {
|
||||
// 计算分页起始和结束索引
|
||||
int startIndex = (pageNum - 1) * pageSize;
|
||||
int endIndex = Math.min(startIndex + pageSize, list.size());
|
||||
// 防止越界
|
||||
if (startIndex >= list.size()) {
|
||||
subList = Collections.emptyList();
|
||||
}
|
||||
// 截取当前页数据
|
||||
subList = list.subList(startIndex, endIndex);
|
||||
}
|
||||
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(subList);
|
||||
rspData.setTotal(list.size());
|
||||
return rspData;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user