-
Notifications
You must be signed in to change notification settings - Fork 0
Seowoo #4
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
base: main
Are you sure you want to change the base?
Seowoo #4
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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.ManyToOne | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity(name = "alarm") | ||
| class Alarm( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "user_id") | ||
| val users: Users, | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "family_id") | ||
| val family: Family, | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "memory_id") | ||
| val record: Memory, | ||
|
|
||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.DiscriminatorColumn | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.Inheritance | ||
| import jakarta.persistence.InheritanceType | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity(name = "comment") | ||
| @Inheritance(strategy = InheritanceType.JOINED) | ||
| @DiscriminatorColumn(name = "comment_Type") | ||
| class Comment( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @Column(name = "updated_at") | ||
| var updatedAt: LocalDateTime = LocalDateTime.now(), | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.DiscriminatorValue | ||
| import jakarta.persistence.Entity | ||
|
|
||
| @Entity(name = "emoji_comment") | ||
| @DiscriminatorValue("EmojiComment") | ||
| class EmojiComment( | ||
|
|
||
| @Column(name = "emoji", nullable = false) | ||
| var emoji: String, | ||
|
|
||
| ) : Comment() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.Table | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity | ||
| @Table(name = "family") | ||
| class Family( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "code", nullable = false) | ||
| var code: String, | ||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.Index | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.ManyToOne | ||
| import jakarta.persistence.Table | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity(name = "fcmtoken") | ||
| class FcmToken( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "fcm_token", nullable = false) | ||
| var fcmToken: String, | ||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @Column(name = "updated_at") | ||
| var updatedAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "user_id") | ||
| val users: Users, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.DiscriminatorColumn | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.Inheritance | ||
| import jakarta.persistence.InheritanceType | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.JoinTable | ||
| import jakarta.persistence.ManyToMany | ||
| import jakarta.persistence.ManyToOne | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity(name = "memory") | ||
| @Inheritance(strategy = InheritanceType.JOINED) | ||
| @DiscriminatorColumn(name = "memory_type") | ||
| class Memory( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int, | ||
|
|
||
| @Column(name = "image") | ||
| var image: String, | ||
|
|
||
| @Column(name = "content") | ||
| var content: String, | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "user_id") | ||
| val users: Users, | ||
|
|
||
| @ManyToMany | ||
| @JoinTable(name = "pet_memory") | ||
| val pets: List<Pet>, | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "family_id") | ||
| val family: Family, | ||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @Column(name = "updated_at") | ||
| var updatedAt: LocalDateTime = LocalDateTime.now(), | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| @Entity(name = "mission") | ||
| class Mission( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "content") | ||
| var content: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.DiscriminatorValue | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.OneToOne | ||
|
|
||
| @Entity(name = "mission_memory") | ||
| @DiscriminatorValue("MissionMemory") | ||
| class MissionMemory( | ||
| id: Int, | ||
| image: String, | ||
| content: String, | ||
| users: Users, | ||
| family: Family, | ||
|
|
||
| @OneToOne | ||
| @JoinColumn(name = "mission_id") | ||
| val mission: Mission, | ||
|
|
||
| ) : Memory(id, image, content, users, family) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.JoinTable | ||
| import jakarta.persistence.ManyToMany | ||
| import jakarta.persistence.ManyToOne | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity(name = "pet") | ||
| class Pet( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "profile_image") | ||
| var profileImage: String, | ||
|
|
||
| @Column(name = "name") | ||
| var name: String, | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "user_id") | ||
| val users: Users, | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "family_id") | ||
| val family: Family, | ||
|
|
||
| @ManyToMany | ||
| @JoinTable(name = "pet_memory") | ||
| val memories: List<Memory>, | ||
|
Comment on lines
+35
to
+37
Contributor
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. Pet의 profileImage 와 동일하게 생성 시 memories 는 항상 그 값을 초기화 하도록 선언되어, 언제나 빈 리스트가 될 것 같은데 이 경우에는 Default 값을 사용해주는 것이 어떨까요? |
||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @Column(name = "updated_at") | ||
| var updatedAt: LocalDateTime = LocalDateTime.now(), | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.DiscriminatorValue | ||
| import jakarta.persistence.Entity | ||
|
|
||
| @Entity(name = "record_memory") | ||
| @DiscriminatorValue("Record_Memory") | ||
| class RecordMemory( | ||
| id: Int, | ||
| image: String, | ||
| content: String, | ||
| users: Users, | ||
| family: Family, | ||
|
|
||
| ) : Memory(id, image, content, users, family) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.DiscriminatorValue | ||
| import jakarta.persistence.Entity | ||
|
|
||
| @Entity(name = "text_comment") | ||
| @DiscriminatorValue("TextComment") | ||
| class TextComment( | ||
| @Column(name = "content", nullable = false) | ||
| var content: String? = null, | ||
|
Comment on lines
+10
to
+11
Contributor
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. 컬럼 자체에서는 nullable = false 로 null이 들어갈 수 없는 상태로 선언 되었지만 해당 객체는 생성 시 null이 Default Value 로 들어가게 됩니다. 해당 부분에서 발생하는 문제가 있는지 확인해보면 좋을 것 같습니다. |
||
| ) : Comment() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.record.zooc.domain | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.Table | ||
| import jakarta.persistence.UniqueConstraint | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity(name = "users") | ||
| class Users( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id", nullable = false) | ||
| var id: Int = 0, | ||
|
|
||
| @Column(name = "sns_token", nullable = false) | ||
| var snsToken: String, | ||
|
|
||
| @Column(name = "sns_type", nullable = false) | ||
| var snsType: String, | ||
|
|
||
| @Column(name = "user_email", nullable = false) | ||
| var userEmail: String, | ||
|
|
||
| @Column(name = "profile_image") | ||
| var profileImage: String, | ||
|
|
||
| @Column(name = "created_at") | ||
| var createdAt: LocalDateTime = LocalDateTime.now(), | ||
|
|
||
| @Column(name = "updated_at") | ||
| var updatedAt: LocalDateTime = LocalDateTime.now() | ||
| ) | ||
|
Comment on lines
+13
to
+36
Contributor
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. Kotlin 에서는 var 로 선언한 프로퍼티는 자바의 맴버 변수, getter, setter 와 동일한 기능을 합니다. 또한 이를 주 생성자의 파라미터로 둔다면 생성자 또한 생성되게 됩니다. 만약 해당 객체를 생성한 후 임의로 값을 변경할 수 있다면 어떤 일이 발생할까요? |
||
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.
Pet은 등록 시 사진이 없을 수 있는 객체이지 않나요?
만약 현재 Pet Entity 를 생성한다면 profileImage를 받지 않은 경우라면 Pet을 생성조차 못하는 상황으로 보입니다.
Kotlin 에서는 자바와 다르게 Null이 들어갈 수 있는 타입과, Null이 들어갈 수 없는 타입으로 나뉩니다.
String? 과 같은 타입으로 사용하면 Null이 들어갈 수 있는 String 이고 String 으로만 쓴다면 Null이 들어갈 수 없는 String 입니다.
Kotlin 에서는 왜 이것을 나누어 사용하는지 알아보면 좋을 것 같습니다~