Java Code Examples for org.springframework.data.web.PageableDefault

The following examples show how to use org.springframework.data.web.PageableDefault. These examples are extracted from open source projects. 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
@RequiresPermissions("ueboot:resources:read")
@PostMapping(value = "/page")
public Response<Page<ResourcesResp>> page(@PageableDefault(value = 15, sort = {"id"}, direction = Sort.Direction.ASC)
                                                  Pageable pageable, @RequestBody(required = false) ResourcesFindReq req) {
    Page<Resources> entities = null;
    if (req.getParentId() == null) {
        entities = resourcesService.findBy(pageable);
    } else {
        entities = resourcesService.findByParentId(pageable, req.getParentId());
    }
    Page<ResourcesResp> body = entities.map(entity -> {
        ResourcesResp resp = new ResourcesResp();
        BeanUtils.copyProperties(entity, resp);
        if (entity.getParent() != null) {
            resp.setParentId(entity.getParent().getId());
        }
        return resp;
    });

    return new Response<>(body);
}
 
Example 2
Source Project: spring-cloud-gray   Source File: ServiceOwnerResource.java    License: Apache License 2.0 6 votes vote down vote up
@ApiImplicitParams({
        @ApiImplicitParam(name = "serviceId", value = "服务id", dataType = "string"),
        @ApiImplicitParam(name = "queryItem", value = "查询项,{0:全部, 1:已绑定owner, 2:未绑定owner}", dataType = "int",
                defaultValue = "0", allowableValues = "0,1,2")})

@GetMapping(value = "/page")
public ResponseEntity<ApiRes<List<ServiceOwner>>> list(
        @RequestParam(value = "serviceId", required = false) String serviceId,
        @RequestParam(value = "queryItem", required = false) int queryItem,
        @ApiParam @PageableDefault(direction = Sort.Direction.DESC) Pageable pageable) {
    ServiceOwnerQuery query = ServiceOwnerQuery.builder()
            .serviceId(serviceId)
            .queryItem(queryItem)
            .build();
    Page<ServiceOwner> serviceOwnerPage = serviceManageModule.queryServiceOwners(query, pageable);
    HttpHeaders headers = PaginationUtils.generatePaginationHttpHeaders(serviceOwnerPage);
    ApiRes<List<ServiceOwner>> data = ApiRes.<List<ServiceOwner>>builder()
            .code(ApiRes.CODE_SUCCESS)
            .data(serviceOwnerPage.getContent())
            .build();
    return new ResponseEntity<>(
            data,
            headers,
            HttpStatus.OK);
}
 
Example 3
Source Project: spring-cloud-gray   Source File: OperateRecordResource.java    License: Apache License 2.0 6 votes vote down vote up
@GetMapping(value = "/page")
public ResponseEntity<ApiRes<List<OperateRecord>>> list(
        @Validated OperateQueryFO fo,
        @ApiParam @PageableDefault(sort = "operateTime", direction = Sort.Direction.DESC) Pageable pageable) {
    OperateQuery query = fo.toOperateQuery();
    Page<OperateRecord> operateRecordPage = operateAuditModule.queryRecords(query, pageable);
    HttpHeaders headers = PaginationUtils.generatePaginationHttpHeaders(operateRecordPage);
    ApiRes<List<OperateRecord>> data = ApiRes.<List<OperateRecord>>builder()
            .code(ApiRes.CODE_SUCCESS)
            .data(operateRecordPage.getContent())
            .build();
    return new ResponseEntity<>(
            data,
            headers,
            HttpStatus.OK);
}
 
Example 4
Source Project: spring-cloud-gray   Source File: UserResource.java    License: Apache License 2.0 6 votes vote down vote up
@GetMapping(value = "/page")
public ResponseEntity<ApiRes<List<UserInfo>>> page(
        @RequestParam(value = "key", required = false) String key,
        @RequestParam(value = "status", required = false) Integer status,
        @ApiParam @PageableDefault(sort = "createTime", direction = Sort.Direction.DESC) Pageable pageable) {

    UserQuery userQuery = UserQuery.builder()
            .key(key)
            .status(ObjectUtils.defaultIfNull(status, -1))
            .build();

    Page<UserInfo> userInfoPage = userModule.query(userQuery, pageable);
    HttpHeaders headers = PaginationUtils.generatePaginationHttpHeaders(userInfoPage);
    return new ResponseEntity<>(
            ApiResHelper.successData(userInfoPage.getContent()),
            headers,
            HttpStatus.OK);
}
 
Example 5
@GetMapping()
//    @ApiOperation(nickname = "get-all-posts", value = "Get all posts")
//    @ApiResponses(
//        value = {
//            @ApiResponse(code = 200, message = "return all posts by page")
//        }
//    )
    @JsonView(View.Summary.class)
    public ResponseEntity<Page<Post>> getAllPosts(
        @RequestParam(value = "q", required = false) String keyword, //
        @RequestParam(value = "status", required = false) Post.Status status, //
        @PageableDefault(page = 0, size = 10, sort = "createdDate", direction = Direction.DESC) Pageable page) {

        log.debug("get all posts of [email protected]" + keyword + ", status @" + status + ", [email protected]" + page);

        Page<Post> posts = this.postRepository.findAll(PostSpecifications.filterByKeywordAndStatus(keyword, status), page);

        return ok(posts);
    }
 
Example 6
Source Project: sk-admin   Source File: DictDetailController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("查询字典详情")
@ApiOperation("查询字典详情")
@GetMapping
public ResponseEntity<Object> getDictDetails(DictDetailQuery criteria,
                                             @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
    return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
}
 
Example 7
Source Project: sk-admin   Source File: DictDetailController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("查询多个字典详情")
@ApiOperation("查询多个字典详情")
@GetMapping(value = "/map")
public ResponseEntity<Object> getDictDetailMaps(DictDetailQuery criteria,
                                                @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
    String[] names = criteria.getDictName().split(",");
    Map<String,Object> map = new HashMap<>(names.length);
    for (String name : names) {
        criteria.setDictName(name);
        map.put(name,dictDetailService.queryAll(criteria,pageable).get("content"));
    }
    return new ResponseEntity<>(map,HttpStatus.OK);
}
 
Example 8
@ApiOperation(value = "查询集合", notes = "Article")
@GetMapping
public JsonData<Object> findArticleByCondition(Article article, String keyword, String sortType,
                                               @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    // 最热文章
    if (ArticleConst.SORT_TYPE_HOT.equals(sortType)) {
        List<Object> hotList = redisService.lGet("ARTICLE_HOT", 0, 10);
        return JsonData.success(hotList);
    }
    Page<Article> result = articleService.findArticleByCondition(article, keyword, pageable);
    return JsonData.success(result);
}
 
Example 9
@ApiOperation(value = "根据标签id查询文章", notes = "根据标签id查询文章")
@GetMapping("/tag/{tagId}")
public JsonData<Page<Article>> findArticleByTagId(@PathVariable String tagId,
                                                  @PageableDefault(sort = "create_at", direction = DESC) Pageable pageable) {
    Page<Article> result = articleService.findArticleByTagId(tagId, pageable);
    return JsonData.success(result);
}
 
Example 10
@ApiOperation(value = "查询标签集合", notes = "Article")
@GetMapping
public JsonData<List<Tags>> findArticleByCondition(Tags tags,
                                                   @PageableDefault(sort = "createAt", direction = DESC, value = 1000) Pageable pageable) {
    List<Tags> result = apiTagsService.findTagsByCondition(tags, pageable);
    return JsonData.success(result);
}
 
Example 11
@ApiOperation(value = "查询分类集合", notes = "Category")
@GetMapping
public JsonData<Page<Category>> findCategoryByCondition(Category category,
                                                                @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
 Page<Category> categoryByCondition = categoryService.findCategoryByCondition(category, pageable);
    return JsonData.success(categoryByCondition);
}
 
Example 12
@ApiOperation(value = "查询全部数据", notes = "id")
@GetMapping
public JsonData<Page<Category>> findCategoryByCondition(Category category,
                                                                @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Category> result = categoryService.findCategoryByCondition(category, pageable);
    return JsonData.success(result);
}
 
Example 13
@GetMapping()
@ApiOperation(value = "查询文章评论", notes = "Comment")
public JsonData<Page<Comment>> findCommentByCondition(Comment comment,
													 @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
	Page<Comment> result = commentService.findCommentByCondition(comment,pageable);
	return JsonData.success(result);
}
 
Example 14
@ApiOperation(value = "查询文章集合", notes = "Article")
@GetMapping
public JsonData<Page<Article>> findArticleByCondition(Article article,
                                                              @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Article> result = articleService.findArticleByCondition(article, pageable);
    return JsonData.success(result);
}
 
Example 15
@ApiOperation(value = "查询标签集合", notes = "tags")
@GetMapping
public JsonData<Page<Tags>> findArticleByCondition(Tags tags,
                                                   @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Tags> result = tagsService.findTagsByCondition(tags, pageable);
    return JsonData.success(result);
}
 
Example 16
@GetMapping
@ApiOperation(value = "按照条件查询全部列表", notes = "LoginLog")
public JsonData<Page<LoginLog>> findLoginLogByCondition(LoginLog loginLog,
                                                                @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<LoginLog> result = loginLogService.findLoginLogByCondition(loginLog, pageable);
    return JsonData.success(result);

}
 
Example 17
@GetMapping
@ApiOperation(value = "条件查询资源", notes = "Dict")
public JsonData<Page<Dict>> findResByCondition(Dict dict,
                                                       @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Dict> resData = dictService.findDictByCondition(dict, pageable);
    return JsonData.success(resData);
}
 
Example 18
@GetMapping
@ApiOperation(value = "按照条件查询全部列表", notes = "OptLog")
public JsonData<Page<OptLog>> findOptLogByCondition(OptLog optLog,
                                                            @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<OptLog> result = optLogService.findOptLogByCondition(optLog, pageable);
    return JsonData.success(result);

}
 
Example 19
Source Project: java-starthere   Source File: UserController.java    License: MIT License 5 votes vote down vote up
@ApiOperation(value = "returns all Users",
              response = User.class,
              responseContainer = "List")
@ApiImplicitParams({@ApiImplicitParam(name = "page",
                                      dataType = "integer",
                                      paramType = "query",
                                      value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size",
                                                                                                             dataType = "integer",
                                                                                                             paramType = "query",
                                                                                                             value = "Number of records per page."), @ApiImplicitParam(name = "sort",
                                                                                                                                                                       allowMultiple = true,
                                                                                                                                                                       dataType = "string",
                                                                                                                                                                       paramType = "query",
                                                                                                                                                                       value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.")})
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
@GetMapping(value = "/users",
            produces = {"application/json"})
public ResponseEntity<?> listAllUsers(HttpServletRequest request,
                                      @PageableDefault(page = 0,
                                                       size = 5)
                                              Pageable pageable)
{
    logger.trace(request.getMethod()
                        .toUpperCase() + " " + request.getRequestURI() + " accessed");

    List<User> myUsers = userService.findAll(pageable);
    return new ResponseEntity<>(myUsers,
                                HttpStatus.OK);
}
 
Example 20
Source Project: java-starthere   Source File: UserController.java    License: MIT License 5 votes vote down vote up
@ApiOperation(value = "returns all Users with names containing a given string",
              response = User.class,
              responseContainer = "List")
@ApiImplicitParams({@ApiImplicitParam(name = "page",
                                      dataType = "integer",
                                      paramType = "query",
                                      value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size",
                                                                                                             dataType = "integer",
                                                                                                             paramType = "query",
                                                                                                             value = "Number of records per page."), @ApiImplicitParam(name = "sort",
                                                                                                                                                                       allowMultiple = true,
                                                                                                                                                                       dataType = "string",
                                                                                                                                                                       paramType = "query",
                                                                                                                                                                       value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.")})
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
@GetMapping(value = "/user/name/like/{userName}",
            produces = {"application/json"})
public ResponseEntity<?> getUserLikeName(HttpServletRequest request,
                                         @PathVariable
                                                 String userName,
                                         @PageableDefault(page = 0,
                                                          size = 5)
                                                 Pageable pageable)
{
    logger.trace(request.getMethod()
                        .toUpperCase() + " " + request.getRequestURI() + " accessed");

    List<User> u = userService.findByNameContaining(userName,
                                                    pageable);
    return new ResponseEntity<>(u,
                                HttpStatus.OK);
}
 
Example 21
Source Project: yshopmall   Source File: DictDetailController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("查询字典详情")
@ApiOperation("查询字典详情")
@GetMapping
public ResponseEntity<Object> getDictDetails(DictDetailQueryCriteria criteria,
                                             @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
    return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
}
 
Example 22
Source Project: yshopmall   Source File: DictDetailController.java    License: Apache License 2.0 5 votes vote down vote up
@Log("查询多个字典详情")
@ApiOperation("查询多个字典详情")
@GetMapping(value = "/map")
public ResponseEntity<Object> getDictDetailMaps(DictDetailQueryCriteria criteria,
                                     @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
    String[] names = criteria.getDictName().split(",");
    Map<String,Object> map = new HashMap<>(names.length);
    for (String name : names) {
        criteria.setDictName(name);
        map.put(name,dictDetailService.queryAll(criteria,pageable).get("content"));
    }
    return new ResponseEntity<>(map,HttpStatus.OK);
}
 
Example 23
@ApiOperation(value = "查询集合", notes = "Article")
@GetMapping
public JsonData<Object> findArticleByCondition(Article article, String keyword, String sortType,
                                               @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    // 最热文章
    if (ArticleConst.SORT_TYPE_HOT.equals(sortType)) {
        List<Object> hotList = redisService.lGet("ARTICLE_HOT", 0, 10);
        return JsonData.success(hotList);
    }
    Page<Article> result = articleService.findArticleByCondition(article, keyword, pageable);
    return JsonData.success(result);
}
 
Example 24
@ApiOperation(value = "根据标签id查询文章", notes = "根据标签id查询文章")
@GetMapping("/tag/{tagId}")
public JsonData<Page<Article>> findArticleByTagId(@PathVariable String tagId,
                                                  @PageableDefault(sort = "create_at", direction = DESC) Pageable pageable) {
    Page<Article> result = articleService.findArticleByTagId(tagId, pageable);
    return JsonData.success(result);
}
 
Example 25
@ApiOperation(value = "查询标签集合", notes = "Article")
@GetMapping
public JsonData<List<Tags>> findArticleByCondition(Tags tags,
                                                   @PageableDefault(sort = "createAt", direction = DESC, value = 1000) Pageable pageable) {
    List<Tags> result = apiTagsService.findTagsByCondition(tags, pageable);
    return JsonData.success(result);
}
 
Example 26
@ApiOperation(value = "查询分类集合", notes = "Category")
@GetMapping
public JsonData<Page<Category>> findCategoryByCondition(Category category,
                                                                @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
 Page<Category> categoryByCondition = categoryService.findCategoryByCondition(category, pageable);
    return JsonData.success(categoryByCondition);
}
 
Example 27
@ApiOperation(value = "查询全部数据", notes = "id")
@GetMapping
public JsonData<Page<Category>> findCategoryByCondition(Category category,
                                                                @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Category> result = categoryService.findCategoryByCondition(category, pageable);
    return JsonData.success(result);
}
 
Example 28
@GetMapping()
@ApiOperation(value = "查询文章评论", notes = "Comment")
public JsonData<Page<Comment>> findCommentByCondition(Comment comment,
													 @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
	Page<Comment> result = commentService.findCommentByCondition(comment,pageable);
	return JsonData.success(result);
}
 
Example 29
@ApiOperation(value = "查询文章集合", notes = "Article")
@GetMapping
public JsonData<Page<Article>> findArticleByCondition(Article article,
                                                              @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Article> result = articleService.findArticleByCondition(article, pageable);
    return JsonData.success(result);
}
 
Example 30
@ApiOperation(value = "查询标签集合", notes = "tags")
@GetMapping
public JsonData<Page<Tags>> findArticleByCondition(Tags tags,
                                                   @PageableDefault(sort = "createAt", direction = DESC) Pageable pageable) {
    Page<Tags> result = tagsService.findTagsByCondition(tags, pageable);
    return JsonData.success(result);
}