-
Notifications
You must be signed in to change notification settings - Fork 0
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
도메인 구조를 리패키징하고 래핑했습니다. #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.usw.usgo.domain | ||
package com.usw.usgo.domain.core | ||
|
||
import jakarta.persistence.* | ||
import org.springframework.data.annotation.CreatedDate | ||
|
@@ -11,12 +11,16 @@ import java.time.LocalDateTime | |
abstract class BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long? = null | ||
val id: Long = 0L | ||
|
||
@Column(name = "is_deleted") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name을 딱히 매핑해주지 않아도 자동으로 snake_case로 변환해주는데 굳이 붙인 이유가 있을까?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 하다가 빼먹은 컬럼이 많긴하지만 명시적으로 컬럼을 네이밍하는게 조금 더 보기 좋은 것 같긴해서 써놨어요~ 이것도 컨벤션 정해놓으면 좋을것같네요?! |
||
var isDeleted: Boolean = false | ||
|
||
@CreatedDate | ||
@Column(updatable = false) | ||
@Column(name = "created_at", updatable = false) | ||
val createdAt: LocalDateTime = LocalDateTime.now() | ||
|
||
@LastModifiedDate | ||
@Column(name = "modified_at") | ||
var modifiedAt: LocalDateTime = LocalDateTime.now() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.usw.usgo.domain.core.notice | ||
|
||
import com.usw.usgo.domain.core.BaseEntity | ||
import com.usw.usgo.domain.embeddable.Content | ||
import com.usw.usgo.domain.embeddable.Title | ||
import jakarta.persistence.Embedded | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Table | ||
|
||
@Entity | ||
@Table(name = "notice") | ||
class Notice( | ||
|
||
@Embedded | ||
var title: Title, | ||
|
||
@Embedded | ||
var content: Content, | ||
) : BaseEntity() { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.usw.usgo.domain.core.productpost | ||
|
||
import com.usw.usgo.domain.core.BaseEntity | ||
import com.usw.usgo.domain.core.user.User | ||
import com.usw.usgo.domain.embeddable.Content | ||
import com.usw.usgo.domain.embeddable.Price | ||
import com.usw.usgo.domain.embeddable.Title | ||
import com.usw.usgo.domain.enumerated.ContactPlace | ||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "product_post") | ||
class ProductPost( | ||
|
||
@Embedded | ||
var title: Title, | ||
|
||
@Embedded | ||
var content: Content, | ||
|
||
@Embedded | ||
var price: Price, | ||
|
||
@Enumerated(EnumType.STRING) | ||
var contactPlace: ContactPlace, | ||
|
||
@Enumerated(EnumType.STRING) | ||
var status: Status = Status.NORMAL, | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
val user: User, | ||
|
||
) : BaseEntity() | ||
|
||
enum class Status { | ||
NORMAL, | ||
RESTRICTED, | ||
DELETED, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.usw.usgo.domain.core.userpost | ||
|
||
import com.usw.usgo.domain.core.BaseEntity | ||
import com.usw.usgo.domain.core.productpost.ProductPost | ||
import com.usw.usgo.domain.core.user.User | ||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "post_like") | ||
class PostLike( | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
val user: User, | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "product_post_id") | ||
val productPost: ProductPost, | ||
|
||
) : BaseEntity() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.usw.usgo.domain.embeddable | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Embeddable | ||
|
||
@Embeddable | ||
class Content( | ||
|
||
@Column(nullable = false) | ||
val value: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.usw.usgo.domain.embeddable | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Embeddable | ||
|
||
@Embeddable | ||
class Price( | ||
|
||
@Column(nullable = false) | ||
val value: Int, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.usw.usgo.domain.embeddable | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Embeddable | ||
|
||
@Embeddable | ||
class Title( | ||
|
||
@Column(nullable = false) | ||
val value: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.usw.usgo.domain.enumerated | ||
|
||
enum class ContactPlace { | ||
|
||
IT, ACE, GLOBAL, | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
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.
이거 안그래도 궁금했던 부분 중 하나..!
JPA에서 Wrapper 타입을 사용하는건 0과 같은 값이 ID일 때 유효한가?에 대한 판단을 위해서인데
이렇게 0을 써도 무방해 부라더?? 잘 모르겠움 😭
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.
auto increment는 GenerationType.IDENTITY옵션을 쓰면 전적으로 DBMS가 부여하는 PK를 쓰는걸로 알고있어서 기본값을 0L로 지정해도 무관하다고 알고있어요!
물론 형이 하신대로 하셔도 진짜 노상관이라서 이것도 굳이 반영안하고 형 생각대로 가도 될 것 같아요!
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.
몰라서 물어본거라 편하게 정해도 좋습니다 ㅋㅋ