@@ -116,21 +116,43 @@ final class DefaultClothDataSource: ClothDataSource {
116116 }
117117
118118 let clothIds = try await apiService. createClothes ( requests: createRequests)
119-
120- // 결과 변환: clothIds + inputs → Cloth 엔티티
121- return zip ( clothIds, zip ( inputs, presignedInfos) ) . map { clothId, pair in
122- let ( input, presignedInfo) = pair
123- return Cloth (
124- id: Int ( clothId) ,
125- imageUrl: presignedInfo. finalUrl,
126- name: input. name. isEmpty ? nil : input. name,
127- brand: input. brand. isEmpty ? nil : input. brand,
128- purchaseUrl: input. purchaseUrl. isEmpty ? nil : input. purchaseUrl,
129- mainCategory: nil ,
130- subCategory: nil ,
131- seasons: input. seasons
132- )
119+
120+ // Step 4: 생성된 옷의 상세 정보를 조회해서 정확한 카테고리 정보 포함
121+ var clothes : [ Cloth ] = [ ]
122+ for (index, clothId) in clothIds. enumerated ( ) {
123+ do {
124+ // 상세 정보 조회
125+ let detail = try await apiService. fetchClothDetails ( clothId: clothId)
126+
127+ // ClothDetailResult → Cloth 변환
128+ clothes. append ( Cloth (
129+ id: Int ( clothId) ,
130+ imageUrl: detail. clothImageUrl,
131+ name: detail. name,
132+ brand: detail. brand,
133+ purchaseUrl: detail. clothUrl,
134+ mainCategory: detail. parentCategory,
135+ subCategory: detail. category,
136+ seasons: Set ( detail. seasons)
137+ ) )
138+ } catch {
139+ // 상세 정보 조회 실패 시, 입력 데이터로 fallback
140+ let input = inputs [ index]
141+ let presignedInfo = presignedInfos [ index]
142+ clothes. append ( Cloth (
143+ id: Int ( clothId) ,
144+ imageUrl: presignedInfo. finalUrl,
145+ name: input. name. isEmpty ? nil : input. name,
146+ brand: input. brand. isEmpty ? nil : input. brand,
147+ purchaseUrl: input. purchaseUrl. isEmpty ? nil : input. purchaseUrl,
148+ mainCategory: nil ,
149+ subCategory: nil ,
150+ seasons: input. seasons
151+ ) )
152+ }
133153 }
154+
155+ return clothes
134156 }
135157
136158 func fetchMyClosetClothItems(
0 commit comments