Skip to content

Commit 3ed505d

Browse files
authored
Merge pull request #32 from Decodeat/Feat/#24
[Feat] 관리자용 상품 수정 요청 거절 API 구현
2 parents c67f9a6 + 6a75ace commit 3ed505d

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

src/main/java/com/DecodEat/domain/report/controller/ReportController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public ApiResponse<ReportResponseDto> requestCheckImage(@CurrentUser User user,
4949
summary = "상품 수정 요청 조회 (관리자)",
5050
description = "관리자가 모든 상품 정보 수정 요청을 페이지별로 조회합니다. 영양 정보 수정과 이미지 확인 요청을 모두 포함합니다.")
5151
@Parameters({
52+
// @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정
5253
@Parameter(name = "page", description = "페이지 번호, 0부터 시작합니다.", example = "0"),
5354
@Parameter(name = "size", description = "한 페이지에 보여줄 항목 수", example = "10")
5455
})
@@ -59,4 +60,14 @@ public ApiResponse<ReportResponseDto.ReportListResponseDTO> getReports(
5960
) {
6061
return ApiResponse.onSuccess(reportService.getReports(page, size));
6162
}
63+
64+
@Operation(
65+
summary = "상품 수정 요청 거절 (관리자)",
66+
description = "관리자가 상품 정보 수정 요청을 거절합니다. 해당 신고 내역의 상태를 REJECTED로 변경합니다.")
67+
@Parameter(name = "reportId", description = "거절할 신고의 ID", example = "1")
68+
// @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정
69+
@PatchMapping("/{reportId}/reject")
70+
public ApiResponse<ReportResponseDto> rejectReport(@PathVariable Long reportId) {
71+
return ApiResponse.onSuccess(reportService.rejectReport(reportId));
72+
}
6273
}

src/main/java/com/DecodEat/domain/report/entity/ReportRecord.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@Entity
1111
@Getter
12+
@Setter
1213
@SuperBuilder // 자식 클래스에서 부모 클래스 필드까지 빌드(컴파일 시점에) <-> @Builder
1314
@AllArgsConstructor
1415
@NoArgsConstructor(access = AccessLevel.PROTECTED) // 서비스 코드 등 다른 곳에서 의미 없는 빈 객체를 실수로 생성하는 것 예방
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.DecodEat.domain.report.entity;
22

33
public enum ReportStatus {
4-
IN_PROGRESS,
5-
UPDATED,
6-
CHECKED
4+
IN_PROGRESS, // 대기
5+
ACCEPTED, // 수락
6+
REJECTED // 거절
77
}

src/main/java/com/DecodEat/domain/report/service/ReportService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import com.DecodEat.domain.report.dto.request.ProductNutritionUpdateRequestDto;
77
import com.DecodEat.domain.report.dto.response.ReportResponseDto;
88
import com.DecodEat.domain.report.entity.ReportRecord;
9+
import com.DecodEat.domain.report.entity.ReportStatus;
10+
import com.DecodEat.domain.report.entity.ReportRecord;
911
import com.DecodEat.domain.report.repository.ImageReportRepository;
1012
import com.DecodEat.domain.report.repository.NutritionReportRepository;
1113
import com.DecodEat.domain.report.repository.ReportRecordRepository;
@@ -55,4 +57,20 @@ public ReportResponseDto.ReportListResponseDTO getReports(int page, int size) {
5557
return ReportConverter.toReportListResponseDTO(reportPage);
5658
}
5759

60+
/**
61+
* 상품 수정 신고 요청 거절
62+
* @param reportId 거절할 신고의 ID
63+
* @return 처리 결과를 담은 DTO
64+
*/
65+
public ReportResponseDto rejectReport(Long reportId){
66+
// 1. ID로 신고 내역 조회
67+
ReportRecord reportRecord = reportRecordRepository.findById(reportId)
68+
.orElseThrow(() -> new GeneralException(REPORT_NOT_FOUND));
69+
70+
// 2. reportstatus 상태를 rejected로 변경
71+
reportRecord.setReportStatus(ReportStatus.REJECTED);
72+
73+
// 3. DTO 반환
74+
return ReportConverter.toReportResponseDto(reportRecord.getProduct().getProductId(), "신고 요청이 거절 처리되었습니다.");
75+
}
5876
}

src/main/java/com/DecodEat/global/apiPayload/code/status/ErrorStatus.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public enum ErrorStatus implements BaseErrorCode {
3636
DUPLICATE_UNIQUE_KEY(HttpStatus.CONFLICT, "COMMON_005", "이미 처리된 요청입니다."),
3737

3838
// s3 사진 첨부 에러
39-
FILE_UPLOAD_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "FILE_001", "파일 업로드에 실패했습니다.");
39+
FILE_UPLOAD_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "FILE_001", "파일 업로드에 실패했습니다."),
40+
41+
// 신고
42+
REPORT_NOT_FOUND(HttpStatus.NOT_FOUND, "REPONT_401", "존재하지 않는 신고 내역 입니다.");
4043

4144
private final HttpStatus httpStatus;
4245
private final String code;

src/main/java/com/DecodEat/global/config/oauth/OAuth2SuccessHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ private void clearAuthenticationAttributes(HttpServletRequest request, HttpServl
9494

9595
// 액세스 토큰을 리다이렉트 경로에 파라미터로 추가
9696
private String getTargetUrl(String token) {
97-
return UriComponentsBuilder.fromUriString("https://decodeat.netlify.app") //todo:로그인 후 스웨거화면
97+
return UriComponentsBuilder.fromUriString("/decodeat.store") //todo:로그인 후 스웨거화면
98+
.queryParam("token", token)
9899
.build()
99100
.toUriString();
100101
}

0 commit comments

Comments
 (0)