Commit 587f2eeb by huangZW

溢出门店做不了分页查询,顶多手动做个分页

parent 8320d564
......@@ -21,6 +21,7 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.DepartmentAddQO;
import com.gic.haoban.manage.web.qo.DepartmentEditQO;
import com.gic.haoban.manage.web.utils.ListUtils;
import com.gic.haoban.manage.web.vo.LoginVO;
@RestController
......@@ -316,6 +317,34 @@ public class DepartmentContoller extends WebBaseController{
}
}
//溢出门店列表
@RequestMapping("store-full-list")
public HaobanResponse storeFullList(BasePageInfo basePageInfo) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
int pageNum = basePageInfo.getPageNum();
int pageSize = basePageInfo.getPageSize();
Page<DepartmentDTO> page = new Page<>(pageNum, pageSize, 0);
//TODO 获取版本容量
int maxSize = 0;
List<DepartmentDTO> list = departmentApiService.listStoreByWxEnterpriseId(wxEnterpriseId);
if(list == null||list.size()==0){
return resultResponse(HaoBanErrCode.ERR_1,new Page<>());
}
page.setTotalCount(list.size());
if(maxSize != 0){
if(list.size() <= maxSize){
//小于版本容量(无溢出门店)
return resultResponse(HaoBanErrCode.ERR_1,new Page<>());
}else{
//大于版本容量(有溢出门店)
list = list.subList(maxSize,list.size()-1);
}
}
List resultList = ListUtils.Pager(pageSize, pageNum, list);
return resultResponse(HaoBanErrCode.ERR_1,resultList);
}
}
package com.gic.haoban.manage.web.utils;
import java.util.ArrayList;
import java.util.List;
/**
* list集合工具类
*/
public class ListUtils {
/**
*
* @param pageSize 当前页面大小
* @param pageIndex 当前页码
* @param list 需要分页的集合
* @return
*/
public static List Pager(int pageSize,int pageIndex,List list){
//使用list 中的sublist方法分页
List resultList = new ArrayList<>();
// 每页显示多少条记录
int currentPage; //当前第几页数据
int totalRecord = list.size(); // 一共多少条记录
int totalPage = totalRecord % pageSize; // 一共多少页
if (totalPage > 0) {
totalPage = totalRecord / pageSize + 1;
} else {
totalPage = totalRecord / pageSize;
}
System.out.println("总页数:" + totalPage);
// 当前第几页数据
currentPage = totalPage < pageIndex ? totalPage : pageIndex;
// 起始索引
int fromIndex = pageSize * (currentPage - 1);
// 结束索引
int toIndex = pageSize * currentPage > totalRecord ? totalRecord : pageSize * currentPage;
try{
resultList = list.subList(fromIndex, toIndex);
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
return resultList;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment