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

The following examples show how to use com.github.pagehelper.PageInfo#getList() . 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: IndexController.java    From my-site with Apache License 2.0 6 votes vote down vote up
@ApiOperation("进入首页")
@GetMapping(value = {"","/index"})
public String index(HttpServletRequest request){
    LOGGER.info("Enter admin index method");
    List<CommentDomain> comments = siteService.getComments(5);
    List<ContentDomain> contents = siteService.getNewArticles(5);
    StatisticsDto statistics = siteService.getStatistics();
    // 取最新的20条日志
    PageInfo<LogDomain> logs = logService.getLogs(1, 5);
    List<LogDomain> list = logs.getList();
    request.setAttribute("comments", comments);
    request.setAttribute("articles", contents);
    request.setAttribute("statistics", statistics);
    request.setAttribute("logs", list);
    LOGGER.info("Exit admin index method");
    return "admin/index";
}
 
Example 2
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 3
Source File: AdminController.java    From sms-ssm with MIT License 6 votes vote down vote up
/**
 * @description: 分页查询:根据管理员姓名获取指定/所有管理员信息列表
 * @param: page 当前页码
 * @param: rows 列表行数
 * @param: username 管理员姓名
 * @date: 2019-06-13 1:31 PM
 * @return: java.util.Map<java.lang.String, java.lang.Object>
 */
@PostMapping("/getAdminList")
@ResponseBody
public Map<String, Object> getAdminList(Integer page, Integer rows, String username) {

    //获取查询的用户名
    Admin admin = new Admin();
    admin.setName(username);
    //设置每页的记录数
    PageHelper.startPage(page, rows);
    //根据姓名获取指定或所有管理员列表信息
    List<Admin> list = adminService.selectList(admin);
    //封装查询结果
    PageInfo<Admin> pageInfo = new PageInfo<>(list);
    //获取总记录数
    long total = pageInfo.getTotal();
    //获取当前页数据列表
    List<Admin> adminList = pageInfo.getList();
    //存储对象数据
    result.put("total", total);
    result.put("rows", adminList);

    return result;
}
 
Example 4
Source File: Category1Controller.java    From product-recommendation-system with MIT License 5 votes vote down vote up
/**
 * 处理查询一级类目列表的请求
 * @return
 */
@RequestMapping(value="/listCategory1")
public @ResponseBody Map<String, Object> listCategory1(String category1Name,
	Integer pageNo, Integer pageSize) {
	
	// 1.创建一级类目对象
	Category1 category1 = new Category1();
	if (category1Name == null || category1Name.equals("") || category1Name.equals("所有一级类目")) {
		category1Name = null;
	}
	category1.setCategory1Name(category1Name);
	// 2.构造分页对象
	PageParam pageParam = new PageParam(pageNo, pageSize);
	// 3.分页查询
	PageInfo<Category1> pageInfo = category1Service.listCategory1Page(category1, pageParam);
	
	// 获取一级类目列表
	List<Category1> category1List = pageInfo.getList();
	// 获取分页条
	String pageBar = PageUtils.pageStr(pageInfo, CATEGORY1_QUERY_METHOD_PAGE);
	
	Map<String, Object> map = new HashMap<String, Object>();
	
	map.put("category1List", category1List);
	map.put("pageBar", pageBar);
	map.put("listSize", pageInfo.getTotal());
	
	return map;
}
 
Example 5
Source File: Category2Controller.java    From product-recommendation-system with MIT License 5 votes vote down vote up
/**
 * 处理查询二级类目列表的请求
 * @return
 */
@RequestMapping(value="/listCategory2")
public @ResponseBody Map<String, Object> listCategory2(String category2Name,
	Long category1Id, Integer pageNo, Integer pageSize) {
	
	// 1.创建二级类目对象
	Category2 category2 = new Category2();
	if (category2Name.equals("所有二级类目")) {
		category2Name = null;
	}
	if (category1Id.equals(0L)) {
		category1Id = null;
	}
	
	category2.setCategory2Name(category2Name);
	category2.setCategory1Id(category1Id);
	// 2.构造分页对象
	PageParam pageParam = new PageParam(pageNo, pageSize);
	// 3.分页查询
	PageInfo<Category2DTO> pageInfo = category2Service.listCategory2Page(category2, pageParam);
	
	// 获取二级类目列表
	List<Category2DTO> category2List = pageInfo.getList();
	// 获取分页条
	String pageBar = PageUtils.pageStr(pageInfo, CATEGORY2_QUERY_METHOD_PAGE);
	
	Map<String, Object> map = new HashMap<String, Object>();
	
	map.put("category2List", category2List);
	map.put("pageBar", pageBar);
	map.put("listSize", pageInfo.getTotal());
	
	return map;
}
 
Example 6
Source File: DataSourceService.java    From DBus with Apache License 2.0 5 votes vote down vote up
/**
 * datasource首页的搜索
 *
 * @param queryString param:dsName,if ds=null get all
 */
public ResultEntity search(String queryString) throws Exception {
    ResponseEntity<ResultEntity> result;
    if (queryString == null || queryString.isEmpty()) {
        result = sender.get(KEEPER_SERVICE, "/datasource/search");
    } else {
        queryString = URLDecoder.decode(queryString, "UTF-8");
        result = sender.get(KEEPER_SERVICE, "/datasource/search", queryString);
    }
    ResultEntity body = result.getBody();
    PageInfo<Map<String, Object>> dataSourceList = body.getPayload(new TypeReference<PageInfo<Map<String, Object>>>() {
    });
    for (Map<String, Object> ds : dataSourceList.getList()) {
        String dsName = (String) ds.get("name");
        if (ds.get("type").equals("mysql")) {
            JSONObject canalConf = autoDeployDataLineService.getCanalConf(dsName);
            ds.put("oggOrCanalHost", canalConf.getString(KeeperConstants.HOST));
            ds.put("oggOrCanalPath", canalConf.getString(KeeperConstants.CANAL_PATH));
            ds.put("slaveAddress", canalConf.getString(KeeperConstants.CANAL_ADD));
            ds.put("slaveId", canalConf.getString(KeeperConstants.SLAVE_ID));
        }
        if (ds.get("type").equals("oracle")) {
            JSONObject oggConf = autoDeployDataLineService.getOggConf(dsName);
            ds.put("oggOrCanalHost", oggConf.getString(KeeperConstants.HOST));
            ds.put("oggOrCanalPath", oggConf.getString(KeeperConstants.OGG_PATH));
            ds.put("oggReplicatName", oggConf.getString(KeeperConstants.REPLICAT_NAME));
            ds.put("oggTrailName", oggConf.getString(KeeperConstants.TRAIL_NAME));
            ds.put("mgrReplicatPort", oggConf.getString(KeeperConstants.MGR_REPLICAT_PORT));
        }
    }
    body.setPayload(dataSourceList);
    return body;
}
 
Example 7
Source File: ProductServiceTest.java    From product-recommendation-system with MIT License 5 votes vote down vote up
/**
 * 测试查询商品列表
 */
@Test
public void testListProduct() {
	ProductService productService = (ProductService) this.application.getBean("productService");
	Product product = new Product();
	product.setProductId(1L);;
	PageInfo<ProductDTO> pageInfo = productService.listProductPage(product, null);
	for (ProductDTO tempProductDTO : pageInfo.getList()) {
		System.out.println(tempProductDTO);
	}
}
 
Example 8
Source File: SysUserController.java    From seezoon-framework-all with Apache License 2.0 5 votes vote down vote up
@RequiresPermissions("sys:user:qry")
@PostMapping("/qryPage.do")
public ResponeModel qryPage(SysUser sysUser,HttpServletRequest request) {
	PageInfo<SysUser> page = sysUserService.findByPage(sysUser, sysUser.getPage(), sysUser.getPageSize());
	for (SysUser user: page.getList()) {
		user.setPhotoFullUrl(FileConfig.getFullUrl(user.getPhoto()));
	}
	return ResponeModel.ok(page);
}
 
Example 9
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 10
Source File: SysFileController.java    From seezoon-framework-all with Apache License 2.0 5 votes vote down vote up
@RequiresPermissions("sys:file:qry")
@PostMapping("/qryPage.do")
public ResponeModel qryPage(SysFile sysFile,@RequestParam(required=false) Date startDate,@RequestParam(required=false) Date endDate) {
	sysFile.addProperty("startDate", startDate);
	sysFile.addProperty("endDate", endDate);
	PageInfo<SysFile> page = sysFileService.findByPage(sysFile, sysFile.getPage(), sysFile.getPageSize());
	for (SysFile file: page.getList()) {
		file.setFullUrl(FileConfig.getFullUrl(file.getRelativePath()));
	}
	return ResponeModel.ok(page);
}
 
Example 11
Source File: SysLogController.java    From Shiro-Action with MIT License 5 votes vote down vote up
@OperationLog("查看操作日志")
@GetMapping("/list")
@ResponseBody
public PageResultBean<SysLog> getList(@RequestParam(value = "page", defaultValue = "1") int page,
                                      @RequestParam(value = "limit", defaultValue = "10")int limit) {
    List<SysLog> loginLogs = sysLogService.selectAll(page, limit);
    PageInfo<SysLog> rolePageInfo = new PageInfo<>(loginLogs);
    return new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
}
 
Example 12
Source File: UserController.java    From java-master with Apache License 2.0 5 votes vote down vote up
/**
 * 拥有管理员权限可查看任何用户信息,否则只能查看自己的信息
 */
@PreAuthorize("hasAuthority('ROLE_DMIN') or #reqVo.sysUser.username == #userDetails.username")
@PostMapping("/findUsers")
public Result<List<SysUser>> findUsers(@RequestBody FindUsersReqVo reqVo, @AuthenticationPrincipal UserDetails userDetails) {
    PageInfo<SysUser> pageInfo = userService.findUsers(reqVo);
    return new Result<>(pageInfo.getList(), pageInfo.getTotal());
}
 
Example 13
Source File: GradeController.java    From sms-ssm with MIT License 5 votes vote down vote up
/**
 * @description: 分页查询:根据年级名称获取指定/所有年级信息列表
 * @param: page
 * @param: rows
 * @param: gradename
 * @date: 2019-06-15 1:14 PM
 * @return: java.util.Map<java.lang.String, java.lang.Object>
 */
@PostMapping("/getGradeList")
@ResponseBody
public Map<String, Object> getGradeList(Integer page, Integer rows, String gradename) {

    //注意:使用Java Bean传递gradename,防止以下异常 !
    //org.springframework.web.util.NestedServletException: Request processing failed;
    // nested exception is org.mybatis.spring.MyBatisSystemException:
    // nested exception is org.apache.ibatis.reflection.ReflectionException:
    // There is no getter for property named 'name' in 'class java.lang.String'
    Grade grade = new Grade();
    grade.setName(gradename);

    //设置每页的记录数
    PageHelper.startPage(page, rows);
    //根据年级名称获取指定或全部年级信息列表
    List<Grade> list = gradeService.selectList(grade);
    //封装信息列表
    PageInfo<Grade> pageInfo = new PageInfo<>(list);
    //获取总记录数
    long total = pageInfo.getTotal();
    //获取当前页数据列表
    List<Grade> gradeList = pageInfo.getList();
    //存储数据对象
    result.put("total", total);
    result.put("rows", gradeList);

    return result;
}
 
Example 14
Source File: AdminController.java    From product-recommendation-system with MIT License 5 votes vote down vote up
/**
 * 查询管理员列表
 * @return
 */
@RequestMapping(value="/listAdmin")
public @ResponseBody Map<String, Object> listAdmin(String adminName, Integer pageNo,
	Integer pageSize) {
	
	Admin admin = new Admin();
	// 去除名称中的空格
	admin.setAdminName(adminName.replace(" ", ""));
	
	// 创建分页对象
	PageParam pageParam = new PageParam(pageNo, pageSize);
	
	PageInfo<Admin> pageInfo = this.adminService.listAdmin(admin, pageParam);
	
	Map<String, Object> resultMap = new HashMap<String, Object>();
	
	// 1.获取管理员列表
	List<Admin> adminList = pageInfo.getList();
	// 2.获取分页条
	String pageBar = PageUtils.pageStr(pageInfo, ADMIN_QUERY_METHOD_PAGE);
	// 3.获取总的记录数
	Long adminNums = pageInfo.getTotal();
	
	resultMap.put("adminList", adminList);
	resultMap.put("pageBar", pageBar);
	resultMap.put("adminNums", adminNums);
	
	return resultMap;
}
 
Example 15
Source File: BizArticleServiceImpl.java    From OneBlog with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 近期文章
 *
 * @param pageSize
 * @return
 */
@Override
public List<Article> listRecent(int pageSize) {
    ArticleConditionVO vo = new ArticleConditionVO();
    vo.setPageSize(pageSize);
    vo.setStatus(ArticleStatusEnum.PUBLISHED.getCode());
    PageInfo pageInfo = this.findPageBreakByCondition(vo);
    return null == pageInfo ? null : pageInfo.getList();
}
 
Example 16
Source File: TripController.java    From newblog with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/ajaxpic")
public void ajaxpic(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String page = request.getParameter("page");
    Integer pagenum;
    if (StringUtils.isEmpty(page)) {
        pagenum = 1;
    } else {
        pagenum = Integer.parseInt(page);
    }
    PageHelper.startPage(pagenum, 15);
    List<Image> lists = imageService.getAllImage();
    PageInfo<Image> images = new PageInfo<>(lists);
    Gson gson = new Gson();
    JsonArray jsonArray = new JsonArray();
    for (Image image : images.getList()) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("photo_id", image.getImageid());
        jsonObject.addProperty("unm", image.getImagename());
        jsonObject.addProperty("uid", image.getImageid());
        jsonObject.addProperty("ava", image.getImagepath());
        jsonObject.addProperty("isrc", image.getImagepath());
        jsonObject.addProperty("id", image.getImageid());
        jsonObject.addProperty("msg", image.getContent());
        jsonObject.addProperty("iht", image.getIht());
        jsonArray.add(jsonObject);
    }
    long totalcount = images.getPages();
    String temp = ",\"totalcount\":" + String.valueOf(totalcount) + ",\"has_next\":" +
            String.valueOf(pagenum < totalcount) + "";
    String str = gson.toJson(jsonArray);
    String json = "{\"data\":{\"blogs\":" + str + ",\"hasrp\":true,\"pgsource\":" +
            "\"_\",\"nopth\":false" + temp + "},\"success\":true}";
    response.getWriter().write(json);
}
 
Example 17
Source File: SysEnterpriseServiceImpl.java    From momo-cloud-permission with Apache License 2.0 4 votes vote down vote up
@Override
public SysUserListRes userList(SysEnterpriseUserReq sysEnterpriseUserReq) {
    UserGroupDO uuid = userGroupMapper.uuid(sysEnterpriseUserReq.getEnterpriseUuid());
    if (uuid == null) {
        throw BizException.fail("用户所在的企业不存在");
    }
    SysUserListRes sysUserListResFianl = new SysUserListRes();
    sysUserListResFianl.setSysEnterpriseName(uuid.getUserGroupName());
    RedisUser redisUser = this.redisUser();
    PageHelper.startPage(sysEnterpriseUserReq.getPageNum(), sysEnterpriseUserReq.getPageSize(), "id desc");
    List<SysUserListDO> pageSysUserList = userMapper.pageSysUserList(uuid.getId(), sysEnterpriseUserReq.getSysUserName(), sysEnterpriseUserReq.getDisabledFlag());
    PageInfo<SysUserListDO> pageInfo = new PageInfo<>(pageSysUserList);
    List<SysUserListRes> resList = Lists.newArrayList();
    List<SysUserListDO> doList = pageInfo.getList();

    PageInfo<SysUserListRes> pageInfoRes = new PageInfo<>();
    pageInfoRes.setPageNum(pageInfo.getPageNum());
    pageInfoRes.setPageSize(pageInfo.getPageSize());
    pageInfoRes.setTotal(pageInfo.getTotal());
    if (CollectionUtils.isNotEmpty(doList)) {
        doList.forEach(sysUserListDO -> {
            SysUserListRes sysUserListRes = new SysUserListRes();
            BeanUtils.copyProperties(sysUserListDO, sysUserListRes);
            //管理员按钮是否显示
            List<RoleDO> roles = sysUserListDO.getRoles();
            Set<Integer> rolesSet = roles.stream().map(RoleDO::getSysRoleType).collect(Collectors.toSet());
            //角色的类型,0:管理员(老板),1:管理员(员工) 2其他
            if (rolesSet.contains(RoleTypeEnum.superAdmin.type)) {
                sysUserListRes.setEditButtonShow(false);
                sysUserListRes.setPwdButtonShow(false);
                sysUserListRes.setDisabledFlagButtonShow(false);
                sysUserListRes.setRoleButtonShow(false);
            }
            if (rolesSet.contains(RoleTypeEnum.admin.type)) {
                sysUserListRes.setEditButtonShow(false);
                sysUserListRes.setPwdButtonShow(false);
                sysUserListRes.setDisabledFlagButtonShow(false);
                sysUserListRes.setRoleButtonShow(false);
            }
            //用户是自己登陆,则显示自己
            if (sysUserListDO.getId().equals(redisUser.getBaseId())) {
                sysUserListRes.setEditButtonShow(true);
                sysUserListRes.setPwdButtonShow(true);
                sysUserListRes.setDisabledFlagButtonShow(true);
                sysUserListRes.setRoleButtonShow(true);
            }
            //超级管理员,则显示全部
            if (superAdminsService.checkIsSuperAdmin(redisUser.getSysUserPhone())) {
                sysUserListRes.setEditButtonShow(true);
                sysUserListRes.setPwdButtonShow(true);
                sysUserListRes.setDisabledFlagButtonShow(true);
                sysUserListRes.setRoleButtonShow(true);
            }
            UserAccountPwdDO userAccountPwdDO = sysUserListDO.getUserAccountPwdDO();
            //密码绑定
            if (null != userAccountPwdDO) {
                sysUserListRes.setPwdBinding(true);
                sysUserListRes.setPwdBindingName(userAccountPwdDO.getSysUserLoginName());
                sysUserListRes.setPwdBindingFlag(userAccountPwdDO.getDisabledFlag());
                sysUserListRes.setPwdBindingDate(userAccountPwdDO.getCreateTime());
            }
            resList.add(sysUserListRes);
        });
        pageInfoRes.setList(resList);

        sysUserListResFianl.setSysUserListResPageInfo(pageInfoRes);
        return sysUserListResFianl;
    }
    sysUserListResFianl.setSysUserListResPageInfo(pageInfoRes);
    return sysUserListResFianl;
}
 
Example 18
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 19
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;
}
 
Example 20
Source File: Commons.java    From Jantent with MIT License 2 votes vote down vote up
/**
 * 判断分页中是否有数据
 *
 * @param paginator
 * @return
 */
public static boolean is_empty(PageInfo paginator) {
    return paginator == null || (paginator.getList() == null) || (paginator.getList().size() == 0);
}