Skip to content

Commit 8dcf3ec

Browse files
authored
feat : 유저 본인 신고 내역 조회, 운영자가 처리시 메세지 입력 가능 (#101)
1 parent 9e591ad commit 8dcf3ec

File tree

7 files changed

+62
-4
lines changed

7 files changed

+62
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.ezcode.codetest.application.report.dto;
2+
3+
import org.ezcode.codetest.domain.report.model.Report;
4+
5+
public record ReportMyResponse(
6+
Long id,
7+
Long targetId,
8+
String targetType,
9+
String reportType,
10+
String reportStatus,
11+
String message,
12+
String imageUrl,
13+
String resultMessage,
14+
String createdAt
15+
) {
16+
public static ReportMyResponse from(Report r) {
17+
return new ReportMyResponse(
18+
r.getId(),
19+
r.getTargetId(),
20+
r.getTargetType().name(),
21+
r.getReportType().name(),
22+
r.getReportStatus().name(),
23+
r.getMessage(),
24+
r.getImageUrl(),
25+
r.getResultMessage(),
26+
r.getCreatedAt().toString()
27+
);
28+
}
29+
}

src/main/java/org/ezcode/codetest/application/report/dto/ReportStatusUpdateRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
public record ReportStatusUpdateRequest(
77
@NotBlank
8-
String newStatus // 예시 RESOLVED(해결됨), REJECTED(거절)
8+
String newStatus, // 예시 RESOLVED(해결됨), REJECTED(거절)
9+
String resultMessage
910
) {
1011
public ReportStatus toEnum() {
1112
return ReportStatus.from(newStatus);

src/main/java/org/ezcode/codetest/application/report/service/ReportService.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import lombok.RequiredArgsConstructor;
1313

14+
import java.util.List;
15+
1416
@Service
1517
@RequiredArgsConstructor
1618
public class ReportService {
@@ -92,6 +94,14 @@ public void updateReportStatus(Long reportId, ReportStatusUpdateRequest req) {
9294
.orElseThrow(() -> new IllegalArgumentException("신고가 존재하지 않습니다."));
9395

9496
ReportStatus newStatus = req.toEnum();
95-
report.updateStatus(newStatus);
97+
report.updateStatus(newStatus, req.resultMessage());
9698
}
99+
100+
@Transactional(readOnly = true)
101+
public List<ReportMyResponse> getMyReports(Long userId) {
102+
return reportRepository.findByReporterIdOrderByCreatedAtDesc(userId).stream()
103+
.map(ReportMyResponse::from)
104+
.toList();
105+
}
106+
97107
}

src/main/java/org/ezcode/codetest/domain/report/model/Report.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public class Report extends BaseEntity {
3636
@Column(nullable = false, length = 50)
3737
private ReportType reportType;
3838

39+
@Column(length = 255)
40+
private String resultMessage; // 운영자가 남긴 처리 메시지
41+
42+
3943
@Column(nullable = false, length = 50)
4044
@Enumerated(EnumType.STRING)
4145
private ReportStatus reportStatus;
@@ -51,8 +55,9 @@ public Report(User reporter, Long targetId, ReportTargetType targetType,
5155
this.reportStatus = ReportStatus.PENDING;
5256
}
5357

54-
public void updateStatus(ReportStatus newStatus) {
58+
public void updateStatus(ReportStatus newStatus, String resultMessage) {
5559
this.reportStatus = newStatus;
60+
this.resultMessage = resultMessage;
5661
}
5762

5863
}

src/main/java/org/ezcode/codetest/domain/report/repository/ReportRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
import org.ezcode.codetest.domain.report.model.Report;
44
import org.springframework.data.jpa.repository.JpaRepository;
55

6+
import java.util.List;
7+
68
public interface ReportRepository extends JpaRepository<Report, Long> {
9+
List<Report> findByReporterIdOrderByCreatedAtDesc(Long reporterId);
710
}

src/main/java/org/ezcode/codetest/presentation/ranking/RankingController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.ezcode.codetest.presentation.ranking;
22

33
import lombok.RequiredArgsConstructor;
4-
import org.ezcode.codetest.application.ranking.dto.PointResponse;
54
import org.ezcode.codetest.application.ranking.dto.RankingResponse;
65
import org.ezcode.codetest.application.ranking.dto.TargetRankingResponse;
76
import org.ezcode.codetest.application.ranking.service.RankingFacadeService;

src/main/java/org/ezcode/codetest/presentation/report/ReportController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import jakarta.validation.Valid;
44
import lombok.RequiredArgsConstructor;
55
import lombok.extern.slf4j.Slf4j;
6+
import org.ezcode.codetest.application.report.dto.ReportMyResponse;
67
import org.ezcode.codetest.application.report.dto.ReportRequest;
78
import org.ezcode.codetest.application.report.dto.ReportResponse;
89
import org.ezcode.codetest.application.report.service.ReportService;
@@ -14,6 +15,8 @@
1415
import org.springframework.web.bind.annotation.RestController;
1516
import org.springframework.web.bind.annotation.*;
1617

18+
import java.util.List;
19+
1720
@Slf4j
1821
@RestController
1922
@RequiredArgsConstructor
@@ -30,4 +33,12 @@ public ResponseEntity<ReportResponse> report(
3033
return ResponseEntity.ok(reportService.submitReport(authUser.getId(), request));
3134
}
3235

36+
@GetMapping("/my")
37+
public ResponseEntity<List<ReportMyResponse>> myReports(
38+
@AuthenticationPrincipal AuthUser authUser
39+
) {
40+
return ResponseEntity.ok(reportService.getMyReports(authUser.getId()));
41+
}
42+
43+
3344
}

0 commit comments

Comments
 (0)