Commit 1c025291 by songyinghui

feature: 评论列表

parent 0c99e85d
......@@ -8,6 +8,7 @@ import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.comment.ListCommentDTO;
import com.gic.content.api.dto.comment.ListSonCommentDTO;
import com.gic.content.api.dto.comment.SonCommentInfoDTO;
import com.gic.content.api.enums.MaterialPurposeEnum;
import com.gic.content.api.enums.UserTypeEnum;
import com.gic.content.api.qdto.comment.ListMobileCommentQDTO;
......@@ -83,6 +84,21 @@ public class CommentController {
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
if (CollectionUtils.isEmpty(serviceResponse.getResult().getResult())) {
return RestResponse.successResult();
}
List<Long> contentMaterialCommentIds = serviceResponse.getResult().getResult().stream().map(ListCommentDTO::getContentMaterialCommentId).collect(Collectors.toList());
//获取子评论信息
ServiceResponse<Map<Long, SonCommentInfoDTO>> filterAuditStatusByContentMaterialCommentIds = contentMaterialCommentApiService.getFilterAuditStatusByContentMaterialCommentIds(mobileCommentQDTO, contentMaterialCommentIds);
Map<Long, SonCommentInfoDTO> sonCommentInfoDTOMap = filterAuditStatusByContentMaterialCommentIds.getResult();
serviceResponse.getResult().getResult().forEach(comment -> {
if (sonCommentInfoDTOMap.containsKey(comment.getContentMaterialCommentId())) {
SonCommentInfoDTO sonCommentInfoDTO = sonCommentInfoDTOMap.get(comment.getContentMaterialCommentId());
comment.setSonComments(ObjectUtil.isNotNull(sonCommentInfoDTO.getListSonCommentDTO()) ? Collections.singletonList(sonCommentInfoDTO.getListSonCommentDTO()) : new ArrayList<>());
comment.setSonCommentNum(sonCommentInfoDTO.getTotal());
}
});
Page<CommentInfoVO> commentInfoVOPage = PageHelperUtils.changePageToCurrentPage(serviceResponse.getResult(), CommentInfoVO.class);
return RestResponse.successResult(commentInfoVOPage);
}
......
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