Search in sources :

Example 36 with Page

use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project springboot-learning by lyb-geek.

the class BookServiceImpl method pageBook.

@Override
public PageResult<BookDTO> pageBook(PageQuery<BookDTO> pageQuery) {
    BookDTO bookDTO = pageQuery.getQueryParams();
    Wrapper<Book> wrapper = wrapperQueryCondition(bookDTO);
    IPage<Book> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
    IPage<Book> bookIPage = baseMapper.selectPage(page, wrapper);
    if (bookIPage != null) {
        List<BookDTO> bookDTOS = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(bookIPage.getRecords())) {
            bookDTOS = BeanMapperUtils.mapList(bookIPage.getRecords(), BookDTO.class);
        }
        return PageUtil.INSTANCE.getPage(bookIPage, bookDTOS);
    }
    return null;
}
Also used : BookDTO(com.github.lybgeek.spilt.dto.BookDTO) Book(com.github.lybgeek.spilt.model.Book) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 37 with Page

use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project springboot-learning by lyb-geek.

the class MsgLogController method pagemsgLogs.

@ApiOperation(value = "查找msgLog", tags = { "msgLog" }, nickname = "pageMsgLogs")
@ApiResponses(value = { @ApiResponse(code = 200, message = "操作是否成功,200:成功,否则失败") })
@ApiImplicitParams({ @ApiImplicitParam(name = "curPage", value = "页数", defaultValue = "1", dataTypeClass = Long.class, paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "条数", defaultValue = "20", dataTypeClass = Long.class, paramType = "query", required = true) })
@GetMapping(value = "/page", produces = { "application/json" })
public Page<MsgLog> pagemsgLogs(@RequestParam(value = "curPage") Long curPage, @RequestParam(value = "pageSize") Long pageSize) {
    Page page = new Page(curPage, pageSize);
    Page<MsgLog> pageMsg = (Page<MsgLog>) msgLogService.page(page);
    return pageMsg;
}
Also used : Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) MsgLog(com.github.lybgeek.mybatisplus.msg.entity.MsgLog)

Example 38 with Page

use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project forum by saysky.

the class BaseService method findAll.

/**
 * 根据查询条件分页获取
 *
 * @param page
 * @param condition
 * @return
 */
default Page<E> findAll(Page<E> page, QueryCondition<E> condition) {
    E e = condition.getData();
    SearchVo searchVo = condition.getSearchVo();
    // 对指定字段查询
    QueryWrapper<E> queryWrapper = getQueryWrapper(e);
    // 查询日期范围
    if (searchVo != null) {
        String startDate = searchVo.getStartDate();
        String endDate = searchVo.getEndDate();
        if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
            Date start = DateUtil.parse(startDate);
            Date end = DateUtil.parse(endDate);
            queryWrapper.between("create_time", start, end);
        }
    }
    return (Page<E>) getRepository().selectPage(page, queryWrapper);
}
Also used : SearchVo(com.example.forum.vo.SearchVo) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) Date(java.util.Date)

Example 39 with Page

use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project RG by ADrWondertainment.

the class AnswerServiceImpl method getAnswersByUserID.

@Override
public Result getAnswersByUserID(Integer id, Integer pageNum, Integer size) {
    IPage<Answer> page = new Page(pageNum, size);
    QueryWrapper<Answer> query = Wrappers.query();
    query.eq("uid", id);
    IPage<Answer> answerIPage = answerMapper.selectPage(page, query);
    if (answerIPage == null) {
        throw new BackException(ErrorCode.TEMPLATE_SELECT_FAILURE, "分页数据查询失败");
    }
    List<Answer> records = answerIPage.getRecords();
    JSONArray jsonArray = JSONUtil.parseArray(records);
    System.out.println(JSONUtil.toJsonPrettyStr(jsonArray));
    ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
    return result;
}
Also used : BackException(ruangong.root.exception.BackException) JSONArray(cn.hutool.json.JSONArray) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 40 with Page

use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project RG by ADrWondertainment.

the class SheetServiceImpl method getSheetsInPages.

@Override
public Result getSheetsInPages(Integer id, Integer pageIndex, Integer sizePerPage) {
    IPage<Sheet> page = new Page(pageIndex, sizePerPage);
    QueryWrapper<Sheet> query = Wrappers.query();
    query.eq("uid", id);
    IPage<Sheet> sheetIPage = sheetMapper.selectPage(page, query);
    if (sheetIPage == null) {
        throw new BackException(ErrorCode.SHEET_SELECT_FAILURE, "分页数据查询失败");
    }
    JSONArray jsonArray = JSONUtil.parseArray(sheetIPage.getRecords());
    ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
    return result;
}
Also used : BackException(ruangong.root.exception.BackException) JSONArray(cn.hutool.json.JSONArray) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Aggregations

Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)239 IPage (com.baomidou.mybatisplus.core.metadata.IPage)171 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)62 ApiOperation (io.swagger.annotations.ApiOperation)38 ArrayList (java.util.ArrayList)29 LoginUser (org.jeecg.common.system.vo.LoginUser)26 Test (org.junit.Test)24 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)19 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)17 JSONObject (com.alibaba.fastjson.JSONObject)15 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)13 Result (org.jeecg.common.api.vo.Result)12 User (org.apache.dolphinscheduler.dao.entity.User)11 OrderItem (com.baomidou.mybatisplus.core.metadata.OrderItem)9 java.util (java.util)9 HashMap (java.util.HashMap)9 Project (org.apache.dolphinscheduler.dao.entity.Project)9 Service (org.springframework.stereotype.Service)9 IOException (java.io.IOException)8