Skip to content

Commit 7910145

Browse files
authored
[refactor/#245] 옷 상세 조회 & 목록 조회 API 수정 사항 (#246)
* fix: 옷의 계절을 모두 던져주도록 수정 * feat: 옷 카테고리 상세 조회 추가 --------- Co-authored-by: 나용준 <141994188+youngJun99@users.noreply.github.com>
1 parent 41e9b6a commit 7910145

6 files changed

Lines changed: 26 additions & 8 deletions

File tree

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
package org.clokey.domain.cloth.dto.response;
22

33
import io.swagger.v3.oas.annotations.media.Schema;
4+
import java.util.ArrayList;
5+
import java.util.List;
46
import org.clokey.cloth.entity.Cloth;
7+
import org.clokey.cloth.enums.Season;
58

69
public record ClothDetailsResponse(
710
@Schema(description = "옷의 이미지 url", example = "https://example.jpg") String clothImageUrl,
811
@Schema(description = "상위 카테고리 이름", example = "상의") String parentCategory,
912
@Schema(description = "하위 카테고리 이름", example = "블라우스") String category,
1013
@Schema(description = "옷 이름", example = "스트링 리본 블라우스") String name,
1114
@Schema(description = "옷 브랜드", example = "로렌하이") String brand,
12-
@Schema(description = "구매 url", example = "https://example.com") String clothUrl) {
15+
@Schema(description = "구매 url", example = "https://example.com") String clothUrl,
16+
@Schema(description = "옷의 계절 목록", example = "[\"SPRING\", \"SUMMER\"]")
17+
List<Season> seasons) {
1318
public static ClothDetailsResponse from(Cloth cloth) {
1419
return new ClothDetailsResponse(
1520
cloth.getClothImageUrl(),
1621
cloth.getCategory().getParent().getName(),
1722
cloth.getCategory().getName(),
1823
cloth.getName(),
1924
cloth.getBrand(),
20-
cloth.getClothUrl());
25+
cloth.getClothUrl(),
26+
new ArrayList<>(cloth.getSeasons()));
2127
}
2228
}

clokey-api/src/main/java/org/clokey/domain/cloth/dto/response/ClothListResponse.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public record ClothListResponse(
77
@Schema(description = "옷 이미지 url", example = "https://example.jpg") String ImageUrl,
88
@Schema(description = "옷 브랜드 이름", example = "나이키") String brand,
99
@Schema(description = "옷 이름", example = "파란색 후드") String name,
10-
@Schema(description = "옷 카테고리", example = "후드티") String category) {}
10+
@Schema(description = "상위 카테고리 이름", example = "상의") String parentCategory,
11+
@Schema(description = "하위 카테고리 이름", example = "후드티") String category) {}

clokey-api/src/main/java/org/clokey/domain/cloth/repository/ClothRepositoryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public Slice<ClothListResponse> findAllMemberClothesByCategoriesAndSeasons(
116116
cloth.clothImageUrl,
117117
cloth.brand,
118118
cloth.name,
119+
cloth.category.parent.name,
119120
cloth.category.name))
120121
.from(cloth)
121122
.where(

clokey-api/src/test/java/org/clokey/domain/cloth/controller/ClothControllerTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,14 @@ class 옷_목록_조회_요청_시 {
373373
"testImageUrl1",
374374
"testBrand1",
375375
"testName1",
376+
"testParentCategory1",
376377
"testCategory1"),
377378
new ClothListResponse(
378379
2L,
379380
"testImageUrl2",
380381
"testBrand2",
381382
"testName2",
383+
"testParentCategory2",
382384
"testCategory2"));
383385

384386
given(clothService.getClothes(null, 2, SortDirection.ASC, 1L, List.of(Season.SPRING)))
@@ -469,7 +471,8 @@ class 옷_상세_조회_요청_시 {
469471
"testCategory",
470472
"testName",
471473
"testBrand",
472-
"testClothUrl");
474+
"testClothUrl",
475+
List.of(Season.SPRING, Season.SUMMER));
473476

474477
given(clothService.getClothDetails(1L)).willReturn(response);
475478

@@ -484,7 +487,10 @@ class 옷_상세_조회_요청_시 {
484487
.andExpect(jsonPath("$.result.category").value("testCategory"))
485488
.andExpect(jsonPath("$.result.name").value("testName"))
486489
.andExpect(jsonPath("$.result.brand").value("testBrand"))
487-
.andExpect(jsonPath("$.result.clothUrl").value("testClothUrl"));
490+
.andExpect(jsonPath("$.result.clothUrl").value("testClothUrl"))
491+
.andExpect(jsonPath("$.result.seasons").isArray())
492+
.andExpect(jsonPath("$.result.seasons[0]").value("SPRING"))
493+
.andExpect(jsonPath("$.result.seasons[1]").value("SUMMER"));
488494
}
489495
}
490496

clokey-api/src/test/java/org/clokey/domain/cloth/service/ClothServiceTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ class 옷을_상세_조회할_때 {
573573

574574
@BeforeEach
575575
void setUp() {
576+
clothRepository.deleteAllInBatch();
577+
576578
Member member1 =
577579
Member.createMember(
578580
"testEmail1",
@@ -626,14 +628,16 @@ void setUp() {
626628
"category",
627629
"name",
628630
"brand",
629-
"clothUrl")
631+
"clothUrl",
632+
"seasons")
630633
.containsExactly(
631634
"testImageUrl1",
632635
"testParentCategory",
633636
"testCategory",
634637
null,
635638
null,
636-
null);
639+
null,
640+
List.of(Season.SPRING));
637641
}
638642

639643
@Test

clokey-api/src/test/java/org/clokey/domain/history/service/HistoryServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ void setUp() {
11541154
null,
11551155
"testName",
11561156
"testBrand",
1157-
Season.SPRING,
1157+
List.of(Season.SPRING),
11581158
category,
11591159
member1);
11601160
clothRepository.save(cloth);

0 commit comments

Comments
 (0)