package springboot_001.entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Page {
private int pageSize = 50;
private int pageIndex = 1;
private int totalPage;
private int totalNumber;
private List<Map<String, Object>> list;
private Object data;
public int getStart() {
int start = (pageIndex - 1) * pageSize;
if (start < 0) {
start = 0;
}
return start;
}
public int getEnd() {
int end = this.getStart() + pageSize;
if (end > totalNumber) {
end = totalNumber;
}
return end;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
if (this.pageIndex < 0) {
this.pageIndex = 1;
}
if (this.pageIndex > totalPage) {
this.pageIndex = totalPage;
}
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getTotalNumber() {
return totalNumber;
}
public void setTotalNumber(int totalNumber) {
this.totalPage = totalNumber % this.pageSize == 0 ?
totalNumber / this.pageSize : totalNumber / this.pageSize + 1;
this.totalNumber = totalNumber;
}
public List<Map<String, Object>> getList() {
if (list == null) {
list = new ArrayList<>();
}
return list;
}
public void setList(List<Map<String, Object>> list) {
this.list = list;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
*/
@Override
public Result<Object> listApplyListByme(Map<String, Object> params, HttpServletRequest request) {
Map<String, Object> resMap = new HashMap<>();
Page page = new Page();
try {
// 计算当前页面
User user = (User) request.getSession().getAttribute("userInfo");
int pageNumer = Integer.parseInt((String) params.get("pageNumber"));
int pageSize = Integer.parseInt((String) params.get("pageSize"));
params.put("founder", user.getUserAgentId());
int total = flowMapper.getCountPage(params);
page.setPageSize(pageSize);
page.setTotalNumber(total);
page.setPageIndex(pageNumer);
// 总记录数
int startRow = page.getStart();
int endRow = page.getEnd();
params.put("startRow", startRow);
params.put("endStartRow", endRow);
List<Map<String, Object>> appList = flowMapper.listApplyListByme(params);
page.setList(appList);
} catch (Exception ex) {
ex.printStackTrace();
return Result.buildResult(Result.Status.BAD_REQUEST);
}
return Result.buildResult(Result.Status.OK, page);
}
select * from (
select ft.*, rownum as ron
from (select ot.*
from (select count(*) as honor_count, t.user_agentid, t.user_name
from t_ows_honor_cup t
where 1 = 1
group by t.user_agentid, t.user_name) ot
order by ot.honor_count desc) ft
) tt
where tt.ron > 0
and tt.ron <= 10
注意 oracle一定在分组之后分页