Skip to content

Commit

Permalink
[fix] 신고 API 요청값에 사유 추가하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchoGreenT committed Sep 8, 2024
1 parent 6274dc4 commit 876d80e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.modernfarmer.farmusspring.domain.farmclub.dto.req;

public record CreateMissionPostCommentReportRequestDto(
Long missionPostCommentId,
String reason
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.modernfarmer.farmusspring.domain.farmclub.dto.req;

public record CreateMissionPostReportRequestDto(
Long missionPostId,
String reason
) {
}
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 876d80e

Please sign in to comment.