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

fix: replyList接口优化

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