Java Code Examples for com.github.pagehelper.PageInfo#getTotal()

The following examples show how to use com.github.pagehelper.PageInfo#getTotal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectRestApi.java    From submarine with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/list")
@SubmarineApi
public Response list(@QueryParam("userName") String userName,
                     @QueryParam("column") String column,
                     @QueryParam("order") String order,
                     @QueryParam("pageNo") int pageNo,
                     @QueryParam("pageSize") int pageSize) {
  LOG.info("ProjectRestApi.list() owner:{}, pageNo:{}, pageSize:{}", userName, pageNo, pageSize);

  List<Project> projectList = new ArrayList<>();
  try {
    projectList = projectService.queryPageList(userName, column, order, pageNo, pageSize);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
    return new JsonResponse.Builder<>(Response.Status.OK).success(false).build();
  }
  PageInfo<Project> page = new PageInfo<>(projectList);
  ListResult<Project> listResult = new ListResult(projectList, page.getTotal());
  return new JsonResponse.Builder<ListResult<Project>>(Response.Status.OK)
      .success(true).result(listResult).build();
}
 
Example 2
Source File: IndexServiceImpl.java    From yyblog with MIT License 6 votes vote down vote up
@Override
public IndexArticleVO next(IndexQuery query) {
    
    PageHelper.startPage(query.getPage(), query.getLimit()); 
    List<ArticleVO> list = articleMapper.listIndexArticle(query);
    //取记录总条数
    PageInfo<ArticleVO> pageInfo = new PageInfo<ArticleVO>(list);
    long total = pageInfo.getTotal();
    Map<Long,Object> map = new HashMap<Long,Object>();
    for (ArticleVO articleVo : list) {
        List<TagDO> listTag = tagMapper.listTagByReferId(articleVo.getId());
        map.put(articleVo.getId(), listTag);
    }
    IndexArticleVO vo = new IndexArticleVO();
    vo.setData(list);
    vo.setTags(map);
    long totalPage = total % query.getLimit() == 0 ? total / query.getLimit():total / query.getLimit() + 1;
    vo.setTotalPage(totalPage);
    vo.setTotalCount(total);
    vo.setCode(200);
    return vo;
}
 
Example 3
Source File: ProductController.java    From product-recommendation-system with MIT License 6 votes vote down vote up
/**
 * 处理查询商品的请求
 * @param product 封装了要查询的商品需要满足的条件
 * @param pageNum 第几页
 * @param pageSize 每页多少条
 * @return 封装有商品列表以及分页信息的map集合
 */
@RequestMapping(value="/listProduct/{pageNum}/{pageSize}")
public @ResponseBody Map<String, Object> listProduct(@RequestBody Product product,
	@PathVariable(value="pageNum") Integer pageNum, @PathVariable(value="pageSize") Integer pageSize) {
	Map<String, Object> map = new HashMap<String, Object>();
	
	PageParam pageParam = new PageParam(pageNum, pageSize);
	if (pageNum == null || pageSize == null) {
		pageParam = null;
	}
	
	PageInfo<ProductDTO> productInfo = this.productService.listProductPage(product, pageParam);
	// 1.获取商品列表
	List<ProductDTO> productList = productInfo.getList();
	// 2.获取分页条
	String pageBar = PageUtils.pageStr(productInfo, PRODUCT_QUERY_METHOD_PAGE);
	// 3.统计公有多少条记录
	Long listSize = productInfo.getTotal();
	
	map.put(FRONT_PRODUCTLIST_ATTR, productList);
	map.put(FRONT_LISTSIZE_ATTR, listSize);
	map.put(FRONT_PAGEBAR_ATTR, pageBar);
	
	return map;
}
 
Example 4
Source File: TeacherController.java    From sms-ssm with MIT License 6 votes vote down vote up
/**
 * @description: 分页查询学生信息列表:根据教师与班级名查询指定/全部教师信息列表
 * @param: page 当前页码
 * @param: rows 列表行数
 * @param: teachername
 * @param: clazzname
 * @date: 2019-06-18 10:17 AM
 * @return: java.util.Map<java.lang.String, java.lang.Object>
 */
@PostMapping("/getTeacherList")
@ResponseBody
public Map<String, Object> getTeacherList(Integer page, Integer rows, String teachername, String clazzname) {

    //存储查询的teachername,clazzname信息
    Teacher teacher = new Teacher(teachername, clazzname);
    //设置每页的记录数
    PageHelper.startPage(page, rows);
    //根据班级与教师名获取指定或全部教师信息列表
    List<Teacher> list = teacherService.selectList(teacher);
    //封装列表信息
    PageInfo<Teacher> pageInfo = new PageInfo<>(list);
    //获取总记录数
    long total = pageInfo.getTotal();
    //获取当前页数据列表
    List<Teacher> teacherList = pageInfo.getList();
    //存储数据对象
    result.put("total", total);
    result.put("rows", teacherList);

    return result;
}
 
Example 5
Source File: ClazzController.java    From sms-ssm with MIT License 6 votes vote down vote up
/**
 * @description: 分页查询班级信息列表:根据班级与年级名查询指定/全部班级信息列表
 * @param: page 当前页码
 * @param: rows 列表行数
 * @param: gradename 年级名称
 * @param: clazzname 班级名称
 * @date: 2019-06-14 10:00 PM
 * @return: java.util.Map<java.lang.String, java.lang.Object>
 */
@PostMapping("/getClazzList")
@ResponseBody
public Map<String, Object> getClazzList(Integer page, Integer rows, String clazzname, String gradename) {

    //存储查询的clazzname,gradename信息
    Clazz clazz = new Clazz(clazzname, gradename);
    //设置每页的记录数
    PageHelper.startPage(page, rows);
    //根据班级与年级名获取指定或全部班级信息列表
    List<Clazz> list = clazzService.selectList(clazz);
    //封装列表信息
    PageInfo<Clazz> pageInfo = new PageInfo<>(list);
    //获取总记录数
    long total = pageInfo.getTotal();
    //获取当前页数据列表
    List<Clazz> clazzList = pageInfo.getList();
    //存储数据对象
    result.put("total", total);
    result.put("rows", clazzList);

    return result;
}
 
Example 6
Source File: SystemRestApi.java    From submarine with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/searchSelect/{tableName}")
@SubmarineApi
public Response searchSelect(@PathParam("tableName") String tableName,
                             @QueryParam("keyword") String keyword) {

  if (StringUtils.equals(tableName, "sys_user")) {
    List<SysUser> list = null;
    try {
      list = userService.queryPageList(keyword, null, null, null, null, 1, 1000);
    } catch (Exception e) {
      LOG.error(e.getMessage(), e);
      return new JsonResponse.Builder<>(Response.Status.OK).success(false).build();
    }
    PageInfo<SysUser> page = new PageInfo<>(list);
    ListResult<SysUser> listResult = new ListResult(list, page.getTotal());

    return new JsonResponse.Builder<ListResult<SysUser>>(Response.Status.OK)
        .success(true).result(listResult).build();
  }

  return new JsonResponse.Builder<ListResult<SysUser>>(Response.Status.OK)
      .success(false).build();
}
 
Example 7
Source File: AdminController.java    From Tbed with GNU Affero General Public License v3.0 5 votes vote down vote up
@RequestMapping(value = "/selecttable")
@ResponseBody
public PageResultBean<Images> selectByFy(HttpSession session, Integer pageNum, Integer pageSize, Integer selecttype,
                                         Integer storageType,String starttime,String stoptime) {
    User u = (User) session.getAttribute("user");
    Images img = new Images();
    if(storageType!=null){
        if(storageType!=0){
            img.setSource(storageType);
        }
    }
    if(starttime!=null && stoptime!=null){
        if(!starttime.equals("") && !stoptime.equals("")){
            img.setStarttime(starttime);
            img.setStoptime(stoptime);
        }
    }
    PageHelper.startPage(pageNum, pageSize);
    List<Images> images = null;
    if (u.getLevel() > 1) {
        if (selecttype == 1) {
            images = imgService.selectimg(img);
        } else if(selecttype == 2) {
            img.setUserid(u.getId());
            images = imgService.selectimg(img);
        }else{
            img.setUserid(u.getId());
            img.setSelecttype(3);
            images = imgService.selectimg(img);
        }
    } else {
        img.setUserid(u.getId());
        images = imgService.selectimg(img);
    }
    PageInfo<Images> rolePageInfo = new PageInfo<>(images);
    return new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
}
 
Example 8
Source File: MemberController.java    From product-recommendation-system with MIT License 5 votes vote down vote up
/**
 * 查询商城会员列表
 * @return
 */
@RequestMapping(value="/listMember")
public @ResponseBody Map<String, Object> listMember(String memberName, Integer pageNo,
	Integer pageSize) {
	
	Member member = new Member();
	// 去除名称中的空格
	member.setMemberName(memberName.replace(" ", ""));
	
	// 创建分页对象
	PageParam pageParam = new PageParam(pageNo, pageSize);
	
	PageInfo<Member> pageInfo = this.memberService.listMember(member, pageParam);
	
	Map<String, Object> resultMap = new HashMap<String, Object>();
	
	// 1.获取商城会员列表
	List<Member> memberList = pageInfo.getList();
	// 2.获取分页条
	String pageBar = PageUtils.pageStr(pageInfo, MEMBER_QUERY_METHOD_PAGE);
	// 3.获取总的记录数
	Long memberNums = pageInfo.getTotal();
	
	resultMap.put("memberList", memberList);
	resultMap.put("pageBar", pageBar);
	resultMap.put("memberNums", memberNums);
	
	return resultMap;
}
 
Example 9
Source File: RoleController.java    From Shiro-Action with MIT License 5 votes vote down vote up
@OperationLog("查询角色列表")
@GetMapping("/list")
@ResponseBody
public PageResultBean<Role> getList(@RequestParam(value = "page", defaultValue = "1") int page,
                                    @RequestParam(value = "limit", defaultValue = "10")int limit,
                                    Role roleQuery) {
    List<Role> roles = roleService.selectAll(page, limit, roleQuery);
    PageInfo<Role> rolePageInfo = new PageInfo<>(roles);
    return new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
}
 
Example 10
Source File: NoteServiceImpl.java    From yyblog with MIT License 5 votes vote down vote up
@Override
public DataGridResult listPageNote(NoteQuery query) {
    PageHelper.startPage(query.getPage(), query.getLimit()); 
    List<NoteDO> list = noteMapper.listNoteByTitle(query.getTitle());
    //取记录总条数
    PageInfo<NoteDO> pageInfo = new PageInfo<NoteDO>(list);
    long total = pageInfo.getTotal();
    //创建一个返回值对象
    DataGridResult result = new DataGridResult(); 
    result.setData(list);
    result.setCount(total);
    return result;
}
 
Example 11
Source File: UserServiceImpl.java    From yyblog with MIT License 5 votes vote down vote up
@Override
public DataGridResult listPageUser(UserQuery query) {
    PageHelper.startPage(query.getPage(), query.getLimit()); 
    List<UserDO> list = userMapper.listUserByNickname(query.getNickname());
    //取记录总条数
    PageInfo<UserDO> pageInfo = new PageInfo<UserDO>(list);
    long total = pageInfo.getTotal();
    //创建一个返回值对象
    DataGridResult result = new DataGridResult(); 
    result.setData(list);
    result.setCount(total);
    return result;
}
 
Example 12
Source File: LoginLogController.java    From Shiro-Action with MIT License 5 votes vote down vote up
@OperationLog("查看登录日志")
@GetMapping("/list")
@ResponseBody
public PageResultBean<LoginLog> getList(@RequestParam(value = "page", defaultValue = "1") int page,
                                    @RequestParam(value = "limit", defaultValue = "10")int limit) {
    List<LoginLog> loginLogs = loginLogService.selectAll(page, limit);
    PageInfo<LoginLog> rolePageInfo = new PageInfo<>(loginLogs);
    return new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
}
 
Example 13
Source File: ResultData.java    From java-tutorial with MIT License 5 votes vote down vote up
public ResultData(PageInfo info) {
    this.totalNum = (int) info.getTotal();
    this.pageNum = info.getPageNum();
    this.totalPage = info.getPages();
    this.items = info.getList();
    this.isMore = info.getPageNum() < info.getPages();
}
 
Example 14
Source File: BaseServiceImpl.java    From scaffold-cloud with MIT License 5 votes vote down vote up
@Override
public ResponsePageModel<T> findPage(T record) {
    PageHelper.startPage(record.getPage(), record.getRows());
    List<T> list = dao.findList(record);
    PageInfo<T> pageInfo = new PageInfo<>(list);
    return new ResponsePageModel<>(list, pageInfo.getTotal());
}
 
Example 15
Source File: KeywordServiceImpl.java    From yyblog with MIT License 5 votes vote down vote up
@Override
public DataGridResult listPageKeyword(BaseQuery query) {
    PageHelper.startPage(query.getPage(), query.getLimit()); 
    List<KeywordDO> list = keywordMapper.listKeyword();
    //取记录总条数
    PageInfo<KeywordDO> pageInfo = new PageInfo<KeywordDO>(list);
    long total = pageInfo.getTotal();
    //创建一个返回值对象
    DataGridResult result = new DataGridResult(); 
    result.setData(list);
    result.setCount(total);
    return result;
}
 
Example 16
Source File: ArticleServiceImpl.java    From yyblog with MIT License 5 votes vote down vote up
@Override
public DataGridResult listPageArticle(ArticleQuery query) {
    PageHelper.startPage(query.getPage(), query.getLimit()); 
    List<ArticleVO> list = articleMapper.listArticleByTitle(query.getTitle());
    //取记录总条数
    PageInfo<ArticleVO> pageInfo = new PageInfo<ArticleVO>(list);
    long total = pageInfo.getTotal();
    //创建一个返回值对象
    DataGridResult result = new DataGridResult(); 
    result.setData(list);
    result.setCount(total);
    return result;
}
 
Example 17
Source File: CateServiceImpl.java    From yyblog with MIT License 5 votes vote down vote up
@Override
public DataGridResult listPageCate(int pageNum, int pageSize) {
    PageHelper.startPage(pageNum, pageSize); 
    List<CateDO> list = cateMapper.listAllCate();
    //取记录总条数
    PageInfo<CateDO> pageInfo = new PageInfo<CateDO>(list);
    long total = pageInfo.getTotal();
    //创建一个返回值对象
    DataGridResult result = new DataGridResult(); 
    result.setData(list);
    result.setCount(total);
    return result;
}
 
Example 18
Source File: CommonResult.java    From macrozheng-mall with MIT License 5 votes vote down vote up
/**
 * 返回分页成功数据
 */
public CommonResult pageSuccess(List data) {
    PageInfo pageInfo = new PageInfo(data);
    long totalPage = pageInfo.getTotal() / pageInfo.getPageSize();
    Map<String, Object> result = new HashMap<>();
    result.put("pageSize", pageInfo.getPageSize());
    result.put("totalPage", totalPage);
    result.put("pageNum", pageInfo.getPageNum());
    result.put("list", pageInfo.getList());
    this.code = SUCCESS;
    this.message = "操作成功";
    this.data = result;
    return this;
}
 
Example 19
Source File: DataGrid.java    From jee-universal-bms with Apache License 2.0 4 votes vote down vote up
public DataGrid(PageInfo pageInfo) {
    this.total = pageInfo.getTotal();
    this.rows = pageInfo.getList();
}
 
Example 20
Source File: DataGrid.java    From jee-universal-bms with Apache License 2.0 4 votes vote down vote up
public DataGrid(PageInfo pageInfo, Object option) {
    this.total = pageInfo.getTotal();
    this.rows = pageInfo.getList();
    this.option = option;
}