Search in sources :

Example 1 with UserEntity

use of com.myspringboot.entity.UserEntity in project springboot_op by SnailFastGo.

the class UserController method curPage.

@RequestMapping(value = "/curpage")
public List<UserEntity> curPage(int page) {
    UserEntity user = new UserEntity();
    user.setSize(2);
    user.setPage(page);
    user.setSort("desc");
    Sort.Direction direction = Sort.Direction.DESC;
    Sort sort = new Sort(direction, "name");
    PageRequest pageRequest = new PageRequest(user.getPage() - 1, user.getSize(), sort);
    List<UserEntity> res = userService.curPage(pageRequest);
    return res;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Sort(org.springframework.data.domain.Sort) UserEntity(com.myspringboot.entity.UserEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

UserEntity (com.myspringboot.entity.UserEntity)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1