22
33import com .closetnangam .be .domain .wardrobe .entity .Wardrobe ;
44import com .closetnangam .be .domain .wardrobe .service .WardrobeService ;
5+ import com .closetnangam .be .global .auth .util .SecurityUtils ;
56import com .closetnangam .be .global .common .response .ApiResponse ;
6- import com .closetnangam .be .global .external .clothes .dto .NaverItemRequest ;
7- import com .closetnangam .be .global .external .clothes .dto .record .SaveNaverProductRequest ;
8- import com .closetnangam .be .global .external .clothes .dto .request .ClothesStyleDto ;
9- import com .closetnangam .be .global .external .clothes .dto .request .ClothingColorDto ;
7+ import com .closetnangam .be .global .external .clothes .dto .record .NaverProductCreateRequest ;
108import com .closetnangam .be .global .external .clothes .dto .response .SaveNaverProductResponse ;
119import com .closetnangam .be .global .external .clothes .service .ExternalClothesService ;
1210import io .swagger .v3 .oas .annotations .Operation ;
1311import io .swagger .v3 .oas .annotations .tags .Tag ;
1412import jakarta .validation .Valid ;
1513import lombok .RequiredArgsConstructor ;
16- import org .springframework .http .ResponseEntity ;
1714import org .springframework .web .bind .annotation .PostMapping ;
1815import org .springframework .web .bind .annotation .RequestBody ;
1916import org .springframework .web .bind .annotation .RequestMapping ;
20- import org .springframework .web .bind .annotation .RequestParam ;
2117import org .springframework .web .bind .annotation .RestController ;
2218
23- import java .util .List ;
24-
2519@ Tag (name = "External Clothes" , description = "외부 서비스 상품 연동 API" )
2620@ RestController
2721@ RequestMapping ("/api/v1/external/clothes" )
@@ -34,24 +28,22 @@ public class ExternalClothesController {
3428 @ Operation (summary = "네이버 상품 저장" , description = "네이버에서 검색한 상품 정보를 저장합니다." )
3529 @ PostMapping ("/naver" )
3630 public ApiResponse <SaveNaverProductResponse > saveNaverProduct (
37- @ RequestParam Long userId ,
38- @ Valid @ RequestBody SaveNaverProductRequest request
31+ @ Valid @ RequestBody NaverProductCreateRequest request
3932 ) {
40- // TODO: SecurityContextHolder 통합 후 아래 검증 추가
41- // Long authenticatedUserId = SecurityUtils.getCurrentUserId();
42- // if (!userId.equals(authenticatedUserId)) {
43- // throw new IllegalArgumentException("자신의 옷장에만 접근할 수 있습니다");
44- // }
45-
46- Wardrobe wardrobe = wardrobeService .getOrCreateWardrobe (userId );
47- // request 내부에서 필요한 객체들만 쏙쏙 뽑아서 전달
48- Long clothesId = externalClothesService .saveNaverToWishlist (
49- userId ,
50- wardrobe ,
51- request , // <-- request 자체가 이제 NaverItemRequest 역할을 함!
52- request .colors (),
53- request .styles ()
54- );
33+ // 1. 테스트용 유저 ID 1번 강제 주입 (로그인 구현 전까지 유지)
34+ Long authenticatedUserId = 1L ;
35+
36+ // 로그인 기능 구현 하면 다시 쓸 예정
37+ // Long authenticatedUserId = SecurityUtils.getCurrentUserId();
38+
39+ // 메서드명을 새로 바꾼 getOrCreateExternalClothes로 매핑하고, DTO 내부의 colors(), styles()를 넘깁니다.
40+ Long clothesId = externalClothesService .getOrCreateExternalClothes (
41+ request , request .colors (), request .styles ());
42+
43+ // 3. [옷장 담당 역할] 유저의 옷장에 이 옷을 담아두는 로직 호출
44+ // 임시로 주석 처리해 두었다가, 옷장 담당 팀원이 메서드(예: addClothesToWishlist)를 만들어주면 주석을 풀고 연결합니다!
45+ // Wardrobe wardrobe = wardrobeService.getOrCreateWardrobe(authenticatedUserId);
46+ // wardrobeService.addClothesToWishlist(authenticatedUserId, wardrobe, clothesId);
5547
5648 return ApiResponse .ok (new SaveNaverProductResponse (clothesId ));
5749 }
0 commit comments