分页类
package com.guiyang.education.controller.api;
import java.util.List;
public class PageData {
private Integer pageIndex;//当前页
private int pageSize;//每页显示记录条数
private int totalPage;//总页数
private List<?> list;//每页显示的数据
private int star;//开始数据
public Integer getPageIndex() {
return pageIndex;
}
public void setPageIndex(Integer pageIndex) {
this.pageIndex = pageIndex;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
public int getStar() {
return star;
}
public void setStar(int star) {
this.star = star;
}
}
控制器
/**
* 获取未签约的学生列表
*/
public void getSignOutList(){
int pageIndex = getParaToInt("pageIndex", 1);
int pageSize = getParaToInt("pageSize", GuiYangWebConfig.PAGE_SIZE);
int status=0;
try {
List<PePhysicalData> schoolList = PePhysicalData.dao.getSignOutStudentList(getPara("activity_id"),getCurrentMember().getID(),getPara("schoolCode"),getPara("checkTime"));
List<Record> recordList=new ArrayList<>();
if (schoolList != null && schoolList.size() > 0) {
for (PePhysicalData data : schoolList) {
int nosign = 1;
String sql = "SELECT a.*,b.nk_img,b.wk_img,b.wgk_img FROM pe_physical_submit a LEFT JOIN pe_contract b \n" +
"ON a.`school_code`=b.`school_code` AND a.`activity_id`=b.`activity_id` AND a.`student_code`=b.`student_code` AND a.`doctor_id`=b.`doctor_id` and a.student_code=b.student_code " +
"where a.activity_id=? and a.doctor_id=? and a.school_code=? and a.student_code=? and DATE_FORMAT(a.create_time,'%Y-%m-%d')=?";
Record stu = Db.findFirst(sql, getPara("activity_id"), getCurrentMember().getID(), data.getStr("schoolCode"), data.getStr("rollCode"),getPara("checkTime"));
if (stu != null) {
if (stu.getStr("subject_type").contains("1") && StrKit.isBlank(stu.getStr("nk_img"))) {
nosign = 0;
}
if (stu.getStr("subject_type").contains("2") && StrKit.isBlank(stu.getStr("wk_img"))) {
nosign = 0;
}
if (stu.getStr("subject_type").contains("3") && StrKit.isBlank(stu.getStr("wgk_img"))) {
nosign = 0;
}
}
if (nosign == 0) {
Record record = new Record();
record.set("id", data.getLong("id"));
record.set("sort", data.getLong("sort"));
record.set("studentName", data.getStr("studentName"));
record.set("sex", data.getInt("sex"));
record.set("rollCode", data.getStr("rollCode"));
record.set("subject_type", data.getStr("subject_type"));
recordList.add(record);
}
}
}
PageData page=new PageData();
page.setPageIndex(pageIndex);
//设置每页数据为十条
page.setPageSize(pageSize);
//每页的开始数
page.setStar((pageIndex - 1) * pageSize);
//list的大小
int count = recordList.size();
//设置总页数
page.setTotalPage(count%page.getPageSize() == 0 ? count/page.getPageSize() : count/page.getPageSize() + 1);
//对list进行截取
page.setList(recordList.subList(page.getStar(), count-page.getStar()>page.getPageSize() ? page.getStar()+page.getPageSize() : count));
//返回json数据给移动端
setAttr("schoolList", page);
}catch (Exception e){
e.printStackTrace();
status=1;
}
setAttr("status",status);
setAttr("result",getResult(status));
returnJson();
}