Commit 80594f69 by 阳浪

查看我的投稿接口

parent 2af2275a
package com.yizhi.training.application.controller;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.orm.id.IdGenerator;
......@@ -28,6 +29,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
......@@ -95,7 +97,68 @@ public class TpCommentController {
Page<PageCommentVo> page = iTpCommentService.getCommentPage(ContextHolder.get().getAccountId(),trainingProjectId, bizType, accountId, pageNo, pageSize, type);
String fullName;
String name;
if(page==null|| CollUtil.isEmpty(page.getRecords())){
return page;
}
List<Long> ids = page.getRecords().stream().map(PageCommentVo::getId).collect(Collectors.toList());
TpCommentReply reply = new TpCommentReply();
if (type != 0) {
reply.setState(0);
}
reply.setAuditStatus("0");
EntityWrapper<TpCommentReply> wrapper = new EntityWrapper<TpCommentReply>(reply);
List<String> list = new ArrayList<String>();
list.add("createTime");
wrapper.in("tp_comment_id",ids);
wrapper.orderDesc(list);
List<TpCommentReply> replies = iTpCommentReplyService.selectList(wrapper);
Map<Long, List<TpCommentReply>> listMap = new HashMap<>();
for (TpCommentReply revert : replies) {
revert.setContent(StringEscapeUtils.unescapeJava(revert.getContent()));
if (listMap.containsKey(revert.getTpCommentId())) {
listMap.get(revert.getTpCommentId()).add(revert);
} else {
List<TpCommentReply> repliesResult = new ArrayList<>();
repliesResult.add(revert);
listMap.put(revert.getTpCommentId(), repliesResult);
}
if (null != revert.getReplyParentId() && 0 != revert.getReplyParentId()) {
TpCommentReply reply2 = iTpCommentReplyService.selectById(revert.getReplyParentId());
if (null != reply2) {
AccountVO findById = accountClient.findById(reply2.getCreateById());
revert.setParentAccountFullName(null == findById.getFullName() || "" == findById.getFullName() ? findById.getName() : findById.getFullName());
} else {
AccountVO findById = accountClient.findById(iTpCommentService.selectById(revert.getTpCommentId()).getCreateById());
revert.setParentAccountFullName(null == findById.getFullName() || "" == findById.getFullName() ? findById.getName() : findById.getFullName());
}
} else {
AccountVO findById = accountClient.findById(iTpCommentService.selectById(revert.getTpCommentId()).getCreateById());
revert.setParentAccountFullName(null == findById.getFullName() || "" == findById.getFullName() ? findById.getName() : findById.getFullName());
}
AccountVO accountVO = accountClient.findById(revert.getCreateById());
fullName = accountVO.getFullName();
name = accountVO.getName();
revert.setCreateByName(name);
revert.setCreateByFullName(null == fullName || "" == fullName ? name : fullName);
}
for (PageCommentVo listCommentVo : page.getRecords()) {
List<TpCommentReply> list1 = listMap.get(listCommentVo.getId());
List<TpCommentReplyVo> list2 = new ArrayList<>();
if (!CollectionUtils.isEmpty(list1)) {
for (TpCommentReply tr : list1
) {
TpCommentReplyVo trv=new TpCommentReplyVo();
BeanUtils.copyProperties(tr,trv);
list2.add(trv);
}
}
listCommentVo.setContent(StringEscapeUtils.unescapeJava(listCommentVo.getContent()));
if (listMap.containsKey(listCommentVo.getId())) {
listCommentVo.setTpCommentReplies(list2);
listCommentVo.setReplys(listMap.get(listCommentVo.getId()).size());
}
listCommentVo.setContent(StringEscapeUtils.unescapeJava(listCommentVo.getContent()));
AccountVO accountVO = accountClient.findById(listCommentVo.getAccountId());
fullName = accountVO.getFullName();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment