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) {