From 6274dc4e151a0c75f1d73a3d6e2ad94a0b09f7e7 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Sun, 8 Sep 2024 19:02:43 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20=EC=8B=A0=EA=B3=A0=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=EC=97=90=20=EC=8B=A0=EA=B3=A0=20=EC=82=AC?= =?UTF-8?q?=EC=9C=A0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/entity/MissionPostCommentReport.java | 6 +++++- .../domain/farmclub/entity/MissionPostReport.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostCommentReport.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostCommentReport.java index 1423d1c..49cdf33 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostCommentReport.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostCommentReport.java @@ -22,6 +22,9 @@ public class MissionPostCommentReport { @Column(name = "mission_post_comment_report_id") private Long id; + @Column(name = "reason") + private String reason; + @OnDelete(action = OnDeleteAction.CASCADE) @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "mission_post_comment_id") @@ -31,10 +34,11 @@ public class MissionPostCommentReport { @JoinColumn(name = "user_id") private User user; - public static MissionPostCommentReport createMissionPostCommentReport(MissionPostComment missionPostComment, User user){ + public static MissionPostCommentReport createMissionPostCommentReport(MissionPostComment missionPostComment, User user, String reason){ MissionPostCommentReport report = MissionPostCommentReport.builder() .missionPostComment(missionPostComment) .user(user) + .reason(reason) .build(); missionPostComment.addReport(report); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostReport.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostReport.java index 3558ac1..e2a630b 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostReport.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostReport.java @@ -22,6 +22,9 @@ public class MissionPostReport { @Column(name = "mission_post_report_id") private Long id; + @Column(name = "reason") + private String reason; + @OnDelete(action = OnDeleteAction.CASCADE) @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "mission_post_id") @@ -31,10 +34,11 @@ public class MissionPostReport { @JoinColumn(name = "user_id") private User user; - public static MissionPostReport createMissionPostReport(MissionPost missionPost, User user){ + public static MissionPostReport createMissionPostReport(MissionPost missionPost, User user, String reason){ MissionPostReport report = MissionPostReport.builder() .missionPost(missionPost) .user(user) + .reason(reason) .build(); missionPost.addReport(report); From 876d80ec5629c0ecf3e785abc80e7e10f409539f Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Sun, 8 Sep 2024 19:03:08 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=20=EC=8B=A0=EA=B3=A0=20API=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EA=B0=92=EC=97=90=20=EC=82=AC=EC=9C=A0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmclub/controller/FarmClubController.java | 10 +++++----- .../CreateMissionPostCommentReportRequestDto.java | 7 +++++++ .../dto/req/CreateMissionPostReportRequestDto.java | 7 +++++++ .../farmclub/service/MissionPostService.java | 14 ++++++++------ 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostCommentReportRequestDto.java create mode 100644 src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostReportRequestDto.java diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java index 0b2fee7..d4e84da 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java @@ -181,21 +181,21 @@ public BaseResponseDto successFarmClub( return BaseResponseDto.of(SuccessCode.SUCCESS, farmClubService.successFarmClub(farmClubId, user.getUserId())); } - @PostMapping("/report/mission/{missionPostId}") + @PostMapping("/report/mission") public BaseResponseDto reportMissionPost( @AuthenticationPrincipal CustomUser user, - @PathVariable Long missionPostId + @RequestBody CreateMissionPostReportRequestDto requestDto ) { - missionPostService.reportMissionPost(user.getUserId(), missionPostId); + missionPostService.reportMissionPost(user.getUserId(), requestDto); return BaseResponseDto.of(SuccessCode.SUCCESS, null); } @PostMapping("/report/comment/{commentId}") public BaseResponseDto reportMissionPostComment( @AuthenticationPrincipal CustomUser user, - @PathVariable Long commentId + @RequestBody CreateMissionPostCommentReportRequestDto requestDto ) { - missionPostService.reportMissionPostComment(user.getUserId(), commentId); + missionPostService.reportMissionPostComment(user.getUserId(), requestDto); return BaseResponseDto.of(SuccessCode.SUCCESS, null); } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostCommentReportRequestDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostCommentReportRequestDto.java new file mode 100644 index 0000000..c610ee2 --- /dev/null +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostCommentReportRequestDto.java @@ -0,0 +1,7 @@ +package com.modernfarmer.farmusspring.domain.farmclub.dto.req; + +public record CreateMissionPostCommentReportRequestDto( + Long missionPostCommentId, + String reason +) { +} diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostReportRequestDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostReportRequestDto.java new file mode 100644 index 0000000..4ed8c61 --- /dev/null +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostReportRequestDto.java @@ -0,0 +1,7 @@ +package com.modernfarmer.farmusspring.domain.farmclub.dto.req; + +public record CreateMissionPostReportRequestDto( + Long missionPostId, + String reason +) { +} diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java index 1146935..1f55265 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java @@ -1,6 +1,8 @@ package com.modernfarmer.farmusspring.domain.farmclub.service; +import com.modernfarmer.farmusspring.domain.farmclub.dto.req.CreateMissionPostCommentReportRequestDto; import com.modernfarmer.farmusspring.domain.farmclub.dto.req.CreateMissionPostCommentRequestDto; +import com.modernfarmer.farmusspring.domain.farmclub.dto.req.CreateMissionPostReportRequestDto; import com.modernfarmer.farmusspring.domain.farmclub.dto.req.CreateMissionPostRequestDto; import com.modernfarmer.farmusspring.domain.farmclub.dto.res.*; import com.modernfarmer.farmusspring.domain.farmclub.entity.*; @@ -77,9 +79,9 @@ public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId } @Transactional - public void reportMissionPost(Long userId, Long missionPostId) { - MissionPost missionPost = missionPostHelper.getMissionPost(missionPostId); - MissionPostReport.createMissionPostReport(missionPost, userHelper.getUserEntity(userId)); + public void reportMissionPost(Long userId, CreateMissionPostReportRequestDto requestDto) { + MissionPost missionPost = missionPostHelper.getMissionPost(requestDto.missionPostId()); + MissionPostReport.createMissionPostReport(missionPost, userHelper.getUserEntity(userId), requestDto.reason()); int userCount = missionPost.getUserFarmClub().getFarmClub().getUserFarmClubs().size(); int reportCount = missionPost.getMissionPostReports().size(); if (userCount < 4 && reportCount >= 2) { @@ -90,9 +92,9 @@ public void reportMissionPost(Long userId, Long missionPostId) { } @Transactional - public void reportMissionPostComment(Long userId, Long missionPostCommentId) { - MissionPostComment missionPostComment = missionPostHelper.getMissionPostComment(missionPostCommentId); - MissionPostCommentReport.createMissionPostCommentReport(missionPostComment, userHelper.getUserEntity(userId)); + public void reportMissionPostComment(Long userId, CreateMissionPostCommentReportRequestDto requestDto) { + MissionPostComment missionPostComment = missionPostHelper.getMissionPostComment(requestDto.missionPostCommentId()); + MissionPostCommentReport.createMissionPostCommentReport(missionPostComment, userHelper.getUserEntity(userId), requestDto.reason()); int userCount = missionPostComment.getMissionPost().getUserFarmClub().getFarmClub().getUserFarmClubs().size(); int reportCount = missionPostComment.getMissionPostCommentReports().size(); if (userCount < 4 && reportCount >= 2) {