@RequestMapping(method = RequestMethod.GET) @ResponseBody public String page(@RequestParam(required = false) String q, PageParam pageParam) { List<SearchFilter> filters = StringUtils.isEmpty(q) ? new ArrayList<SearchFilter>() : SearchFilter.parseQuery(q); filters.add(new SearchFilter("creator.id", Operator.EQ, currentUserId())); filters.add(new SearchFilter("status", Operator.EQ, Share.Status.CREATED)); Page<Share> page = shareService2.findAll(filters, pageParam.getPageable(Share.class)); return Gsons.filterByFields(ShareDto.Brief.class, pageParam.getFields()) .toJson(PageDto.of(page, ShareDto.toBrief)); }
/** * 搜索我搜到的分享 * * @param q * @param pageParam * @return */ @RequestMapping(value = "/received", method = RequestMethod.GET) @ResponseBody public String pageReceived(@RequestParam(required = false) String q, PageParam pageParam) { List<SearchFilter> filters = StringUtils.isEmpty(q) ? new ArrayList<SearchFilter>() : SearchFilter.parseQuery(q); filters.add(new SearchFilter("recipient.id", Operator.EQ, currentUserId())); filters.add(new SearchFilter("isDeleted", Operator.EQ, Boolean.FALSE)); filters.add(new SearchFilter("share.status", Operator.NE, Share.Status.CANCELED)); Page<ReceivedShare> page = receivedShareService.findAll(filters, pageParam.getPageable(ReceivedShare.class)); return Gsons.filterByFields(ReceivedShareDto.Brief.class, pageParam.getFields()) .toJson(PageDto.of(page, ReceivedShareDto.toBrief)); }
@RequestMapping(value = "search", method = RequestMethod.GET) @ResponseBody public String search( @RequestParam("recipientType") String recipientType, @RequestParam(required = false) Long recipientId, PageParam pageParam) { Pageable pageable = pageParam.getPageable(Share.class); Page<Share> page = null; if (recipientId == null) { page = shareService2.findAll(currentUserId(), recipientType, pageable); } else { page = shareService2.findAll(currentUserId(), recipientType, recipientId, pageable); } return Gsons.filterByFields(ShareDto.Brief.class, pageParam.getFields()) .toJson(PageDto.of(page, ShareDto.toBrief)); }