Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.ezcode.codetest.application.report.dto;

import org.ezcode.codetest.domain.report.model.Report;

public record ReportMyResponse(
Long id,
Long targetId,
String targetType,
String reportType,
String reportStatus,
String message,
String imageUrl,
String resultMessage,
String createdAt
) {
public static ReportMyResponse from(Report r) {
return new ReportMyResponse(
r.getId(),
r.getTargetId(),
r.getTargetType().name(),
r.getReportType().name(),
r.getReportStatus().name(),
r.getMessage(),
r.getImageUrl(),
r.getResultMessage(),
r.getCreatedAt().toString()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

public record ReportStatusUpdateRequest(
@NotBlank
String newStatus // 예시 RESOLVED(해결됨), REJECTED(거절)
String newStatus, // 예시 RESOLVED(해결됨), REJECTED(거절)
String resultMessage
) {
public ReportStatus toEnum() {
return ReportStatus.from(newStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import lombok.RequiredArgsConstructor;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ReportService {
Expand Down Expand Up @@ -92,6 +94,14 @@ public void updateReportStatus(Long reportId, ReportStatusUpdateRequest req) {
.orElseThrow(() -> new IllegalArgumentException("신고가 존재하지 않습니다."));

ReportStatus newStatus = req.toEnum();
report.updateStatus(newStatus);
report.updateStatus(newStatus, req.resultMessage());
}

@Transactional(readOnly = true)
public List<ReportMyResponse> getMyReports(Long userId) {
return reportRepository.findByReporterIdOrderByCreatedAtDesc(userId).stream()
.map(ReportMyResponse::from)
.toList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class Report extends BaseEntity {
@Column(nullable = false, length = 50)
private ReportType reportType;

@Column(length = 255)
private String resultMessage; // 운영자가 남긴 처리 메시지


@Column(nullable = false, length = 50)
@Enumerated(EnumType.STRING)
private ReportStatus reportStatus;
Expand All @@ -51,8 +55,9 @@ public Report(User reporter, Long targetId, ReportTargetType targetType,
this.reportStatus = ReportStatus.PENDING;
}

public void updateStatus(ReportStatus newStatus) {
public void updateStatus(ReportStatus newStatus, String resultMessage) {
this.reportStatus = newStatus;
this.resultMessage = resultMessage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
import org.ezcode.codetest.domain.report.model.Report;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface ReportRepository extends JpaRepository<Report, Long> {
List<Report> findByReporterIdOrderByCreatedAtDesc(Long reporterId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.ezcode.codetest.presentation.ranking;

import lombok.RequiredArgsConstructor;
import org.ezcode.codetest.application.ranking.dto.PointResponse;
import org.ezcode.codetest.application.ranking.dto.RankingResponse;
import org.ezcode.codetest.application.ranking.dto.TargetRankingResponse;
import org.ezcode.codetest.application.ranking.service.RankingFacadeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.ezcode.codetest.application.report.dto.ReportMyResponse;
import org.ezcode.codetest.application.report.dto.ReportRequest;
import org.ezcode.codetest.application.report.dto.ReportResponse;
import org.ezcode.codetest.application.report.service.ReportService;
Expand All @@ -14,6 +15,8 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
Expand All @@ -30,4 +33,12 @@ public ResponseEntity<ReportResponse> report(
return ResponseEntity.ok(reportService.submitReport(authUser.getId(), request));
}

@GetMapping("/my")
public ResponseEntity<List<ReportMyResponse>> myReports(
@AuthenticationPrincipal AuthUser authUser
) {
return ResponseEntity.ok(reportService.getMyReports(authUser.getId()));
}


}