Skip to content

Commit 97a6dc4

Browse files
authored
Merge pull request #93 from yyoonngg/chore/change-server
feat: report function
2 parents ff04a9a + 278dd05 commit 97a6dc4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/main/java/Devroup/hidaddy/service/ReportService.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ public ReportResponse reportPost(Long postId, User reporter) {
3434
throw new BadRequestException("자신의 게시글은 신고할 수 없습니다.");
3535
}
3636

37-
// 중복 신고 방지
37+
// 중복 신고 체크
3838
if (reportRepository.existsByReporterAndReportTypeAndTargetId(reporter, ReportType.POST, postId)) {
39-
throw new BadRequestException("이미 신고한 게시글입니다.");
39+
// 이미 신고한 경우, 에러가 아닌 정상 응답 반환 (UI 구분용)
40+
long totalReportCount = reportRepository.countByReportTypeAndTargetId(ReportType.POST, postId);
41+
return ReportResponse.builder()
42+
.reportId(null)
43+
.message("이미 신고한 게시글입니다.")
44+
.totalReportCount(totalReportCount)
45+
.build();
4046
}
4147

4248
// 신고 저장
@@ -76,9 +82,15 @@ public ReportResponse reportComment(Long postId, Long commentId, User reporter)
7682
throw new BadRequestException("자신의 댓글은 신고할 수 없습니다.");
7783
}
7884

79-
// 중복 신고 방지
85+
// 중복 신고 체크
8086
if (reportRepository.existsByReporterAndReportTypeAndTargetId(reporter, ReportType.COMMENT, commentId)) {
81-
throw new BadRequestException("이미 신고한 댓글입니다.");
87+
// 이미 신고한 경우, 에러가 아닌 정상 응답 반환 (UI 구분용)
88+
long totalReportCount = reportRepository.countByReportTypeAndTargetId(ReportType.COMMENT, commentId);
89+
return ReportResponse.builder()
90+
.reportId(null)
91+
.message("이미 신고한 댓글입니다.")
92+
.totalReportCount(totalReportCount)
93+
.build();
8294
}
8395

8496
// 신고 저장

0 commit comments

Comments
 (0)