提交 1a9e474e 编写于 作者: minghao.wu's avatar minghao.wu

fix: replyList接口优化

上级 a7c0d6cd
流水线 #3587 已通过 于阶段
in 10 second
......@@ -187,8 +187,11 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
ExamTitleReplyDto examTitleReplyDto = new ExamTitleReplyDto();
ExamTitleDto examTitleDto = getExamTitleDtoById(examTitleId);
List<ReplyDto> replyDtoList = getReplyListDtoByExamTitleId(examTitleId, user != null ? user.getId() : 0);
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
List<ReplyDto> replyDtoList = getReplyListDtoByExamTitleId(analysisRound, examTitleId, user != null ? user.getId() : 0);
/**
* 如果是PSA 删除回复的时间显示
*/
......@@ -202,8 +205,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
examTitleReplyDto.setReplyList(replyDtoList);
examTitleReplyDto.setType(analysis.getType().intValue());
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
/**
* 设置回复状态
*/
......@@ -223,7 +224,11 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
ExamTitleReplyDto examTitleReplyDto = new ExamTitleReplyDto();
ExamTitleDto examTitleDto = getExamTitleDtoById(examTitleId);
List<ReplyDto> replyDtoList = getReplyListDtoByExamTitleId(examTitleId, user != null ? user.getId() : 0);
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
List<ReplyDto> replyDtoList = getReplyListDtoByExamTitleId(analysisRound, examTitleId, user != null ? user.getId() : 0);
/**
* 分页 pageNo: 1,2,...
......@@ -251,8 +256,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
examTitleReplyDto.setReplyList(replyDtoList);
examTitleReplyDto.setType(analysis.getType().intValue());
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
/**
* 设置回复状态
*/
......@@ -281,8 +284,11 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
Reply reply = replyMapper.selectByPrimaryKey(replyId);
AnalysisRoundExamTitle analysisRoundExamTitle = analysisRoundExamTitleMapper.selectByPrimaryKey(reply.getAnalysisRoundExamTitleId());
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDetailDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
ExamTitleDto examTitleDto = getExamTitleDtoById(reply.getAnalysisRoundExamTitleId());
ReplyDto replyDto = getReplyDtoByReply(reply, user != null ? user.getId() : 0);
ReplyDto replyDto = getReplyDtoByReply(analysisRound, reply, user != null ? user.getId() : 0);
CHCAnalysis analysis = analysisMapper.selectByPrimaryKey(analysisRoundExamTitle.getAnalysisId());
......@@ -292,8 +298,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
examTitleReplyDetailDto.setReply(replyDto);
examTitleReplyDetailDto.setType(analysis.getType().intValue());
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDetailDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
/**
* 设置回复状态
*/
......@@ -320,9 +324,12 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
AnalysisRoundExamTitle analysisRoundExamTitle = analysisRoundExamTitleMapper.selectByPrimaryKey(examTitleId);
ExamTitleDto examTitleDto = getExamTitleDtoById(examTitleId);
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDetailDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
ReplyDto replyDto = new ReplyDto();
if (null != reply) {
replyDto = getReplyDtoByReply(reply, user != null ? user.getId() : 0);
replyDto = getReplyDtoByReply(analysisRound, reply, user != null ? user.getId() : 0);
} else {
replyDto.setContent("");
}
......@@ -331,8 +338,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
examTitleReplyDetailDto.setExamTitle(examTitleDto);
examTitleReplyDetailDto.setReply(replyDto);
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
examTitleReplyDetailDto.setPublished(analysisRound.getIsPublished() ? 1 : 0);
CHCAnalysis analysis = analysisMapper.selectByPrimaryKey(analysisRoundExamTitle.getAnalysisId());
examTitleReplyDetailDto.setType(analysis.getType().intValue());
......@@ -650,7 +655,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return examTitleDto;
}
private List<ReplyDto> getReplyListDtoByExamTitleId(Integer analysisRoundExamTitleId, Integer userId) {
private List<ReplyDto> getReplyListDtoByExamTitleId(AnalysisRound round, Integer analysisRoundExamTitleId, Integer userId) {
List<Reply> replyList = getReplyList(analysisRoundExamTitleId);
List<ReplyDto> replyDtoList = new ArrayList<>();
......@@ -660,7 +665,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
/**
* 发现有评论用户不在p_doctor的情况,数据不同步造成的
*/
replyDtoList.add(getReplyDtoByReply(reply, userId));
replyDtoList.add(getReplyDtoByReply(round, reply, userId));
} catch (Exception e) {
// logger.error("getReplyListDtoByExamTitleId", e);
}
......@@ -693,7 +698,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return replyList.get(idx);
}
private ReplyDto getReplyDtoByReply(Reply reply, Integer userId) {
private ReplyDto getReplyDtoByReply(AnalysisRound round, Reply reply, Integer userId) {
ReplyDto replyDto = new ReplyDto();
Doctor doctor = doctorMapper.selectByPrimaryKey(reply.getUserId());
......@@ -710,10 +715,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
replyDto.setReplayTime(DateUtils.fromNow(reply.getModifiedTime()));
replyDto.setStarCount(starRecordMapper.selectStarCountByReplyId(reply.getId()));
AnalysisRoundExamTitle analysisRoundExamTitle = analysisRoundExamTitleMapper.selectByPrimaryKey(reply.getAnalysisRoundExamTitleId());
AnalysisRound analysisRound = analysisRoundMapper.selectByPrimaryKey(analysisRoundExamTitle.getRoundId());
if ((new Date()).getTime() > analysisRound.getEndTime().getTime()) {
if ((new Date()).getTime() > round.getEndTime().getTime()) {
replyDto.setStatus(2);
} else {
StarRecord starRecord = new StarRecord();
......@@ -853,6 +855,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
* case 1. 按照时间排序,如果个数小于5,直接返回
*/
List<Reply> replyList = replyMapper.selectReplyListOrderByTime(examTitleId);
if (replyCount < 5) {
return replyList;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册