diff --git a/src/main/java/com/DecodEat/domain/report/controller/ReportController.java b/src/main/java/com/DecodEat/domain/report/controller/ReportController.java index 9f32e64..9c53738 100644 --- a/src/main/java/com/DecodEat/domain/report/controller/ReportController.java +++ b/src/main/java/com/DecodEat/domain/report/controller/ReportController.java @@ -49,6 +49,7 @@ public ApiResponse requestCheckImage(@CurrentUser User user, summary = "상품 수정 요청 조회 (관리자)", description = "관리자가 모든 상품 정보 수정 요청을 페이지별로 조회합니다. 영양 정보 수정과 이미지 확인 요청을 모두 포함합니다.") @Parameters({ + // @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정 @Parameter(name = "page", description = "페이지 번호, 0부터 시작합니다.", example = "0"), @Parameter(name = "size", description = "한 페이지에 보여줄 항목 수", example = "10") }) @@ -59,4 +60,14 @@ public ApiResponse getReports( ) { return ApiResponse.onSuccess(reportService.getReports(page, size)); } + + @Operation( + summary = "상품 수정 요청 거절 (관리자)", + description = "관리자가 상품 정보 수정 요청을 거절합니다. 해당 신고 내역의 상태를 REJECTED로 변경합니다.") + @Parameter(name = "reportId", description = "거절할 신고의 ID", example = "1") + // @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정 + @PatchMapping("/{reportId}/reject") + public ApiResponse rejectReport(@PathVariable Long reportId) { + return ApiResponse.onSuccess(reportService.rejectReport(reportId)); + } } diff --git a/src/main/java/com/DecodEat/domain/report/entity/ReportRecord.java b/src/main/java/com/DecodEat/domain/report/entity/ReportRecord.java index 219625d..aa59371 100644 --- a/src/main/java/com/DecodEat/domain/report/entity/ReportRecord.java +++ b/src/main/java/com/DecodEat/domain/report/entity/ReportRecord.java @@ -9,6 +9,7 @@ @Entity @Getter +@Setter @SuperBuilder // 자식 클래스에서 부모 클래스 필드까지 빌드(컴파일 시점에) <-> @Builder @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) // 서비스 코드 등 다른 곳에서 의미 없는 빈 객체를 실수로 생성하는 것 예방 diff --git a/src/main/java/com/DecodEat/domain/report/entity/ReportStatus.java b/src/main/java/com/DecodEat/domain/report/entity/ReportStatus.java index 529c101..4c9ca0c 100644 --- a/src/main/java/com/DecodEat/domain/report/entity/ReportStatus.java +++ b/src/main/java/com/DecodEat/domain/report/entity/ReportStatus.java @@ -1,7 +1,7 @@ package com.DecodEat.domain.report.entity; public enum ReportStatus { - IN_PROGRESS, - UPDATED, - CHECKED + IN_PROGRESS, // 대기 + ACCEPTED, // 수락 + REJECTED // 거절 } diff --git a/src/main/java/com/DecodEat/domain/report/service/ReportService.java b/src/main/java/com/DecodEat/domain/report/service/ReportService.java index b99e9a8..b66e5c9 100644 --- a/src/main/java/com/DecodEat/domain/report/service/ReportService.java +++ b/src/main/java/com/DecodEat/domain/report/service/ReportService.java @@ -6,6 +6,8 @@ import com.DecodEat.domain.report.dto.request.ProductNutritionUpdateRequestDto; import com.DecodEat.domain.report.dto.response.ReportResponseDto; import com.DecodEat.domain.report.entity.ReportRecord; +import com.DecodEat.domain.report.entity.ReportStatus; +import com.DecodEat.domain.report.entity.ReportRecord; import com.DecodEat.domain.report.repository.ImageReportRepository; import com.DecodEat.domain.report.repository.NutritionReportRepository; import com.DecodEat.domain.report.repository.ReportRecordRepository; @@ -55,4 +57,20 @@ public ReportResponseDto.ReportListResponseDTO getReports(int page, int size) { return ReportConverter.toReportListResponseDTO(reportPage); } + /** + * 상품 수정 신고 요청 거절 + * @param reportId 거절할 신고의 ID + * @return 처리 결과를 담은 DTO + */ + public ReportResponseDto rejectReport(Long reportId){ + // 1. ID로 신고 내역 조회 + ReportRecord reportRecord = reportRecordRepository.findById(reportId) + .orElseThrow(() -> new GeneralException(REPORT_NOT_FOUND)); + + // 2. reportstatus 상태를 rejected로 변경 + reportRecord.setReportStatus(ReportStatus.REJECTED); + + // 3. DTO 반환 + return ReportConverter.toReportResponseDto(reportRecord.getProduct().getProductId(), "신고 요청이 거절 처리되었습니다."); + } } diff --git a/src/main/java/com/DecodEat/global/apiPayload/code/status/ErrorStatus.java b/src/main/java/com/DecodEat/global/apiPayload/code/status/ErrorStatus.java index ad01464..8cad1d8 100644 --- a/src/main/java/com/DecodEat/global/apiPayload/code/status/ErrorStatus.java +++ b/src/main/java/com/DecodEat/global/apiPayload/code/status/ErrorStatus.java @@ -36,7 +36,10 @@ public enum ErrorStatus implements BaseErrorCode { DUPLICATE_UNIQUE_KEY(HttpStatus.CONFLICT, "COMMON_005", "이미 처리된 요청입니다."), // s3 사진 첨부 에러 - FILE_UPLOAD_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "FILE_001", "파일 업로드에 실패했습니다."); + FILE_UPLOAD_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "FILE_001", "파일 업로드에 실패했습니다."), + + // 신고 + REPORT_NOT_FOUND(HttpStatus.NOT_FOUND, "REPONT_401", "존재하지 않는 신고 내역 입니다."); private final HttpStatus httpStatus; private final String code; diff --git a/src/main/java/com/DecodEat/global/config/oauth/OAuth2SuccessHandler.java b/src/main/java/com/DecodEat/global/config/oauth/OAuth2SuccessHandler.java index a90d6e0..dab927b 100644 --- a/src/main/java/com/DecodEat/global/config/oauth/OAuth2SuccessHandler.java +++ b/src/main/java/com/DecodEat/global/config/oauth/OAuth2SuccessHandler.java @@ -94,7 +94,8 @@ private void clearAuthenticationAttributes(HttpServletRequest request, HttpServl // 액세스 토큰을 리다이렉트 경로에 파라미터로 추가 private String getTargetUrl(String token) { - return UriComponentsBuilder.fromUriString("https://decodeat.netlify.app") //todo:로그인 후 스웨거화면 + return UriComponentsBuilder.fromUriString("/decodeat.store") //todo:로그인 후 스웨거화면 + .queryParam("token", token) .build() .toUriString(); }