From dd55dc2ce21e31eda31aa50ac819a3bbba756783 Mon Sep 17 00:00:00 2001 From: Ogu1208 Date: Sun, 11 Aug 2024 08:25:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20Product=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/config/SecurityConfiguration.kt | 2 +- .../product/controller/ProductController.kt | 15 +++++++----- .../store/clothstar/product/domain/Item.kt | 3 +++ .../clothstar/product/domain/ItemAttribute.kt | 2 ++ .../clothstar/product/domain/OptionValue.kt | 2 ++ .../store/clothstar/product/domain/Product.kt | 16 +++++++++++-- .../clothstar/product/domain/ProductImage.kt | 2 ++ .../clothstar/product/domain/ProductOption.kt | 5 +++- .../{ItemResponse.kt => ProductResponse.kt} | 5 ++-- .../product/repository/ProductRepository.kt | 5 ++++ .../service/ProductApplicationService.kt | 10 +++++++- .../product/service/ProductService.kt | 23 +++++++++++-------- src/main/resources/application-db.yml | 6 +++-- 13 files changed, 72 insertions(+), 24 deletions(-) rename src/main/kotlin/org/store/clothstar/product/dto/response/{ItemResponse.kt => ProductResponse.kt} (96%) diff --git a/src/main/kotlin/org/store/clothstar/common/config/SecurityConfiguration.kt b/src/main/kotlin/org/store/clothstar/common/config/SecurityConfiguration.kt index 1a36f14..ccd6561 100644 --- a/src/main/kotlin/org/store/clothstar/common/config/SecurityConfiguration.kt +++ b/src/main/kotlin/org/store/clothstar/common/config/SecurityConfiguration.kt @@ -61,7 +61,7 @@ class SecurityConfiguration( "/v1/members/login", "/signup", "/v1/members/email/**", "/v1/access", "/v1/categories/**", "/v1/products/**", "/v1/productLines/**", "/v2/productLines/**", "/productLinePagingSlice", "/productLinePagingOffset", - "/v3/products", + "/v3/products/**", "/v1/orderdetails", "/v1/orders", "membersPagingOffset", "membersPagingSlice", "/v1/orderdetails", "/v1/orders", "/v2/orders", "/v3/orders", "/v1/orders/list", "/v1/orders/list", "/ordersPagingOffset", "/ordersPagingSlice", "/v2/orders/list", diff --git a/src/main/kotlin/org/store/clothstar/product/controller/ProductController.kt b/src/main/kotlin/org/store/clothstar/product/controller/ProductController.kt index c59da73..a7472da 100644 --- a/src/main/kotlin/org/store/clothstar/product/controller/ProductController.kt +++ b/src/main/kotlin/org/store/clothstar/product/controller/ProductController.kt @@ -7,21 +7,17 @@ import org.springframework.http.ResponseEntity import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile -import org.store.clothstar.category.service.CategoryService import org.store.clothstar.common.dto.MessageDTO import org.store.clothstar.product.dto.request.ProductCreateRequest +import org.store.clothstar.product.dto.response.ProductResponse import org.store.clothstar.product.service.ProductApplicationService -import org.store.clothstar.product.service.ProductService -import java.net.URI @Tag(name = "Products", description = "Products(상품 옵션) 관련 API 입니다.") @RequestMapping("/v3/products") @RestController private class ProductController ( private val productApplicationService: ProductApplicationService, - private val productService: ProductService, - private val categoryService: CategoryService, -) { + ) { @PostMapping @Operation(summary = "상품 등록", description = "카테고리 아이디, 상품 이름, 내용, 가격, 상태를 입력하여 상품을 신규 등록한다.") @@ -41,4 +37,11 @@ private class ProductController ( return ResponseEntity(messageDTO, HttpStatus.CREATED) } + + @GetMapping("/{productId}") + @Operation(summary = "상품 상세 조회", description = "상품 ID를 사용하여 특정 상품의 상세 정보를 조회한다.") + fun getProductDetails(@PathVariable productId: Long): ResponseEntity { + val productResponse = productApplicationService.getProductDetails(productId) + return ResponseEntity(productResponse, HttpStatus.OK) + } } \ No newline at end of file diff --git a/src/main/kotlin/org/store/clothstar/product/domain/Item.kt b/src/main/kotlin/org/store/clothstar/product/domain/Item.kt index 9054c12..a6ac3fb 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/Item.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/Item.kt @@ -1,6 +1,7 @@ package org.store.clothstar.product.domain import jakarta.persistence.* +import org.hibernate.annotations.BatchSize import org.store.clothstar.product.domain.type.DisplayStatus import org.store.clothstar.product.domain.type.SaleStatus @@ -22,6 +23,7 @@ import org.store.clothstar.product.domain.type.SaleStatus * ] * } */ +@BatchSize(size = 20) @Entity class Item( @Id @@ -33,6 +35,7 @@ class Item( val saleStatus: SaleStatus, val displayStatus: DisplayStatus, + @BatchSize(size = 20) @ElementCollection @CollectionTable( name = "item_attributes", diff --git a/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt b/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt index 505038a..aacaefe 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt @@ -1,10 +1,12 @@ package org.store.clothstar.product.domain import jakarta.persistence.Embeddable +import org.hibernate.annotations.BatchSize /** * { "optionId": 1, "name": "색상", "value": "중청", "valueId": 1 } */ +@BatchSize(size = 20) @Embeddable data class ItemAttribute( var optionId: Long, diff --git a/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt b/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt index c3e8ab9..0cbec3f 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt @@ -1,6 +1,7 @@ package org.store.clothstar.product.domain import jakarta.persistence.* +import org.hibernate.annotations.BatchSize import org.store.clothstar.product.domain.type.ProductColor @@ -12,6 +13,7 @@ import org.store.clothstar.product.domain.type.ProductColor * "productOption": 1 * } */ +@BatchSize(size = 20) @Entity class OptionValue( @Id diff --git a/src/main/kotlin/org/store/clothstar/product/domain/Product.kt b/src/main/kotlin/org/store/clothstar/product/domain/Product.kt index 2c744e6..341e32e 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/Product.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/Product.kt @@ -1,12 +1,16 @@ package org.store.clothstar.product.domain import jakarta.persistence.* +import org.hibernate.annotations.BatchSize +import org.hibernate.annotations.Fetch +import org.hibernate.annotations.FetchMode import org.store.clothstar.common.entity.BaseEntity import org.store.clothstar.product.domain.type.DisplayStatus import org.store.clothstar.product.domain.type.ProductColor import org.store.clothstar.product.domain.type.SaleStatus import org.store.clothstar.product.dto.request.UpdateProductRequest +@BatchSize(size = 20) @Entity class Product( @Id @@ -26,15 +30,19 @@ class Product( var price: Int, // 색상 목록 + @BatchSize(size = 20) @ElementCollection(targetClass = ProductColor::class) @CollectionTable(name = "product_colors", joinColumns = [JoinColumn(name = "product_id")]) @Enumerated(EnumType.STRING) + @Fetch(FetchMode.SUBSELECT) var productColors: MutableSet = mutableSetOf(), // 이미지 목록 + @Fetch(FetchMode.SUBSELECT) + @BatchSize(size = 20) @ElementCollection @CollectionTable(name = "product_image", joinColumns = [JoinColumn(name = "product_line_id")]) - var imageList: MutableList = mutableListOf(), + var imageList: MutableSet = mutableSetOf(), // 기타 정보 var saleCount: Long = 0, @@ -44,11 +52,15 @@ class Product( var saleStatus: SaleStatus, // 판매 상태 // 연관 관계 (1:N) + @Fetch(FetchMode.SUBSELECT) + @BatchSize(size = 20) @OneToMany(mappedBy = "product", cascade = [CascadeType.ALL], fetch = FetchType.LAZY) var productOptions: MutableSet = mutableSetOf(), + @Fetch(FetchMode.SUBSELECT) + @BatchSize(size = 20) @OneToMany(mappedBy = "product", fetch = FetchType.LAZY, cascade = [CascadeType.ALL]) - var items: MutableList = mutableListOf(), + var items: MutableSet = mutableSetOf(), ) : BaseEntity() { diff --git a/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt b/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt index be79774..2ae949e 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt @@ -3,8 +3,10 @@ package org.store.clothstar.product.domain import jakarta.persistence.Embeddable import jakarta.persistence.EnumType import jakarta.persistence.Enumerated +import org.hibernate.annotations.BatchSize import org.store.clothstar.product.domain.type.ImageType +@BatchSize(size = 20) @Embeddable class ProductImage( val url: String, diff --git a/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt b/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt index 6024d5a..a31e2ec 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt @@ -1,6 +1,7 @@ package org.store.clothstar.product.domain import jakarta.persistence.* +import org.hibernate.annotations.BatchSize /** @@ -20,6 +21,7 @@ import jakarta.persistence.* * ] * } */ +@BatchSize(size = 20) @Entity class ProductOption( @Id @@ -33,6 +35,7 @@ class ProductOption( @JoinColumn(name = "product_id") val product: Product, + @BatchSize(size = 20) @OneToMany(mappedBy = "productOption", cascade = [CascadeType.ALL], orphanRemoval = true) - var optionValues: MutableList = mutableListOf(), + var optionValues: MutableSet = mutableSetOf(), ) \ No newline at end of file diff --git a/src/main/kotlin/org/store/clothstar/product/dto/response/ItemResponse.kt b/src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt similarity index 96% rename from src/main/kotlin/org/store/clothstar/product/dto/response/ItemResponse.kt rename to src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt index 95be83c..c44f739 100644 --- a/src/main/kotlin/org/store/clothstar/product/dto/response/ItemResponse.kt +++ b/src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt @@ -37,15 +37,16 @@ class ProductResponse( ) { companion object { fun from(product: Product): ProductResponse { + val distinctImages = product.imageList.distinctBy { it.url } return ProductResponse( id = product.productId!!, name = product.name, description = product.content, + imageList = distinctImages.map { ImageResponse.from(it) }, + productColors = product.productColors.toSet(), price = product.price, displayStatus = product.displayStatus, saleStatus = product.saleStatus, - productColors = product.productColors.toSet(), - imageList = product.imageList.map { ImageResponse.from(it) }, productOptions = product.productOptions.map { ProductOptionResponse.from(it) }, items = product.items.map { ItemResponse.from(it) } ) diff --git a/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt b/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt index 895120f..3f6791e 100644 --- a/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt +++ b/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt @@ -1,10 +1,15 @@ package org.store.clothstar.product.repository +import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository import org.store.clothstar.product.domain.Product +import java.util.* @Repository interface ProductRepository : JpaRepository { fun findByProductIdIn(productLineIds: List): List + + @EntityGraph(attributePaths = ["productOptions", "items", "imageList"]) + fun findWithDetailsByProductId(productId: Long): Optional } \ No newline at end of file diff --git a/src/main/kotlin/org/store/clothstar/product/service/ProductApplicationService.kt b/src/main/kotlin/org/store/clothstar/product/service/ProductApplicationService.kt index 0a7361a..f37ae91 100644 --- a/src/main/kotlin/org/store/clothstar/product/service/ProductApplicationService.kt +++ b/src/main/kotlin/org/store/clothstar/product/service/ProductApplicationService.kt @@ -6,9 +6,11 @@ import org.springframework.web.multipart.MultipartFile import org.store.clothstar.member.domain.Member import org.store.clothstar.member.domain.vo.MemberShoppingActivity import org.store.clothstar.member.service.MemberService +import org.store.clothstar.product.domain.Product import org.store.clothstar.product.domain.ProductImage import org.store.clothstar.product.domain.type.ImageType import org.store.clothstar.product.dto.request.ProductCreateRequest +import org.store.clothstar.product.dto.response.ProductResponse @Service class ProductApplicationService( @@ -41,7 +43,7 @@ class ProductApplicationService( val mainImageUrl = "https://on.com2us.com/wp-content/uploads/2023/12/VxdEKDNZCp9hAW5TU5-3MZTePLGSdlYKzEZUyVLDB-Cyo950Ee19yaOL8ayxgJzEfMYfzfLcRYuwkmKEs2cg0w.webp" product.imageList.add(ProductImage(mainImageUrl, mainImageUrl, ImageType.MAIN)) - // 3. 서브 이미지 업로드 및 저장 + // 3. 서브 이미지 업로드 및® 저장 subImages?.forEach { subImage -> // val subImageUrl = s3Service.uploadFile(subImage) val subImageUrl = "https://on.com2us.com/wp-content/uploads/2023/12/%EC%98%A4%EA%B5%AC%EC%99%80-%EB%B9%84%EB%B0%80%EC%9D%98%EC%88%B2-002.jpg" @@ -61,4 +63,10 @@ class ProductApplicationService( product.items.add(item) } } + + @Transactional(readOnly = true) + fun getProductDetails(productId: Long): ProductResponse { + + return productService.getProductDetails(productId) + } } \ No newline at end of file diff --git a/src/main/kotlin/org/store/clothstar/product/service/ProductService.kt b/src/main/kotlin/org/store/clothstar/product/service/ProductService.kt index f5d8a25..3b6f9e5 100644 --- a/src/main/kotlin/org/store/clothstar/product/service/ProductService.kt +++ b/src/main/kotlin/org/store/clothstar/product/service/ProductService.kt @@ -1,27 +1,32 @@ package org.store.clothstar.product.service +import jakarta.persistence.EntityNotFoundException import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import org.springframework.web.server.ResponseStatusException import org.store.clothstar.product.domain.Product import org.store.clothstar.product.dto.response.ProductResponse -import org.store.clothstar.product.repository.ItemRepository -import org.store.clothstar.product.repository.OptionValueRepository -import org.store.clothstar.product.repository.ProductOptionRepository import org.store.clothstar.product.repository.ProductRepository @Service class ProductService( private val productRepository: ProductRepository, ) { + @Transactional + fun createProduct(product: Product): Product { + return productRepository.save(product) + } + + @Transactional(readOnly = true) + fun getProductDetails(productId: Long): ProductResponse { + val product = productRepository.findWithDetailsByProductId(productId) + .orElseThrow { EntityNotFoundException("상품을 찾을 수 없습니다.") } + + return ProductResponse.from(product) + } + fun findByProductIdIn(productIds: List): List { return productRepository.findByProductIdIn(productIds).map { it ?: throw IllegalArgumentException("상품을 조회할 수 없습니다.") } } - - @Transactional - fun createProduct(product: Product): Product { - return productRepository.save(product) - } } \ No newline at end of file diff --git a/src/main/resources/application-db.yml b/src/main/resources/application-db.yml index 3e3fe7b..2a01620 100644 --- a/src/main/resources/application-db.yml +++ b/src/main/resources/application-db.yml @@ -51,6 +51,7 @@ spring: ddl-auto: create properties: hibernate: + default_batch_fetch_size: 1000 dialect: org.hibernate.dialect.MySQLDialect format_sql: true @@ -67,8 +68,9 @@ spring: jpa: hibernate: ddl-auto: update - show-sql: true database-platform: org.hibernate.dialect.MySQLDialect properties: hibernate: - format_sql: true \ No newline at end of file + default_batch_fetch_size: 1000 + format_sql: true + show_sql: true \ No newline at end of file From 67bd5ec76a0c8bc35e29b699a8f4b4502af86cb4 Mon Sep 17 00:00:00 2001 From: Ogu1208 Date: Sun, 11 Aug 2024 16:50:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EB=8B=A4=EC=A4=91=20=EC=BB=AC?= =?UTF-8?q?=EB=A0=89=EC=85=98=20N+1=20=EC=A1=B0=ED=9A=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20-=20default=5Fbatch=5Ffetch=5Fsize=20=EC=9E=AC?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/store/clothstar/product/domain/Item.kt | 2 -- .../store/clothstar/product/domain/ItemAttribute.kt | 1 - .../store/clothstar/product/domain/OptionValue.kt | 1 - .../org/store/clothstar/product/domain/Product.kt | 12 +++--------- .../store/clothstar/product/domain/ProductImage.kt | 1 - .../store/clothstar/product/domain/ProductOption.kt | 4 +--- .../product/dto/response/ProductResponse.kt | 3 +-- .../product/repository/ProductRepository.kt | 1 - src/main/resources/application-db.yml | 4 +--- src/main/resources/application.yml | 2 +- 10 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/org/store/clothstar/product/domain/Item.kt b/src/main/kotlin/org/store/clothstar/product/domain/Item.kt index a6ac3fb..2d0bb32 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/Item.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/Item.kt @@ -23,7 +23,6 @@ import org.store.clothstar.product.domain.type.SaleStatus * ] * } */ -@BatchSize(size = 20) @Entity class Item( @Id @@ -35,7 +34,6 @@ class Item( val saleStatus: SaleStatus, val displayStatus: DisplayStatus, - @BatchSize(size = 20) @ElementCollection @CollectionTable( name = "item_attributes", diff --git a/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt b/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt index aacaefe..8262c68 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/ItemAttribute.kt @@ -6,7 +6,6 @@ import org.hibernate.annotations.BatchSize /** * { "optionId": 1, "name": "색상", "value": "중청", "valueId": 1 } */ -@BatchSize(size = 20) @Embeddable data class ItemAttribute( var optionId: Long, diff --git a/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt b/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt index 0cbec3f..45afb73 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/OptionValue.kt @@ -13,7 +13,6 @@ import org.store.clothstar.product.domain.type.ProductColor * "productOption": 1 * } */ -@BatchSize(size = 20) @Entity class OptionValue( @Id diff --git a/src/main/kotlin/org/store/clothstar/product/domain/Product.kt b/src/main/kotlin/org/store/clothstar/product/domain/Product.kt index 341e32e..dd3b677 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/Product.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/Product.kt @@ -10,7 +10,6 @@ import org.store.clothstar.product.domain.type.ProductColor import org.store.clothstar.product.domain.type.SaleStatus import org.store.clothstar.product.dto.request.UpdateProductRequest -@BatchSize(size = 20) @Entity class Product( @Id @@ -28,9 +27,8 @@ class Product( var name: String, var content: String, var price: Int, - // 색상 목록 - @BatchSize(size = 20) + // 색상 목록 @ElementCollection(targetClass = ProductColor::class) @CollectionTable(name = "product_colors", joinColumns = [JoinColumn(name = "product_id")]) @Enumerated(EnumType.STRING) @@ -38,8 +36,6 @@ class Product( var productColors: MutableSet = mutableSetOf(), // 이미지 목록 - @Fetch(FetchMode.SUBSELECT) - @BatchSize(size = 20) @ElementCollection @CollectionTable(name = "product_image", joinColumns = [JoinColumn(name = "product_line_id")]) var imageList: MutableSet = mutableSetOf(), @@ -53,14 +49,12 @@ class Product( // 연관 관계 (1:N) @Fetch(FetchMode.SUBSELECT) - @BatchSize(size = 20) @OneToMany(mappedBy = "product", cascade = [CascadeType.ALL], fetch = FetchType.LAZY) - var productOptions: MutableSet = mutableSetOf(), + var productOptions: MutableList = mutableListOf(), @Fetch(FetchMode.SUBSELECT) - @BatchSize(size = 20) @OneToMany(mappedBy = "product", fetch = FetchType.LAZY, cascade = [CascadeType.ALL]) - var items: MutableSet = mutableSetOf(), + var items: MutableList = mutableListOf(), ) : BaseEntity() { diff --git a/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt b/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt index 2ae949e..d1002c5 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/ProductImage.kt @@ -6,7 +6,6 @@ import jakarta.persistence.Enumerated import org.hibernate.annotations.BatchSize import org.store.clothstar.product.domain.type.ImageType -@BatchSize(size = 20) @Embeddable class ProductImage( val url: String, diff --git a/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt b/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt index a31e2ec..8bb58f5 100644 --- a/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt +++ b/src/main/kotlin/org/store/clothstar/product/domain/ProductOption.kt @@ -21,7 +21,6 @@ import org.hibernate.annotations.BatchSize * ] * } */ -@BatchSize(size = 20) @Entity class ProductOption( @Id @@ -35,7 +34,6 @@ class ProductOption( @JoinColumn(name = "product_id") val product: Product, - @BatchSize(size = 20) @OneToMany(mappedBy = "productOption", cascade = [CascadeType.ALL], orphanRemoval = true) - var optionValues: MutableSet = mutableSetOf(), + var optionValues: MutableList = mutableListOf(), ) \ No newline at end of file diff --git a/src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt b/src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt index c44f739..f681adb 100644 --- a/src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt +++ b/src/main/kotlin/org/store/clothstar/product/dto/response/ProductResponse.kt @@ -37,12 +37,11 @@ class ProductResponse( ) { companion object { fun from(product: Product): ProductResponse { - val distinctImages = product.imageList.distinctBy { it.url } return ProductResponse( id = product.productId!!, name = product.name, description = product.content, - imageList = distinctImages.map { ImageResponse.from(it) }, + imageList = product.imageList.map { ImageResponse.from(it) }, productColors = product.productColors.toSet(), price = product.price, displayStatus = product.displayStatus, diff --git a/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt b/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt index 3f6791e..33113c9 100644 --- a/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt +++ b/src/main/kotlin/org/store/clothstar/product/repository/ProductRepository.kt @@ -10,6 +10,5 @@ import java.util.* interface ProductRepository : JpaRepository { fun findByProductIdIn(productLineIds: List): List - @EntityGraph(attributePaths = ["productOptions", "items", "imageList"]) fun findWithDetailsByProductId(productId: Long): Optional } \ No newline at end of file diff --git a/src/main/resources/application-db.yml b/src/main/resources/application-db.yml index 2a01620..4e2c36a 100644 --- a/src/main/resources/application-db.yml +++ b/src/main/resources/application-db.yml @@ -30,7 +30,7 @@ spring: jpa: properties: hibernate: - default_batch_fetch_size: 1000 + default_batch_fetch_size: 200 --- # local 공통 설정 spring: @@ -51,7 +51,6 @@ spring: ddl-auto: create properties: hibernate: - default_batch_fetch_size: 1000 dialect: org.hibernate.dialect.MySQLDialect format_sql: true @@ -71,6 +70,5 @@ spring: database-platform: org.hibernate.dialect.MySQLDialect properties: hibernate: - default_batch_fetch_size: 1000 format_sql: true show_sql: true \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ec14174..f2d775e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,7 +5,7 @@ jasypt: spring: profiles: active: - - local, mybatis + - local group: local: - db-local