org.springframework.data.web.PageableDefault Java Examples
The following examples show how to use
org.springframework.data.web.PageableDefault.
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: PostController.java From spring-microservice-sample with GNU General Public License v3.0 | 6 votes |
@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 q@" + keyword + ", status @" + status + ", page@" + page); Page<Post> posts = this.postRepository.findAll(PostSpecifications.filterByKeywordAndStatus(keyword, status), page); return ok(posts); }
Example #2
Source File: UserResource.java From spring-cloud-gray with Apache License 2.0 | 6 votes |
@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 #3
Source File: ResourcesController.java From ueboot with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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 #4
Source File: ApiArticleController.java From codeway_service with GNU General Public License v3.0 | 6 votes |
@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 #5
Source File: OperateRecordResource.java From spring-cloud-gray with Apache License 2.0 | 6 votes |
@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 #6
Source File: JournalController.java From halo with GNU General Public License v3.0 | 5 votes |
@GetMapping @ApiOperation("Lists journals") public Page<JournalWithCmtCountDTO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable, JournalQuery journalQuery) { Page<Journal> journalPage = journalService.pageBy(journalQuery, pageable); return journalService.convertToCmtCountDto(journalPage); }
Example #7
Source File: PostController.java From halo with GNU General Public License v3.0 | 5 votes |
@GetMapping("status/{status}") @ApiOperation("Gets a page of post by post status") public Page<? extends BasePostSimpleDTO> pageByStatus(@PathVariable(name = "status") PostStatus status, @RequestParam(value = "more", required = false, defaultValue = "false") Boolean more, @PageableDefault(sort = "createTime", direction = DESC) Pageable pageable) { Page<Post> posts = postService.pageBy(status, pageable); if (more) { return postService.convertToListVo(posts); } return postService.convertToSimple(posts); }
Example #8
Source File: CategoryController.java From halo with GNU General Public License v3.0 | 5 votes |
@GetMapping("{slug}/posts") @ApiOperation("Lists posts by category slug") public Page<BasePostSimpleDTO> listPostsBy(@PathVariable("slug") String slug, @PageableDefault(sort = {"topPriority", "updateTime"}, direction = DESC) Pageable pageable) { // Get category by slug Category category = categoryService.getBySlugOfNonNull(slug); Page<Post> postPage = postCategoryService.pagePostBy(category.getId(), PostStatus.PUBLISHED, pageable); return postService.convertToSimple(postPage); }
Example #9
Source File: DictDetailController.java From sk-admin with Apache License 2.0 | 5 votes |
@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 #10
Source File: UserController.java From spring-microservice-sample with GNU General Public License v3.0 | 5 votes |
@GetMapping(value = "") public ResponseEntity getAll( @RequestParam(value = "q", required = false) String q, @RequestParam(value = "role", required = false) String role, @RequestParam(value = "active", required = false) String active, @PageableDefault(page = 0, size = 10, sort = "createdDate", direction = Sort.Direction.DESC) Pageable page) { Page<User> users = this.userRepository.findAll(UserSpecifications.byKeyword(q, role, active), page); return ok(users); }
Example #11
Source File: UserController.java From LazyREST with Apache License 2.0 | 5 votes |
/** * 分页查找 * * @param pageable * @return */ @RequestMapping("/list") public Page<UserEntity> list(@PageableDefault(sort = {"id"}, direction = Sort.Direction.DESC) Pageable pageable) { Page<UserEntity> users = userRepository.findAll(pageable); return users; }
Example #12
Source File: UserController.java From spring-glee-o-meter with GNU General Public License v3.0 | 5 votes |
@GetMapping Page<User> all(@PageableDefault(size = Integer.MAX_VALUE) Pageable pageable, OAuth2Authentication authentication) { String auth = (String) authentication.getUserAuthentication().getPrincipal(); String role = authentication.getAuthorities().iterator().next().getAuthority(); if (role.equals(User.Role.USER.name())) { return repository.findAllByEmail(auth, pageable); } return repository.findAll(pageable); }
Example #13
Source File: ContentFeedController.java From halo with GNU General Public License v3.0 | 5 votes |
/** * Get sitemap.html. * * @param model model * @return template path: common/web/sitemap_html */ @GetMapping(value = "sitemap.html") public String sitemapHtml(Model model, @PageableDefault(size = Integer.MAX_VALUE, sort = "createTime", direction = DESC) Pageable pageable) { model.addAttribute("posts", buildPosts(pageable)); return "common/web/sitemap_html"; }
Example #14
Source File: ContentFeedController.java From halo with GNU General Public License v3.0 | 5 votes |
/** * Get sitemap.xml. * * @param model model * @return sitemap xml content. * @throws IOException IOException * @throws TemplateException TemplateException */ @GetMapping(value = {"sitemap", "sitemap.xml"}, produces = XML_MEDIA_TYPE) @ResponseBody public String sitemapXml(Model model, @PageableDefault(size = Integer.MAX_VALUE, sort = "createTime", direction = DESC) Pageable pageable) throws IOException, TemplateException { model.addAttribute("posts", buildPosts(pageable)); Template template = freeMarker.getConfiguration().getTemplate("common/web/sitemap_xml.ftl"); return FreeMarkerTemplateUtils.processTemplateIntoString(template, model); }
Example #15
Source File: JournalCommentController.java From halo with GNU General Public License v3.0 | 5 votes |
@GetMapping @ApiOperation("Lists journal comments") public Page<JournalCommentWithJournalVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable, CommentQuery commentQuery) { Page<JournalComment> journalCommentPage = journalCommentService.pageBy(commentQuery, pageable); return journalCommentService.convertToWithJournalVo(journalCommentPage); }
Example #16
Source File: SheetCommentController.java From halo with GNU General Public License v3.0 | 5 votes |
@GetMapping @ApiOperation("Lists sheet comments") public Page<SheetCommentWithSheetVO> pageBy(@PageableDefault(sort = "createTime", direction = DESC) Pageable pageable, CommentQuery commentQuery) { Page<SheetComment> sheetCommentPage = sheetCommentService.pageBy(commentQuery, pageable); return sheetCommentService.convertToWithSheetVo(sheetCommentPage); }
Example #17
Source File: UserController.java From imooc-security with Apache License 2.0 | 5 votes |
@GetMapping() @JsonView(User.UserSimpleView.class) @ApiOperation(value = "查询用户") public List<User> query(UserQueryCondition condition, @PageableDefault(page=2,size=20,sort="age,asc") Pageable pageable){ System.out.println(ReflectionToStringBuilder.toString(condition, ToStringStyle.MULTI_LINE_STYLE)); System.out.println(pageable.getPageSize()); System.out.println(pageable.getPageNumber()); System.out.println(pageable.getSort()); List<User> users = new ArrayList<>(); users.add(new User()); users.add(new User()); users.add(new User()); return users; }
Example #18
Source File: EventController.java From eventapis with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/history", method = RequestMethod.GET) public ResponseEntity<ResponseDto> getTopicsHistory(@PageableDefault Pageable pageable) { try { ResponseDto responseDto = new ResponseDto(); responseDto.setOperations(operationsHistoryMap.entrySet()); return new ResponseEntity<>(responseDto, HttpStatus.OK); } catch (Exception e) { log.error(e.getMessage(), e); return ResponseEntity.status(500).build(); } }
Example #19
Source File: EventController.java From eventapis with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<Collection<Topology>> getOperations( @PageableDefault Pageable pageable ) throws IOException, EventStoreException { try { Collection<Topology> values = operationsMap.values( new PagingPredicate<>((Comparator<Map.Entry<String, Topology>> & Serializable) (o1, o2) -> -1 * Long.compare(o1.getValue().getStartTime(), o2.getValue().getStartTime()), pageable.getPageSize())); return new ResponseEntity<>(values, HttpStatus.OK); } catch (Exception e) { log.error(e.getMessage(), e); return ResponseEntity.status(500).build(); } }
Example #20
Source File: ServiceAuthorityResource.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@GetMapping(value = "/page") public ResponseEntity<ApiRes<List<UserServiceAuthority>>> list( @RequestParam("serviceId") String serviceId, @ApiParam @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { Page<UserServiceAuthority> serviceAuthorityPage = serviceManageModule.listServiceAuthorities(serviceId, pageable); HttpHeaders headers = PaginationUtils.generatePaginationHttpHeaders(serviceAuthorityPage); ApiRes<List<UserServiceAuthority>> data = ApiRes.<List<UserServiceAuthority>>builder() .code(ApiRes.CODE_SUCCESS) .data(serviceAuthorityPage.getContent()) .build(); return new ResponseEntity<>( data, headers, HttpStatus.OK); }
Example #21
Source File: GrayTrackResource.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@GetMapping(value = "/pageByService") public ResponseEntity<ApiRes<List<GrayTrack>>> pageByService( @RequestParam("serviceId") String serviceId, @ApiParam @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { Page<GrayTrack> page = grayServerTrackModule.listGrayTracks(serviceId, pageable); HttpHeaders headers = PaginationUtils.generatePaginationHttpHeaders(page); return new ResponseEntity<>( ApiRes.<List<GrayTrack>>builder() .code(CODE_SUCCESS) .data(page.getContent()) .build(), headers, HttpStatus.OK); }
Example #22
Source File: ApiTagsController.java From codeway_service with GNU General Public License v3.0 | 5 votes |
@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 #23
Source File: GrayServiceResource.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@GetMapping(value = "/page") public ResponseEntity<ApiRes<List<GrayService>>> list( @ApiParam @PageableDefault(direction = Sort.Direction.DESC) Pageable pageable) { Page<String> servicePage = serviceManageModule.listAllServiceIds(userModule.getCurrentUserId(), pageable); List<GrayService> grayServices = grayServerModule.findGrayServices(servicePage.getContent()); // Page<GrayService> page = grayServerModule.listAllGrayServices(pageable); HttpHeaders headers = PaginationUtils.generatePaginationHttpHeaders(servicePage); ApiRes<List<GrayService>> data = ApiRes.<List<GrayService>>builder().code("0").data(grayServices).build(); return new ResponseEntity<>( data, headers, HttpStatus.OK); }
Example #24
Source File: DictDetailController.java From sk-admin with Apache License 2.0 | 5 votes |
@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 #25
Source File: ServiceOwnerResource.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@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 #26
Source File: DictDetailController.java From eladmin with Apache License 2.0 | 5 votes |
@Log("查询字典详情") @ApiOperation("查询字典详情") @GetMapping public ResponseEntity<Object> query(DictDetailQueryCriteria criteria, @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){ return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); }
Example #27
Source File: MainController.java From ShadowSocks-Share with Apache License 2.0 | 5 votes |
/** * SSR 订阅地址 */ @RequestMapping("/subscribe") @ResponseBody public ResponseEntity<String> subscribe(boolean valid, @PageableDefault(page = 0, size = 1000, sort = {"id"}, direction = Sort.Direction.DESC) Pageable pageable) { List<ShadowSocksEntity> ssrList = shadowSocksSerivceImpl.findAll(pageable); return ResponseEntity.ok() .contentType(MediaType.TEXT_PLAIN) .body(shadowSocksSerivceImpl.toSSLink(ssrList, valid)); }
Example #28
Source File: MainController.java From ShadowSocks-Share with Apache License 2.0 | 5 votes |
/** * 首页 */ @RequestMapping("/") public String index(@PageableDefault(page = 0, size = 50, sort = {"id"}, direction = Sort.Direction.DESC) Pageable pageable, Model model) { List<ShadowSocksEntity> ssrList = shadowSocksSerivceImpl.findAll(pageable); List<ShadowSocksDetailsEntity> ssrdList = new ArrayList<>(); for (ShadowSocksEntity ssr : ssrList) { ssrdList.addAll(ssr.getShadowSocksSet()); } // ssr 信息 model.addAttribute("ssrList", ssrList); // ssr 明细信息,随机排序 Collections.shuffle(ssrdList); model.addAttribute("ssrdList", ssrdList); return "index"; }
Example #29
Source File: OrganizationController.java From ueboot with BSD 3-Clause "New" or "Revised" License | 5 votes |
@RequiresPermissions("ueboot:organization:read") @RequestMapping(value = "/page", method = RequestMethod.POST) public Response<Page<OrganizationResp>> page(@PageableDefault(value = 15, sort = { "id" }, direction = Sort.Direction.DESC) Pageable pageable, @RequestBody(required = false) OrganizationFindReq req){ Page<Organization> entities = organizationService.findBy(pageable); Page<OrganizationResp> body = entities.map(entity -> { OrganizationResp resp = new OrganizationResp(); BeanUtils.copyProperties(entity, resp); return resp; }); return new Response<>(body); }
Example #30
Source File: PostController.java From halo with GNU General Public License v3.0 | 5 votes |
@GetMapping @ApiOperation("Lists posts") public Page<? extends BasePostSimpleDTO> pageBy(@PageableDefault(sort = {"topPriority", "createTime"}, direction = DESC) Pageable pageable, PostQuery postQuery, @RequestParam(value = "more", defaultValue = "true") Boolean more) { Page<Post> postPage = postService.pageBy(postQuery, pageable); if (more) { return postService.convertToListVo(postPage); } return postService.convertToSimple(postPage); }