Skip to content

Commit dd8dd55

Browse files
authored
Merge pull request #35 from Decodeat/Feat/#34
[Refactor, Chore] 관리자용 api 분리 및 설정 추가
2 parents f0366c6 + d66e0a8 commit dd8dd55

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.DecodEat.domain.report.controller;
2+
3+
import com.DecodEat.domain.report.dto.response.ReportResponseDto;
4+
import com.DecodEat.domain.report.service.ReportService;
5+
import com.DecodEat.global.apiPayload.ApiResponse;
6+
import io.swagger.v3.oas.annotations.Operation;
7+
import io.swagger.v3.oas.annotations.Parameter;
8+
import io.swagger.v3.oas.annotations.Parameters;
9+
import io.swagger.v3.oas.annotations.tags.Tag;
10+
import lombok.RequiredArgsConstructor;
11+
import org.springframework.web.bind.annotation.*;
12+
13+
@RestController
14+
@RequiredArgsConstructor
15+
@RequestMapping("/api/admin/reports")
16+
@Tag(name = "[관리자] 신고 관리")
17+
public class AdminReportController {
18+
19+
private final ReportService reportService;
20+
21+
@Operation(
22+
summary = "상품 수정 요청 조회 (관리자)",
23+
description = "관리자가 모든 상품 정보 수정 요청을 페이지별로 조회합니다. 영양 정보 수정과 이미지 확인 요청을 모두 포함합니다.")
24+
@Parameters({
25+
// @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정
26+
@Parameter(name = "page", description = "페이지 번호, 0부터 시작합니다.", example = "0"),
27+
@Parameter(name = "size", description = "한 페이지에 보여줄 항목 수", example = "10")
28+
})
29+
@GetMapping
30+
public ApiResponse<ReportResponseDto.ReportListResponseDTO> getReports(
31+
@RequestParam(defaultValue = "0") int page,
32+
@RequestParam(defaultValue = "10") int size
33+
) {
34+
return ApiResponse.onSuccess(reportService.getReports(page, size));
35+
}
36+
37+
@Operation(
38+
summary = "상품 수정 요청 거절 (관리자)",
39+
description = "관리자가 상품 정보 수정 요청을 거절합니다. 해당 신고 내역의 상태를 REJECTED로 변경합니다.")
40+
@Parameter(name = "reportId", description = "거절할 신고의 ID", example = "1")
41+
// @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정
42+
@PatchMapping("/{reportId}/reject")
43+
public ApiResponse<ReportResponseDto> rejectReport(@PathVariable Long reportId) {
44+
return ApiResponse.onSuccess(reportService.rejectReport(reportId));
45+
}
46+
}

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,5 @@ public ApiResponse<ReportResponseDto> requestCheckImage(@CurrentUser User user,
4545

4646
return ApiResponse.onSuccess(reportService.requestCheckImage(user, productId, imageUrl));
4747
}
48-
@Operation(
49-
summary = "상품 수정 요청 조회 (관리자)",
50-
description = "관리자가 모든 상품 정보 수정 요청을 페이지별로 조회합니다. 영양 정보 수정과 이미지 확인 요청을 모두 포함합니다.")
51-
@Parameters({
52-
// @PreAuthorize("hasRole('ADMIN')") // Spring Security 사용 시 권한 설정
53-
@Parameter(name = "page", description = "페이지 번호, 0부터 시작합니다.", example = "0"),
54-
@Parameter(name = "size", description = "한 페이지에 보여줄 항목 수", example = "10")
55-
})
56-
@GetMapping
57-
public ApiResponse<ReportResponseDto.ReportListResponseDTO> getReports(
58-
@RequestParam(defaultValue = "0") int page,
59-
@RequestParam(defaultValue = "10") int size
60-
) {
61-
return ApiResponse.onSuccess(reportService.getReports(page, size));
62-
}
6348

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-
}
7349
}

src/main/java/com/DecodEat/global/config/CorsConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public CorsConfigurationSource corsConfigurationSource() {
1616
CorsConfiguration configuration = new CorsConfiguration();
1717

1818
configuration.setAllowedOriginPatterns(List.of( "https://decodeat.netlify.app",
19-
"http://localhost:8080","http://localhost:5173", "http://decodeat.store", "https://decodeat.store" ));
19+
"http://localhost:8080","http://localhost:5173", "http://decodeat.store", "https://decodeat.store", "http://www.decodeat.store", "https://www.decodeat.store" ));
2020
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
2121
configuration.setAllowedHeaders(List.of("*"));
2222
configuration.setAllowCredentials(true); // 쿠키/인증정보 포함 허용

src/main/java/com/DecodEat/global/config/WebOAuthSecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
8181
http.logout(logout -> logout
8282
.logoutUrl("/api/logout")
8383
// 👇 카카오 로그아웃 URL로 리다이렉트
84-
.logoutSuccessUrl("https://kauth.kakao.com/oauth/logout?client_id=" + kakaoClientId + "&logout_redirect_uri=https://decodeat.store.app/")
84+
.logoutSuccessUrl("https://kauth.kakao.com/oauth/logout?client_id=" + kakaoClientId + "&logout_redirect_uri=https://decodeat.store/")
8585
.invalidateHttpSession(true)
8686
.deleteCookies("JSESSIONID")
8787
.clearAuthentication(true)

0 commit comments

Comments
 (0)