Java Code Examples for com.baomidou.mybatisplus.plugins.Page#setSize()

The following examples show how to use com.baomidou.mybatisplus.plugins.Page#setSize() . 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: BasicServiceTest.java    From app-version with Apache License 2.0 6 votes vote down vote up
@Test
public void formatCreatedBy() throws Exception {
    EntityWrapper<CustomApi> wrapper = new EntityWrapper<>();
    wrapper.and().eq("app_id", ThreadLocalUtils.USER_THREAD_LOCAL.get().getAppId());
    wrapper.andNew().eq("id", 48);
    wrapper.andNew().eq("del_flag", 0);
    wrapper.orderBy("created_time", false);

    Page<CustomApi> pageEntity = new Page<>();
    pageEntity.setSize(10);
    pageEntity.setCurrent(1);
    pageEntity.setRecords(customApiMapper.selectPage(pageEntity, wrapper));
    logger.info("formatCreatedBy前:" + pageEntity.getRecords().toString());
    basicService.formatCreatedBy(pageEntity.getRecords());
    logger.info("formatCreatedBy后:" + pageEntity.getRecords().toString());
}
 
Example 2
Source File: ChannelServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult list(int page, int pageSize, EntityWrapper<Channel> wrapper) {
    Page<Channel> pageEntity = new Page<>();
    pageEntity.setSize(pageSize);
    pageEntity.setCurrent(page);
    pageEntity.setRecords(channelMapper.selectPage(pageEntity, wrapper));
    basicService.formatCreatedBy(pageEntity.getRecords());
    return ServiceResult.ok(pageEntity);
}
 
Example 3
Source File: AdminServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult listApp(int page, int pageSize, EntityWrapper<App> wrapper) {
    Page<App> pageEntity = new Page<>();
    pageEntity.setSize(pageSize);
    pageEntity.setCurrent(page);
    pageEntity.setRecords(appMapper.selectPage(pageEntity, wrapper));
    basicService.formatCreatedBy(pageEntity.getRecords());
    return ServiceResult.ok(pageEntity);
}
 
Example 4
Source File: AdminServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult listUser(int page, int pageSize, EntityWrapper<User> wrapper) {
    Page<User> pageEntity = new Page<>();
    pageEntity.setSize(pageSize);
    pageEntity.setCurrent(page);
    pageEntity.setRecords(userMapper.selectPage(pageEntity, wrapper));
    return ServiceResult.ok(pageEntity);
}
 
Example 5
Source File: CustomApiServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult list(int page, int pageSize, EntityWrapper<CustomApi> wrapper) {
    Page<CustomApi> pageEntity = new Page<>();
    pageEntity.setSize(pageSize);
    pageEntity.setCurrent(page);
    pageEntity.setRecords(customApiMapper.selectPage(pageEntity, wrapper));
    basicService.formatCreatedBy(pageEntity.getRecords());
    return ServiceResult.ok(pageEntity);
}
 
Example 6
Source File: ApkServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult getApkPageWithChannelCode(int page, int pageSize, Integer versionId, String channelCode, String md5, Integer deliveryStatus) {
    AndroidVersion androidVersion = androidVersionMapper.selectById(versionId);
    if (androidVersion == null) {
        return ServiceResultConstants.VERSION_NOT_EXISTS;
    }
    Page<ApkExt> apkPage = new Page<>();
    apkPage.setCurrent(page);
    apkPage.setSize(pageSize);
    apkPage.setRecords(apkMapper.selectApkWithChannelCode(apkPage, versionId, channelCode, md5, deliveryStatus));
    basicService.formatCreatedBy(apkPage.getRecords());
    return ServiceResult.ok(apkPage);
}
 
Example 7
Source File: IosVersionServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult list(int page, int pageSize, EntityWrapper<IosVersion> wrapper) {
    Page<IosVersion> versionPage = new Page<>();
    versionPage.setCurrent(page);
    versionPage.setSize(pageSize);
    versionPage.setRecords(iosVersionMapper.selectPage(versionPage, wrapper));
    basicService.formatCreatedBy(versionPage.getRecords());
    return ServiceResult.ok(versionPage);
}
 
Example 8
Source File: AppServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult getAppListWithUserId(int page, int pageSize, String userId) {
    EntityWrapper<UserAppRel> entityWrapper = new EntityWrapper<>();
    entityWrapper.and().eq("user_id", userId);
    Page<UserAppRel> userAppRelPage = new Page<>();
    userAppRelPage.setCurrent(page);
    userAppRelPage.setSize(pageSize);
    userAppRelPage.setRecords(userAppRelMapper.selectPage(userAppRelPage, entityWrapper));
    List<App> collect = userAppRelPage.getRecords().stream().map(mapper -> {
        Integer appId = mapper.getAppId();
        App app = new App();
        app.setId(appId);
        app.setDelFlag(0);
        return appMapper.selectOne(app);
    }).collect(Collectors.toList());

    collect.removeAll(Collections.singleton(null));
    Page<App> appPage = new Page<>();
    try {
        $.bean.copyProperties(appPage, userAppRelPage);
        appPage.setRecords(collect);
        return ServiceResult.ok(appPage);
    } catch (InvocationTargetException | IllegalAccessException e) {
        logger.error("App参数转换出错", e);
    }
    return ServiceResultConstants.ERROR_500;
}
 
Example 9
Source File: OperationRecordLogServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult list(int page, int pageSize, EntityWrapper<OperationRecordLog> wrapper) {
    Page<OperationRecordLog> pageEntity = new Page<>();
    pageEntity.setSize(pageSize);
    pageEntity.setCurrent(page);
    pageEntity.setRecords(operationRecordLogMapper.selectPage(pageEntity, wrapper));
    basicService.formatCreatedBy(pageEntity.getRecords());
    return ServiceResult.ok(pageEntity);
}
 
Example 10
Source File: OperationRecordLogServiceImpl.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceResult getListByQuery(int page, int pageSize, String phone, String nickName, Integer appId, String operationResource, String operationDescription, String operationType, String startDate, String endDate) {
    Page<OperationRecordLogExt> logPage = new Page<>();
    logPage.setCurrent(page);
    logPage.setSize(pageSize);
    List<OperationRecordLogExt> list = operationRecordLogMapper.selectLogExtByQuery(logPage, phone, nickName, appId, operationResource, operationDescription, operationType, startDate, endDate);
    logPage.setRecords(list);
    return ServiceResult.ok(logPage);
}
 
Example 11
Source File: OperationRecordLogMapperTest.java    From app-version with Apache License 2.0 5 votes vote down vote up
@Test
public void selectLogExtByQuery() throws Exception {
    Page<OperationRecordLogExt> page = new Page<>();
    page.setCurrent(1);
    page.setSize(10);
    String endDate = "2018-06-27 19:10:27";

    List list = operationRecordLogMapper.selectLogExtByQuery(page, null, null, null, null, null, null,null,endDate);
    logger.info("size: " + list.size());

    list = operationRecordLogMapper.selectLogExtByQuery(page, "", "", null, "", null, "",null,null);
    logger.info("size: " + list.size());
}
 
Example 12
Source File: BaseCrudController.java    From Ffast-Java with MIT License 5 votes vote down vote up
/**
 * 查询
 *
 * @param m
 * @param page
 * @param simple 只查少数字段
 * @return
 */
@ResponseBody
@RequestMapping(value = "/list")
@Permission(value = "list")
public ServiceResult list(T m, Integer pageSize, Integer page, Boolean simple, String sortField, String sortOrder) {
    ServiceResult beforeResult = listBefore(m);
    if (beforeResult != null) {
        return beforeResult;
    }
    // 查询字段
    String[] properties = ((simple != null && simple) ? getSimpleProperties() : getProperties());
    Page<T> pageM = new Page<T>();
    if (pageSize == null || page == null) {
        pageSize = 1000;
        page = 0;
    }
    // 排序相关
    if (sortOrder != null) {
        pageM.setAsc("asc".equals(sortOrder));
    } else {
        pageM.setAsc(isAsc());
    }
    if (sortField == null) {
        sortField = getSortField();
    }
    pageM.setOrderByField(sortField);
    pageM.setCurrent(page);
    pageM.setSize(pageSize);
    return getService().findListByPage(m, pageM);
}
 
Example 13
Source File: DefaultCinemaServiceImpl.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Override
public Page<CinemaVO> getCinemas(CinemaQueryVO cinemaQueryVO) {
    // 业务实体集合
    List<CinemaVO> cinemas = new ArrayList<>();

    Page<MoocCinemaT> page = new Page<>(cinemaQueryVO.getNowPage(), cinemaQueryVO.getPageSize());
    // 判断是否传入查询条件 -> brandId,distId,hallType 是否==99
    EntityWrapper<MoocCinemaT> entityWrapper = new EntityWrapper<>();
    if (cinemaQueryVO.getBrandId() != 99) {
        entityWrapper.eq("brand_id", cinemaQueryVO.getBrandId());
    }
    if (cinemaQueryVO.getDistrictId() != 99) {
        entityWrapper.eq("area_id", cinemaQueryVO.getDistrictId());
    }
    if (cinemaQueryVO.getHallType() != 99) {  // %#3#%
        entityWrapper.like("hall_ids", "%#+" + cinemaQueryVO.getHallType() + "+#%");
    }

    // 将数据实体转换为业务实体
    List<MoocCinemaT> moocCinemaTS = moocCinemaTMapper.selectPage(page, entityWrapper);
    for (MoocCinemaT moocCinemaT : moocCinemaTS) {
        CinemaVO cinemaVO = new CinemaVO();

        cinemaVO.setUuid(moocCinemaT.getUuid() + "");
        cinemaVO.setMinimumPrice(moocCinemaT.getMinimumPrice() + "");
        cinemaVO.setCinemaName(moocCinemaT.getCinemaName());
        cinemaVO.setAddress(moocCinemaT.getCinemaAddress());

        cinemas.add(cinemaVO);
    }

    // 根据条件,判断影院列表总数
    long counts = moocCinemaTMapper.selectCount(entityWrapper);

    // 组织返回值对象
    Page<CinemaVO> result = new Page<>();
    result.setRecords(cinemas);
    result.setSize(cinemaQueryVO.getPageSize());
    result.setTotal(counts);

    return result;
}