-
Notifications
You must be signed in to change notification settings - Fork 0
[#7] 판매자 도메인 모델 구현 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| %% 판매자 도메인 ERD | ||
| erDiagram | ||
| Seller { | ||
| } | ||
| SellerRegistrationRequest { | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.nilgil.commerce.common | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Embeddable | ||
|
|
||
| @Embeddable | ||
| data class Email( | ||
| @Column(name = "email") | ||
| val value: String, | ||
| ) { | ||
| companion object { | ||
| private val EMAIL_REGEX = Regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$") | ||
| } | ||
|
|
||
| init { | ||
| require(value.matches(EMAIL_REGEX)) { "Invalid email format: $value" } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.nilgil.commerce.common | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Embeddable | ||
|
|
||
| @Embeddable | ||
| data class PhoneNumber( | ||
| @Column(name = "phone_number") | ||
| val value: String, | ||
| ) { | ||
| companion object { | ||
| private val PHONE_NUMBER_REGEX = Regex("^01[016789]-\\d{3,4}-\\d{4}$") | ||
| } | ||
|
|
||
| init { | ||
| require(value.matches(PHONE_NUMBER_REGEX)) { "Invalid phone number format: $value" } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| import com.nilgil.commerce.common.BaseEntity | ||
| import com.nilgil.commerce.common.Email | ||
| import com.nilgil.commerce.common.PhoneNumber | ||
| import jakarta.persistence.Embedded | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.EnumType | ||
| import jakarta.persistence.Enumerated | ||
|
|
||
| @Entity | ||
| class Seller( | ||
| @Embedded | ||
| var businessInfo: SellerBusinessInfo, | ||
| @Embedded | ||
| var contactInfo: SellerContactInfo, | ||
| @Embedded | ||
| var bankAccount: SellerBankAccount, | ||
| var introduction: String?, | ||
| var brandLogo: String?, | ||
| ) : BaseEntity() { | ||
| @Enumerated(EnumType.STRING) | ||
| var status: SellerStatus = SellerStatus.ACTIVE | ||
|
|
||
| fun activate() { | ||
| this.status = SellerStatus.ACTIVE | ||
| } | ||
|
|
||
| fun deactivate() { | ||
| this.status = SellerStatus.INACTIVE | ||
| } | ||
|
|
||
| fun block() { | ||
| this.status = SellerStatus.BLOCKED | ||
| } | ||
|
|
||
| fun unblock() { | ||
| this.status = SellerStatus.ACTIVE | ||
| } | ||
|
|
||
| fun changeBusinessInfo(sellerBusinessInfo: SellerBusinessInfo) { | ||
| this.businessInfo = sellerBusinessInfo | ||
| } | ||
|
|
||
| fun changeContactInfo(contactInfo: SellerContactInfo) { | ||
| this.contactInfo = contactInfo | ||
| } | ||
|
|
||
| fun changeEmail(email: Email) { | ||
| this.contactInfo = this.contactInfo.copy(email = email) | ||
| } | ||
|
|
||
| fun changePhoneNumber(phoneNumber: PhoneNumber) { | ||
| this.contactInfo = this.contactInfo.copy(phoneNumber = phoneNumber) | ||
| } | ||
|
|
||
| fun changeBankAccount(bankAccount: SellerBankAccount) { | ||
| this.bankAccount = bankAccount | ||
| } | ||
|
|
||
| fun changeIntroduction(introduction: String) { | ||
| this.introduction = introduction | ||
| } | ||
|
|
||
| fun changeBrandLogo(brandLogo: String) { | ||
| this.brandLogo = brandLogo | ||
| } | ||
| } | ||
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/nilgil/commerce/seller/SellerBankAccount.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Embeddable | ||
|
|
||
| @Embeddable | ||
| data class SellerBankAccount( | ||
| @Column(name = "bank_name") | ||
| val bankName: String, | ||
| @Column(name = "bank_account_number") | ||
| val accountNumber: String, | ||
| @Column(name = "bank_account_holder") | ||
| val accountHolder: String, | ||
| ) |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/nilgil/commerce/seller/SellerBusinessInfo.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Embeddable | ||
|
|
||
| @Embeddable | ||
| data class SellerBusinessInfo( | ||
| @Column(name = "business_name") | ||
| val name: String, | ||
| @Column(name = "business_type") | ||
| val type: String, | ||
| @Column(name = "business_category") | ||
| val category: String, | ||
| @Column(name = "business_address") | ||
| val address: String, | ||
| @Column(name = "business_registration_number") | ||
| val registrationNumber: String, | ||
| @Column(name = "business_registration_certificate") | ||
| val registrationCertificate: String, | ||
| ) |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/nilgil/commerce/seller/SellerContactInfo.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| import com.nilgil.commerce.common.Email | ||
| import com.nilgil.commerce.common.PhoneNumber | ||
| import jakarta.persistence.Embeddable | ||
| import jakarta.persistence.Embedded | ||
|
|
||
| @Embeddable | ||
| data class SellerContactInfo( | ||
| @Embedded | ||
| val email: Email, | ||
| @Embedded | ||
| val phoneNumber: PhoneNumber, | ||
| ) |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/com/nilgil/commerce/seller/SellerRegistrationRequest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| import com.nilgil.commerce.common.BaseEntity | ||
| import jakarta.persistence.Embedded | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.EnumType | ||
| import jakarta.persistence.Enumerated | ||
|
|
||
| @Entity | ||
| class SellerRegistrationRequest( | ||
| @Embedded | ||
| val businessInfo: SellerBusinessInfo, | ||
| @Embedded | ||
| val contactInfo: SellerContactInfo, | ||
| @Embedded | ||
| val bankAccount: SellerBankAccount, | ||
| ) : BaseEntity() { | ||
| @Enumerated(EnumType.STRING) | ||
| var status: SellerRegistrationStatus = SellerRegistrationStatus.PENDING | ||
|
|
||
| fun approve() { | ||
| this.status = SellerRegistrationStatus.APPROVED | ||
| } | ||
|
|
||
| fun reject() { | ||
| this.status = SellerRegistrationStatus.REJECTED | ||
| } | ||
|
|
||
| fun cancel() { | ||
| this.status = SellerRegistrationStatus.CANCELLED | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/nilgil/commerce/seller/SellerRegistrationStatus.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| enum class SellerRegistrationStatus { | ||
| APPROVED, | ||
| PENDING, | ||
| REJECTED, | ||
| CANCELLED, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.nilgil.commerce.seller | ||
|
|
||
| enum class SellerStatus { | ||
| ACTIVE, | ||
| INACTIVE, | ||
| BLOCKED, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setter 보다 명확한 의미를 가지는 메소드로 뽑아내신 것 좋은 시도 같습니다 👍👍
근데 현재구조라면, 외부에서 seller.backAccount = backAccount 행위를 막을 수 없을 것 같은데요.
코틀린 프로퍼티 setter 접근을 제한하려면 어떻게 하면 좋을까요?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런식으로 백킹 프로퍼티를 사용하여 가능할 것 같습니다. 그런데 모든 var에 대해 이렇게 해줘야 할 것 같은데 너무 복잡해질 것 같다는 생각이 듭니다. 세터 사용 금지라는 규약을 정해두고(CI/CD에서 검증 등) 세터를 열어두는 트레이드 오프를 하는 것도 좋아 보입니다.