Search in sources :

Example 1 with OpenPage

use of org.tech.commons.OpenPage in project tech by ffyyhh995511.

the class PeopleService method queryPage.

public OpenPage queryPage(Integer pageNum, Integer pageSize) {
    // 获取第1页,10条内容,默认查询总数count
    PageHelper.startPage(pageNum, pageSize);
    // 紧跟着的第一个select方法会被分页
    List<People> list = peopleMapper.queryAll();
    Page p = ((Page) list);
    return OpenPage.buildPage(p);
}
Also used : People(org.tech.domain.People) Page(com.github.pagehelper.Page) OpenPage(org.tech.commons.OpenPage)

Example 2 with OpenPage

use of org.tech.commons.OpenPage in project tech by ffyyhh995511.

the class PeopleController method query.

/**
 * 分页查询
 * @param pageNum
 * @param pageSize
 * @return
 */
@ResponseBody
@RequestMapping(value = "/queryPage", method = RequestMethod.GET)
public Object query(Integer pageNum, Integer pageSize) {
    pageNum = pageNum == null ? 1 : pageNum;
    pageSize = pageSize == null ? 10 : pageSize;
    pageSize = pageSize > 500 ? 500 : pageSize;
    try {
        OpenPage page = peopleService.queryPage(pageNum, pageSize);
        return responseSuccess("成功", page);
    } catch (Exception e) {
        logger.error("查询不成功", e);
        logger.error(getHeadsMap());
        logger.error(getParameterMap());
    }
    return responseFail("查询不成功");
}
Also used : OpenPage(org.tech.commons.OpenPage) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

OpenPage (org.tech.commons.OpenPage)2 Page (com.github.pagehelper.Page)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 People (org.tech.domain.People)1