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

The following examples show how to use com.github.pagehelper.Page#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: BrandService.java    From leyou with Apache License 2.0 6 votes vote down vote up
/**
     * 条件查询品牌-含分页
     *
     * @param page   当前页
     * @param rows   每页大小
     * @param sortBy 排序字段
     * @param desc   是否为降序
     * @param key    搜索关键字
     * @return
     */
    public PageResult<Brand> queryBrandByPageAndSort(Integer page, Integer rows, String sortBy, Boolean desc, String key) {
        // 开启分页
        PageHelper.startPage(page, rows);
        // 过滤
        Example example = new Example(Brand.class);
//        if (StringUtils.isNotBlank(key)) {
        if (key != null && !"".equals(key)) {
            // 条件非空,name-品牌名称 letter-品牌首字母
            example.createCriteria().andLike("name", "%" + key + "%").orEqualTo("letter", key);
        }
        if (sortBy != null && !"".equals(sortBy)) {
            // 排序 order by 属性名 DESC/ASC
            String orderByClause = sortBy + (desc ? " DESC " : " ASC ");
            example.setOrderByClause(orderByClause);
        }
        // 查询
        Page<Brand> pageInfo = (Page<Brand>) brandMapper.selectByExample(example);
        // 返回结果
        return new PageResult<>(pageInfo.getTotal(), pageInfo);

    }
 
Example 2
Source File: SmsSkdController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:根据部门id筛选排版规则基本信息、分页
 * <p>author: ma
 * <p>author: 赵煜  修改查询不到科室排班规则500错误,并返回创建人name
 */
@ApiOperation("根据部门id筛选排版规则基本信息、分页")
@RequestMapping(value = "/listRule", method = RequestMethod.POST)
@ResponseBody
public CommonResult<CommonPage<SmsSkdRuleResult>> listRule(@RequestParam("deptId")  Long deptId,
                                                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);
    List<SmsSkdRuleResult> list = smsSkdService.selectRuleByDept(deptId);
   if( CollectionUtils.isEmpty(list)){
        return CommonResult.success(null,"不存在排班规则");
   }
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 3
Source File: NamespacesRepositoryImplTest.java    From pulsar-manager with Apache License 2.0 5 votes vote down vote up
public void checkResult(Page<NamespaceEntity> namespacesEntityPage) {
    long total = namespacesEntityPage.getTotal();
    Assert.assertEquals(1, total);
    namespacesEntityPage.getResult().forEach((result) -> {
        Assert.assertEquals("test-namespace-public", result.getTenant());
        Assert.assertEquals("test-namespace-default", result.getNamespace());
    });
}
 
Example 4
Source File: SmsSkdController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:根据部门id筛选排版规则基本信息、分页
 * <p>author: ma
 * <p>author: 赵煜  修改查询不到科室排班规则500错误,并返回创建人name
 */
@ApiOperation("根据部门id筛选排版规则基本信息、分页")
@RequestMapping(value = "/listRule", method = RequestMethod.POST)
@ResponseBody
public CommonResult<CommonPage<SmsSkdRuleResult>> listRule(@RequestParam("deptId")  Long deptId,
                                                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);
    List<SmsSkdRuleResult> list = smsSkdService.selectRuleByDept(deptId);
   if( CollectionUtils.isEmpty(list)){
        return CommonResult.success(null,"不存在排班规则");
   }
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 5
Source File: BmsFeeController.java    From HIS with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "查询挂号人")
@RequestMapping(value = "/listRegisteredPatient", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<BmsRegistrationPatientResult>> listRegisteredPatient(@RequestParam(required=false,name = "medicalRecordNo") String  medicalRecordNo,
                                                                                    @RequestParam(required=false,name="queryDate")@DateTimeFormat(pattern = "yyyy-MM-dd") Date queryDate,
                                                                                    @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                                                    @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){


    Page page = PageHelper.startPage(pageNum, pageSize);
    List<BmsRegistrationPatientResult> list = bmsFeeService.listRegisteredPatient(medicalRecordNo,queryDate);
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 6
Source File: PageUtis.java    From spring-boot-starter-dao with Apache License 2.0 5 votes vote down vote up
public static <T, TO> PageInfo<TO> outPage(Page<T> page, List<TO> tos) {
	if (page == null)
		return new PageInfo<TO>();
	int pageSize = page.getPageSize();
	int pageNo = page.getPageNum();
	long total = page.getTotal();
	return new PageInfo<TO>(pageNo, pageSize, total, tos);
}
 
Example 7
Source File: DmsDrugController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:模糊查询药品、且分页
 * <p>author: ma
 */
@ApiOperation("模糊查询药品、且分页")
@RequestMapping(value = "/selectDrug", method = RequestMethod.POST)
@ResponseBody
public CommonResult<CommonPage<DmsDrugResult>> listDrug(DmsDrugParam queryParam,
                                                        @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);
    List<DmsDrugResult> list = dmsDrugService.selectDrug(queryParam,pageSize,pageNum);
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 8
Source File: SmsSkdController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:根据部门id筛选排版规则基本信息、分页
 * <p>author: ma
 * <p>author: 赵煜  修改查询不到科室排班规则500错误,并返回创建人name
 */
@ApiOperation("根据部门id筛选排版规则基本信息、分页")
@RequestMapping(value = "/listRule", method = RequestMethod.POST)
@ResponseBody
public CommonResult<CommonPage<SmsSkdRuleResult>> listRule(@RequestParam("deptId")  Long deptId,
                                                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);
    List<SmsSkdRuleResult> list = smsSkdService.selectRuleByDept(deptId);
   if( CollectionUtils.isEmpty(list)){
        return CommonResult.success(null,"不存在排班规则");
   }
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 9
Source File: DmsDrugController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:模糊查询药品、且分页
 * <p>author: ma
 */
@ApiOperation("模糊查询药品、且分页")
@RequestMapping(value = "/selectDrug", method = RequestMethod.POST)
@ResponseBody
public CommonResult<CommonPage<DmsDrugResult>> listDrug(@RequestBody DmsDrugParam queryParam,
                                                        @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);
    List<DmsDrugResult> list = dmsDrugService.selectDrug(queryParam,pageSize,pageNum);
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 10
Source File: SmsSkdController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:查找排班记录、分页
 * <p>author: ma
 */
@ApiOperation("查找排班记录、分页")
@RequestMapping(value = "/listSkd", method = RequestMethod.POST)
@ResponseBody
public  CommonResult<CommonPage<SmsSkdResult>> listSkd(@RequestBody SmsSkdParam queryParam,
                                                       @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);

    List<SmsSkdResult> smsSkdResultList = smsSkdService.listSkd(queryParam);
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(smsSkdResultList,pageTotal));
}
 
Example 11
Source File: CustomerServiceImpl.java    From ssm-Online_Examination with Apache License 2.0 5 votes vote down vote up
/**
 * 分页查询-条件查询方法
 *
 * @param customer 查询条件
 * @param pageCode 当前页
 * @param pageSize 每页的记录数
 * @return
 */
public PageBean findByPage(Customer customer, int pageCode, int pageSize) {
    //使用Mybatis分页插件
    PageHelper.startPage(pageCode, pageSize);

    //调用分页查询方法,其实就是查询所有数据,mybatis自动帮我们进行分页计算
    Page<Customer> page = customerMapper.findByPage(customer);

    return new PageBean(pageCode, (int)Math.ceil((double)(page.getTotal() / (double)pageSize)), (int)page.getTotal(), pageSize, page.getResult());
}
 
Example 12
Source File: DmsDrugController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:模糊查询药品、且分页
 * <p>author: ma
 */
@ApiOperation("模糊查询药品、且分页")
@RequestMapping(value = "/selectDrug", method = RequestMethod.POST)
@ResponseBody
public CommonResult<CommonPage<DmsDrugResult>> listDrug(DmsDrugParam queryParam,
                                                        @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);
    List<DmsDrugResult> list = dmsDrugService.selectDrug(queryParam,pageSize,pageNum);
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(list,pageTotal));
}
 
Example 13
Source File: OrderService.java    From leyou with Apache License 2.0 5 votes vote down vote up
public PageResult<Order> queryUserOrderList(Integer page, Integer rows, Integer status) {
    try {
        // 分页
        PageHelper.startPage(page, rows);
        // 获取登录用户
        UserInfo user = LoginInterceptor.getLoginUser();
        // 创建查询条件
        Page<Order> pageInfo = (Page<Order>) this.orderMapper.queryOrderList(user.getId(), status);

        return new PageResult<>(pageInfo.getTotal(), pageInfo);
    } catch (Exception e) {
        logger.error("查询订单出错", e);
        return null;
    }
}
 
Example 14
Source File: SmsSkdController.java    From HIS with Apache License 2.0 5 votes vote down vote up
/**
 * 描述:查找排班记录、分页
 * <p>author: ma
 */
@ApiOperation("查找排班记录、分页")
@RequestMapping(value = "/listSkd", method = RequestMethod.POST)
@ResponseBody
public  CommonResult<CommonPage<SmsSkdResult>> listSkd(SmsSkdParam queryParam,
                                                       @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
    Page page =PageHelper.startPage(pageNum, pageSize);

    List<SmsSkdResult> smsSkdResultList = smsSkdService.listSkd(queryParam);
    Long pageTotal=page.getTotal();
    return CommonResult.success(CommonPage.restPage(smsSkdResultList,pageTotal));
}
 
Example 15
Source File: LogService.java    From frostmourne with MIT License 5 votes vote down vote up
public PagerContract<AlertLog> findAlertLog(int pageIndex, int pageSize, Date startTime, Date endTime,
                                            Long executeId, Long alarmId, String recipient, String way,
                                            String sendStatus, String inSilence, String alertType) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<AlertLog> list = alertLogMapper.find(startTime, endTime, executeId, alarmId, recipient, way, sendStatus, inSilence, alertType);
    return new PagerContract<>(list, page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 16
Source File: DataAdminService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<DataSourceContract> findDatasource(int pageIndex, int pageSize, String datasourceType) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<DataSource> list = this.dataSourceMapper.find(datasourceType);
    return new PagerContract<>(list.stream().map(DataSourceTransformer::model2Contract).collect(Collectors.toList()),
            page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 17
Source File: NamespacesRepositoryImplTest.java    From pulsar-manager with Apache License 2.0 4 votes vote down vote up
public void checkDeleteResult(Page<NamespaceEntity> namespacesEntityPage) {
    long total = namespacesEntityPage.getTotal();
    Assert.assertEquals(0, total);
}
 
Example 18
Source File: LogService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<AlarmLog> findAlarmLog(int pageIndex, int pageSize, Date startTime,
                                    Date endTime, Long alarmId, String verifyResult, String executeResult) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<AlarmLog> list = alarmLogMapper.find(startTime, endTime, alarmId, verifyResult, executeResult);
    return new PagerContract<>(list, page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 19
Source File: AlarmAdminService.java    From frostmourne with MIT License 4 votes vote down vote up
public PagerContract<Alarm> find(int pageIndex, int pageSize, Long alarmId, String name,
                                 String teamName, String status) {
    Page page = PageHelper.startPage(pageIndex, pageSize);
    List<Alarm> list = this.alarmMapper.find(alarmId, name, teamName, status);
    return new PagerContract<>(list, page.getPageSize(), page.getPageNum(), (int) page.getTotal());
}
 
Example 20
Source File: PageResultWrapper.java    From magic-starter with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 构造分页对象
 *
 * @param pageData 当前页数据
 * @param <T>泛型
 * @return 分页对象
 */
public static <T> PageResult<T> wrapper(Page<T> pageData) {
	return new PageResult<>(pageData.getPageNum(), pageData.getPageSize(), pageData.getPages(), pageData.getTotal(), pageData.getResult());
}