From 713325c61e9f5cde4759b49b02f047db47b5b960 Mon Sep 17 00:00:00 2001 From: myhyun0002 Date: Thu, 9 Feb 2023 22:02:54 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20#98=20forum=20responsebody=EC=97=90=20c?= =?UTF-8?q?omment=5Fnum=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/dto/response/ForumResponseDto.java | 3 +++ .../example/umc3_teamproject/service/ForumService.java | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/umc3_teamproject/domain/dto/response/ForumResponseDto.java b/src/main/java/com/example/umc3_teamproject/domain/dto/response/ForumResponseDto.java index 56b818c..7d22759 100644 --- a/src/main/java/com/example/umc3_teamproject/domain/dto/response/ForumResponseDto.java +++ b/src/main/java/com/example/umc3_teamproject/domain/dto/response/ForumResponseDto.java @@ -40,6 +40,9 @@ public static class ForumDataToGetResult { @ApiParam(value = "해당 forum의 interview 수", required = false, example = "100") private int interview_num; + @ApiParam(value = "해당 forum의 comment 수", required = false, example = "100") + private int comment_num; + @ApiParam(value = "해당 forum의 이미지나 비디오 수", required = false, example = "100") private int image_video_num; diff --git a/src/main/java/com/example/umc3_teamproject/service/ForumService.java b/src/main/java/com/example/umc3_teamproject/service/ForumService.java index 9f2c3ee..6f89d36 100644 --- a/src/main/java/com/example/umc3_teamproject/service/ForumService.java +++ b/src/main/java/com/example/umc3_teamproject/service/ForumService.java @@ -111,7 +111,7 @@ public ResponseTemplate createForum(Long forumRepository.save(forum); return new ResponseTemplate<>(new ForumResponseDto.ForumDataToGetResult(forum.getMember().getId(),forum.getMember().getNickName(),forum.getId(), - forum.getTitle(),forum.getContent(),forum.getLike_num(),scriptIdToRequests.size(),interviewIdsToRequests.size(),postImages.size(), + forum.getTitle(),forum.getContent(),forum.getLike_num(),scriptIdToRequests.size(),interviewIdsToRequests.size(),0,postImages.size(), scriptIdToRequests,interviewIdsToRequests,postImages,forum.getCreatedDate(),forum.getModifiedDate())); } @@ -302,6 +302,7 @@ public ResponseTemplate updateForum(Long findForum.getMember().getNickName(),findForum.getId(),findForum.getTitle(),findForum.getContent(),findForum.getLike_num(), script_num, interview_num, + findForum.getComments().size(), findForum.getForumImages().size(), request.getScriptIds(), request.getInterviewIds(), @@ -386,6 +387,7 @@ public ResponseTemplate getForumByForumId forum.getLike_num(), forum.getForumScripts().size(), forum.getForumInterviews().size(), + forum.getComments().size(), forum.getForumImages().size(), forum.getForumScripts().stream().map( i -> new ForumRequestDto.ScriptIdsToRequest(i.getScript().getScriptId()) @@ -473,7 +475,7 @@ public ResponseTemplate> getSixForum private ResponseTemplate> getListFroumDataToGetResult(List forums) { List forumDataToGetResultRespons = forums.stream().map( s -> new ForumResponseDto.ForumDataToGetResult(s.getMember().getId(),s.getMember().getNickName(),s.getId(),s.getTitle(),s.getContent(),s.getLike_num(), - s.getForumScripts().size(),s.getForumInterviews().size(),s.getForumImages().size(), + s.getForumScripts().size(),s.getForumInterviews().size(),s.getComments().size(),s.getForumImages().size(), s.getForumScripts().stream().map(i -> new ForumRequestDto.ScriptIdsToRequest(i.getScript().getScriptId())).collect(Collectors.toList()), s.getForumInterviews().stream().map(i -> new ForumRequestDto.InterviewIdsToRequest(i.getInterview().getInterviewId())).collect(Collectors.toList()), s.getForumImages().stream().map(ForumImage::getImageUrl).collect(Collectors.toList()) @@ -485,7 +487,7 @@ private ResponseTemplate> getListFro private ResponsePageTemplate> getListFroumDataToPage(List forums,Pageable pageable,Long total_page) { List forumDataToGetResultRespons = forums.stream().map( s -> new ForumResponseDto.ForumDataToGetResult(s.getMember().getId(),s.getMember().getNickName(),s.getId(),s.getTitle(),s.getContent(),s.getLike_num(), - s.getForumScripts().size(),s.getForumInterviews().size(),s.getForumImages().size(), + s.getForumScripts().size(),s.getForumInterviews().size(),s.getComments().size(),s.getForumImages().size(), s.getForumScripts().stream().map(i -> new ForumRequestDto.ScriptIdsToRequest(i.getScript().getScriptId())).collect(Collectors.toList()), s.getForumInterviews().stream().map(i -> new ForumRequestDto.InterviewIdsToRequest(i.getInterview().getInterviewId())).collect(Collectors.toList()), s.getForumImages().stream().map(ForumImage::getImageUrl).collect(Collectors.toList())