use of org.springframework.data.domain.Pageable in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method getStudyInsights.
@ApiOperation("Get recent Insights of Study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/insights", method = GET)
public List<SubmissionInsightDTO> getStudyInsights(@PathVariable("studyId") Long studyId, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "commentsPerInsight", required = false) Integer commentsPerInsight, @RequestParam(value = "order", required = false) Sort.Direction order) {
if (size == null) {
size = Integer.MAX_VALUE;
}
if (commentsPerInsight == null) {
commentsPerInsight = Integer.MAX_VALUE;
}
if (order == null) {
order = Sort.Direction.DESC;
}
List<SubmissionInsightDTO> submissionInsightDTOS = new ArrayList<>();
Pageable pageRequest = PageRequest.of(0, size, Sort.by(order, "created"));
final Page<SubmissionInsight> page = submissionInsightService.getInsightsByStudyId(studyId, pageRequest);
final List<SubmissionInsight> insights = page.getContent();
for (int i = 0; i < insights.size(); i++) {
final SubmissionInsight insight = insights.get(i);
final Set<CommentTopic> recentTopics = submissionInsightService.getInsightComments(insight, commentsPerInsight, Sort.by(Sort.Direction.DESC, "id"));
final SubmissionInsightDTO insightDTO = conversionService.convert(insight, SubmissionInsightDTO.class);
final List<Commentable> recentCommentables = getRecentCommentables(conversionService, recentTopics, insightDTO);
insightDTO.setRecentCommentEntities(recentCommentables);
submissionInsightDTOS.add(insightDTO);
}
if (LOG.isDebugEnabled()) {
submissionInsightDTOS.stream().forEach(submissionInsightDTO -> {
LOG.debug("+" + submissionInsightDTO.getName());
submissionInsightDTO.getRecentCommentEntities().stream().forEach(commentable -> {
LOG.debug("|+" + commentable.getName());
commentable.getTopic().getComments().stream().forEach(commentDTO -> {
LOG.debug(" |-" + commentDTO.getAuthor().getFirstname() + ":" + commentDTO.getDate() + ":" + commentDTO.getComment());
});
});
});
}
return submissionInsightDTOS;
}
use of org.springframework.data.domain.Pageable in project ArachneCentralAPI by OHDSI.
the class CommentServiceImpl method list.
@Override
public Set<CommentTopic> list(Set<CommentTopic> topics, Integer size, Sort sort) {
Pageable pageable = PageRequest.of(0, size, sort);
final Page<Comment> page = commentRepository.getAllByTopicIn(topics, pageable);
final List<Comment> comments = page.getContent();
comments.forEach(comment -> connectToTopic(topics, comment));
return comments.stream().map(Comment::getTopic).collect(Collectors.toCollection(LinkedHashSet::new));
}
use of org.springframework.data.domain.Pageable in project topcom-cloud by 545314690.
the class TjsEnforcementController method findByCompanyId.
@ApiOperation("根据企业id查找")
@RequestMapping(value = { "findByCompany" }, method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public Page<TjsEnforcement> findByCompanyId(@RequestParam Long companyId, @RequestParam Integer page, @RequestParam Integer limit, @RequestParam String startDate, @RequestParam String endDate) {
Pageable pageable = new PageRequest(page - 1, limit);
DateParam dateParam = new DateParam(startDate, endDate);
return tjsEnforcementManager.findByCompanyIdAndZFJCJZSJBetween(companyId, dateParam.startDate(), dateParam.endDate(), pageable);
}
use of org.springframework.data.domain.Pageable in project haha by hahafreeasair666.
the class NewsCommentServiceImpl method getNewsCommentList.
@Override
public PageVO<NewsCommentBO> getNewsCommentList(Integer newsId, Pageable pageable, Integer userId) {
Page<NewsCommentBO> allByNewsIdAndIsDel = newsCommentRepository.findAllByNewsIdAndIsDel(newsId, false, pageable);
List<NewsCommentBO> commentList = allByNewsIdAndIsDel.getContent();
commentList.forEach(li -> {
// 评论中评论的回复只显示未删除的点赞最多的三条
if (li.getReplies().size() > 3) {
li.setReplies(li.getReplies().stream().filter(de -> !de.getIsDel()).sorted(Comparator.comparing(NewsCommentBO.Reply::getZan).reversed()).collect(Collectors.toList()).subList(0, 3));
li.setIsNeedOpen(true);
} else {
li.setIsNeedOpen(false);
}
// 评论字段赋值
UserInfo userInfo = userInfoService.selectById(li.getUserId());
li.setUserName(userInfo.getUsername());
li.setAvatar(userInfo.getPicPath());
if (li.getZan() > 0 && userId != null) {
CommentZanBO zanInfo = commentZanRepository.findOne(li.getId());
if (zanInfo != null && zanInfo.getZanUserList().parallelStream().anyMatch(zan -> zan.equals(userId))) {
li.setIsPraised(true);
} else {
li.setIsPraised(false);
}
} else {
li.setIsPraised(false);
}
// 设置能否删除该评论字段
if (li.getUserId().equals(userId)) {
li.setIsCanDel(true);
} else {
li.setIsCanDel(false);
}
// 回复字段赋值
li.getReplies().forEach(re -> handleReplies(re, userId));
});
return new PageVO(allByNewsIdAndIsDel, pageable.getPageNumber(), commentList);
}
use of org.springframework.data.domain.Pageable in project topcom-cloud by 545314690.
the class SearchWordController method findByType.
/**
* 热词查询 查询排名前 limit 的word
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/findByType", produces = "application/json")
@ResponseBody
public List<SearchWord> findByType(@CurrentUser User user, @ApiParam("limit") @RequestParam(required = true) Integer limit, @ApiParam("type") @RequestParam(required = true) Integer type) {
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "wordCount"));
Pageable page = new PageRequest(0, limit, sort);
User user1 = this.userManager.findById(user.getId());
Set<Group> groups = user1.getGroups();
String groupId = SearchWord.groupIdBySet(groups);
List<String> groupIdList = new ArrayList<>();
groupIdList.add(groupId);
if (groupId.indexOf(",") != -1) {
String[] split = groupId.split(",");
for (String s : split) {
groupIdList.add(s);
}
}
Page<SearchWord> searchWords = this.searchWordManager.findByTypeAndGroupIdIn(page, type, groupIdList);
return filterNull(searchWords);
}
Aggregations