From 31167cba1bb47ad1e5c826d789b3d3ed3cc0c131 Mon Sep 17 00:00:00 2001 From: Klaus Date: Thu, 8 Oct 2026 21:00:01 +0900 Subject: [PATCH] =?UTF-8?q?fix(gift):=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=A0=91=EC=88=98=20=EC=BD=94=EB=93=9C=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EC=9D=84=20=ED=97=88=EC=9A=A9=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/20260929_크리에이터_선물하기/gift-schema.sql | 2 ++ .../gift/adapter/out/persistence/GiftCategory.kt | 3 +-- .../out/persistence/GiftEntityMappingTest.kt | 15 +++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/20260929_크리에이터_선물하기/gift-schema.sql b/docs/20260929_크리에이터_선물하기/gift-schema.sql index 81dbfff3..af09cb64 100644 --- a/docs/20260929_크리에이터_선물하기/gift-schema.sql +++ b/docs/20260929_크리에이터_선물하기/gift-schema.sql @@ -126,3 +126,5 @@ CREATE TABLE gift_application_no_sequence ( UNIQUE KEY uk_gift_application_no_sequence_category_date (category_id, sequence_date), CONSTRAINT fk_gift_application_no_sequence_category FOREIGN KEY (category_id) REFERENCES gift_category (id) ) COMMENT='선물 신청번호 날짜별 채번'; + +ALTER TABLE gift_category DROP INDEX uk_gift_category_receipt_code; diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftCategory.kt b/src/main/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftCategory.kt index 807b17ec..06820cbe 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftCategory.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftCategory.kt @@ -11,8 +11,7 @@ import javax.persistence.UniqueConstraint name = "gift_category", uniqueConstraints = [ UniqueConstraint(name = "uk_gift_category_classification_number", columnNames = ["classification_number"]), - UniqueConstraint(name = "uk_gift_category_code", columnNames = ["category_code"]), - UniqueConstraint(name = "uk_gift_category_receipt_code", columnNames = ["receipt_code"]) + UniqueConstraint(name = "uk_gift_category_code", columnNames = ["category_code"]) ] ) class GiftCategory( diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftEntityMappingTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftEntityMappingTest.kt index cf7e4057..577bcd03 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftEntityMappingTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/gift/adapter/out/persistence/GiftEntityMappingTest.kt @@ -92,7 +92,7 @@ class GiftEntityMappingTest @Autowired constructor( } @Test - @DisplayName("신청번호와 카테고리 unique 값과 리뷰 선물 ID는 중복 저장할 수 없다") + @DisplayName("신청번호와 카테고리 분류번호 및 코드와 리뷰 선물 ID는 중복 저장할 수 없다") fun shouldRejectDuplicateUniqueValues() { val category = giftCategoryRepository.save(giftCategory("100", "DOLL", "A")) val gift = giftRepository.save(gift(category.id!!, "G20260929000001")) @@ -108,14 +108,21 @@ class GiftEntityMappingTest @Autowired constructor( assertThrows(DataIntegrityViolationException::class.java) { giftCategoryRepository.saveAndFlush(giftCategory("100", "TOY", "B")) } - assertThrows(DataIntegrityViolationException::class.java) { - giftCategoryRepository.saveAndFlush(giftCategory("101", "TOY", "A")) - } assertThrows(DataIntegrityViolationException::class.java) { giftReviewRepository.saveAndFlush(GiftReview(giftId = gift.id!!, senderMemberId = 1L, rating = 4)) } } + @Test + @DisplayName("카테고리 접수 코드는 중복 저장할 수 있다") + fun shouldAllowDuplicateReceiptCode() { + val first = giftCategoryRepository.saveAndFlush(giftCategory("100", "DOLL", "A")) + val second = giftCategoryRepository.saveAndFlush(giftCategory("101", "TOY", "A")) + + assertNotNull(first.id) + assertNotNull(second.id) + } + @Test @DisplayName("카테고리와 날짜별 신청번호 채번 sequence를 저장한다") fun shouldSaveApplicationNoSequence() {