From ab1a6c5b509332c17037af4c016ff53ff3cf4221 Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Sun, 26 Mar 2023 20:39:43 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[ADD]=20entity=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 10 ++- .../com/record/zooc/domain/entity/Alarm.kt | 13 ++++ .../domain/entity/BaseTimeEntityCreated.kt | 18 +++++ .../domain/entity/BaseTimeEntityModified.kt | 26 +++++++ .../com/record/zooc/domain/entity/Comment.kt | 19 +++++ .../record/zooc/domain/entity/Emojicomment.kt | 6 ++ .../com/record/zooc/domain/entity/Family.kt | 0 .../com/record/zooc/domain/entity/FcmToken.kt | 1 + .../com/record/zooc/domain/entity/Memory.kt | 25 +++++++ .../record/zooc/domain/entity/Memory_pet.kt | 0 .../zooc/domain/entity/Missionmemory.kt | 10 +++ .../com/record/zooc/domain/entity/Pet.kt | 23 ++++++ .../record/zooc/domain/entity/Recordmemory.kt | 10 +++ .../record/zooc/domain/entity/Textcomment.kt | 6 ++ .../com/record/zooc/domain/entity/User.kt | 72 +++++++++++++++++++ .../record/zooc/domain/entity/User_family.kt | 0 src/main/resources/application-dev.yml | 36 +++++----- src/main/resources/application-prod.yml | 24 +++---- 18 files changed, 266 insertions(+), 33 deletions(-) create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Comment.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Family.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Memory.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Memory_pet.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Pet.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/User.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/User_family.kt diff --git a/build.gradle b/build.gradle index 72fe741..29579ab 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ plugins { id 'org.jetbrains.kotlin.plugin.spring' version '1.7.22' id 'org.jetbrains.kotlin.plugin.jpa' version '1.7.22' id "org.jlleitschuh.gradle.ktlint" version "11.0.0" + id 'kotlin-extension' } group = 'com.record' @@ -17,7 +18,7 @@ repositories { mavenCentral() } -subprojects { +subprojects { //ktlint 적용 린트 repositories { mavenCentral() } @@ -41,7 +42,7 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' } -compileKotlin { +compileKotlin { kotlinOptions { freeCompilerArgs = ['-Xjsr305=strict'] jvmTarget = '17' @@ -49,6 +50,9 @@ compileKotlin { } allOpen { + //JPA 엔티티 만들 때 규칙이 있음 (final 클래스 안돼) + //코틀린은 클래스 기본이 final이야. @Entity 등 annotation이 붙이면 자동으로 final 아니게 설정 + //이렇게 안 하면 모든 클래스에 open을 붙여야됨 annotation("jakarta.persistence.Entity") annotation("jakarta.persistence.MappedSuperclass") annotation("jakarta.persistence.Embeddable") @@ -58,6 +62,6 @@ noArg { annotation("jakarta.persistence.Entity") } -test{ +test { useJUnitPlatform() } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt b/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt new file mode 100644 index 0000000..48513a9 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt @@ -0,0 +1,13 @@ +import com.record.zooc.domain.entity.BaseTimeEntityCreated +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id + +@Entity +class Alarm() : BaseTimeEntityCreated() { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = null + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt b/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt new file mode 100644 index 0000000..7dc06a4 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt @@ -0,0 +1,18 @@ +package com.record.zooc.domain.entity + +import jakarta.persistence.Column +import jakarta.persistence.EntityListeners +import jakarta.persistence.MappedSuperclass +import org.springframework.data.annotation.CreatedDate +import org.springframework.data.jpa.domain.support.AuditingEntityListener +import java.time.LocalDateTime + +@MappedSuperclass +@EntityListeners(AuditingEntityListener::class) +abstract class BaseTimeEntityCreated { + @CreatedDate + @Column(nullable = false, updatable = false) + var createdAt: LocalDateTime = LocalDateTime.now() + protected set + // var로 해야지 시간 저장될 때 오류 안남 +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt b/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt new file mode 100644 index 0000000..0408b92 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt @@ -0,0 +1,26 @@ +package com.record.zooc.domain.entity + +import com.fasterxml.jackson.annotation.JsonFormat +import jakarta.persistence.Column +import jakarta.persistence.EntityListeners +import jakarta.persistence.MappedSuperclass +import org.springframework.data.annotation.CreatedDate +import org.springframework.data.annotation.LastModifiedDate +import org.springframework.data.jpa.domain.support.AuditingEntityListener +import java.time.LocalDateTime + +@MappedSuperclass +@EntityListeners(AuditingEntityListener::class) +abstract class BaseTimeEntityModified { + @CreatedDate + @Column(nullable = false, updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + var createdAt: LocalDateTime = LocalDateTime.now() + protected set + + @LastModifiedDate + @Column(nullable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + var modifiedAt: LocalDateTime = LocalDateTime.now() + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt new file mode 100644 index 0000000..070361b --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt @@ -0,0 +1,19 @@ +import com.record.zooc.domain.entity.BaseTimeEntityModified +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 + +@DiscriminatorColumn(name = "comment_type") +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +class Comment( +) : BaseTimeEntityModified() { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = 0 + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt new file mode 100644 index 0000000..39027da --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt @@ -0,0 +1,6 @@ +import jakarta.persistence.DiscriminatorValue + +@DiscriminatorValue("Emoji") +class Emojicomment( + emoji: Int +) : Comment() diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt b/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt new file mode 100644 index 0000000..a6bca8c --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt @@ -0,0 +1 @@ +class FcmToken() {} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt b/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt new file mode 100644 index 0000000..028fde6 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt @@ -0,0 +1,25 @@ +import com.record.zooc.domain.entity.BaseTimeEntityModified +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 + +@DiscriminatorColumn(name = "mission_type") +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +class Memory( + + @Column + var image: String, + + @Column + var content: String, +) : BaseTimeEntityModified() { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + val id: Long = 0; // ㅜㅜ 이거 어카지... +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Memory_pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Memory_pet.kt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt new file mode 100644 index 0000000..671b1bb --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt @@ -0,0 +1,10 @@ +import jakarta.persistence.DiscriminatorValue + +@DiscriminatorValue("Mission") +class Missionmemory( + image: String, + content: String +) : Memory( + image, + content +) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt new file mode 100644 index 0000000..38b8118 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt @@ -0,0 +1,23 @@ +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id + +@Entity +class Pet( + name: String, +) { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = null + protected set + + @Column(name = "profile_image") + var profileImage: String? = null + protected set + + @Column + var name: String = name + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt new file mode 100644 index 0000000..f137628 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt @@ -0,0 +1,10 @@ +import jakarta.persistence.DiscriminatorValue + +@DiscriminatorValue("Record") +class Recordmemory( + image: String, + content: String +) : Memory( + image, + content +) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt new file mode 100644 index 0000000..e0f2773 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt @@ -0,0 +1,6 @@ +import jakarta.persistence.DiscriminatorValue + +@DiscriminatorValue("Text") +class Textcomment( + content: String +) : Comment() diff --git a/src/main/kotlin/com/record/zooc/domain/entity/User.kt b/src/main/kotlin/com/record/zooc/domain/entity/User.kt new file mode 100644 index 0000000..9194a78 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/User.kt @@ -0,0 +1,72 @@ +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.Table + +// @Builder가 필요한 상황 찾아보기 +// reflection 개념 찾아보기 + +@Entity +@Table(name = "user") +class User( + role: String, + userEmail: String? = null, + profileImage: String? = null, + everRecorded: Boolean = false, + refreshToken: String, + snsToken: String, + snsType: String, +) { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = 0 + protected set + // 객체의 id를 null로 두고 데이터베이스에 insert일어날 때 생성되기 때문에 nullable이어야됨 + + @Column + var role: String = role + protected set + + @Column(name = "user_email") + var userEmail: String? = userEmail + protected set + + @Column(name = "profile_image") + var profileImage: String? = profileImage + protected set + + @Column(name = "ever_recorded") + var everRecorded: Boolean = everRecorded + protected set + + @Column(name = "refresh_token") + var refreshToken: String = refreshToken + protected set + + @Column(name = "sns_token") + var snsToken: String = snsToken + protected set + + @Column(name = "sns_type") + var snsType: String = snsType + protected set + + fun updateUserRoleAndProfile( + role: String? = null, + profileImage: String? = null, + ) { + + if(role != null) this.role = role + + //role이 null이 아니면 this에 role 저장 + role?.let { this.role = it } + profileImage?.let { this.profileImage = it } + } + + fun userRecordedForTheFirstTime() { + this.everRecorded = true + } + +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/User_family.kt b/src/main/kotlin/com/record/zooc/domain/entity/User_family.kt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 67ac92d..cdff020 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,21 +1,21 @@ server: - port: 8082 + port: 8082 spring: - datasource: - driver-class-name: org.postgresql.Driver - url: ${url} - username: ${username} - password: ${password} - jpa: - hibernate: - ddl-auto: update - show-sql: true - database: postgresql - database-platform: org.hibernate.dialect.PostgreSQLDialect - open-in-view: false - generate-ddl: true - properties: - hibernate: - default_schema: dev - format_sql: true + datasource: + driver-class-name: org.postgresql.Driver + url: ${url} + username: ${username} + password: ${password} + jpa: + hibernate: + ddl-auto: update + show-sql: true + database: postgresql + database-platform: org.hibernate.dialect.PostgreSQLDialect + open-in-view: false + generate-ddl: true + properties: + hibernate: + default_schema: dev + format_sql: true diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 6bc3c67..9277c14 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,15 +1,15 @@ server: - port: 8080 + port: 8080 spring: - datasource: - driver-class-name: org.postgresql.Driver - url: ${url} - username: ${username} - password: ${password} - jpa: - database: postgresql - database-platform: org.hibernate.dialect.PostgreSQLDialect - properties: - hibernate: - default_schema: prod + datasource: + driver-class-name: org.postgresql.Driver + url: ${url} + username: ${username} + password: ${password} + jpa: + database: postgresql + database-platform: org.hibernate.dialect.PostgreSQLDialect + properties: + hibernate: + default_schema: prod From c92a4e51f91ed80d3265823f40437818f67b8e5a Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Thu, 30 Mar 2023 21:03:04 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EC=A0=9C=EC=99=B8=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - .../kotlin/com/record/zooc/ZoocApplication.kt | 1 + .../com/record/zooc/domain/entity/Alarm.kt | 28 +++++++++++++++++-- .../com/record/zooc/domain/entity/Comment.kt | 25 +++++++++++++++++ .../record/zooc/domain/entity/Emojicomment.kt | 10 ++++++- .../com/record/zooc/domain/entity/Family.kt | 10 +++++++ .../com/record/zooc/domain/entity/FcmToken.kt | 23 ++++++++++++++- .../com/record/zooc/domain/entity/Memory.kt | 19 +++++++++---- .../com/record/zooc/domain/entity/Mission.kt | 23 +++++++++++++++ .../zooc/domain/entity/Missionmemory.kt | 10 +++++-- .../com/record/zooc/domain/entity/Pet.kt | 11 +++++--- .../record/zooc/domain/entity/Textcomment.kt | 6 ++-- .../com/record/zooc/domain/entity/User.kt | 10 ++----- 13 files changed, 151 insertions(+), 26 deletions(-) create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Mission.kt diff --git a/build.gradle b/build.gradle index 29579ab..e444a7a 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,6 @@ plugins { id 'org.jetbrains.kotlin.plugin.spring' version '1.7.22' id 'org.jetbrains.kotlin.plugin.jpa' version '1.7.22' id "org.jlleitschuh.gradle.ktlint" version "11.0.0" - id 'kotlin-extension' } group = 'com.record' diff --git a/src/main/kotlin/com/record/zooc/ZoocApplication.kt b/src/main/kotlin/com/record/zooc/ZoocApplication.kt index 4c39dbf..c479d78 100644 --- a/src/main/kotlin/com/record/zooc/ZoocApplication.kt +++ b/src/main/kotlin/com/record/zooc/ZoocApplication.kt @@ -8,4 +8,5 @@ class ZoocApplication fun main(args: Array) { runApplication(*args) + } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt b/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt index 48513a9..b1aae4f 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt @@ -1,13 +1,37 @@ import com.record.zooc.domain.entity.BaseTimeEntityCreated +import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue import jakarta.persistence.GenerationType import jakarta.persistence.Id +import jakarta.persistence.Table @Entity -class Alarm() : BaseTimeEntityCreated() { +@Table(name = "alarm") +class Alarm( + userId: Long, + writerId: Long, + familyId: Long, + recordId: Long, +) : BaseTimeEntityCreated() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - var id: Long? = null + var id: Long? = 0 + protected set + + @Column(name = "user_id") + var userId: Long = userId + protected set + + @Column(name = "writer_id") + var writerId: Long = writerId + protected set + + @Column(name = "family_id") + var familyId: Long = familyId + protected set + + @Column(name = "record_id") + var recordId: Long = recordId protected set } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt index 070361b..2deafc8 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt @@ -1,4 +1,5 @@ import com.record.zooc.domain.entity.BaseTimeEntityModified +import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue @@ -6,14 +7,38 @@ import jakarta.persistence.GenerationType import jakarta.persistence.Id import jakarta.persistence.Inheritance import jakarta.persistence.InheritanceType +import jakarta.persistence.Table @DiscriminatorColumn(name = "comment_type") @Entity +@Table(name = "comment") @Inheritance(strategy = InheritanceType.JOINED) class Comment( + content: String, + writerId: Long, + recordId: Int, + ) : BaseTimeEntityModified() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = 0 protected set + + @Column + var content: String = content + protected set + + @Column + var writer: Long = writerId + protected set + + @Column(name = "record_id") + var recordId: Int = recordId + protected set + + fun updateContent( + content: String, + ) { + this.content = content + } } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt index 39027da..65dd6df 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt @@ -1,6 +1,14 @@ +import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Emoji") class Emojicomment( + content: String, + writerId: Long, + recordId: Int, emoji: Int -) : Comment() +) : Comment(content, writerId, recordId) { + @Column + var emoji: Int = emoji + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt index e69de29..62283b6 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt @@ -0,0 +1,10 @@ +package com.record.zooc.domain.entity + +@Entity +class Family { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = 0 + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt b/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt index a6bca8c..55b9928 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt @@ -1 +1,22 @@ -class FcmToken() {} +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.Table + +@Entity +@Table(name = "fcmtoken") +class FcmToken( + userId: Long, + fcmToken: String, +) { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = 0 + protected set + + @Column(name = "fcm_token") + var fcmToken: String = fcmToken + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt b/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt index 028fde6..89a61cb 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt @@ -7,19 +7,26 @@ import jakarta.persistence.GenerationType import jakarta.persistence.Id import jakarta.persistence.Inheritance import jakarta.persistence.InheritanceType +import jakarta.persistence.Table @DiscriminatorColumn(name = "mission_type") @Entity +@Table(name = "memory") @Inheritance(strategy = InheritanceType.JOINED) class Memory( + image: String, + content: String, +) : BaseTimeEntityModified() { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long = 0 + protected set @Column - var image: String, + var image: String = image + protected set @Column - var content: String, -) : BaseTimeEntityModified() { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - val id: Long = 0; // ㅜㅜ 이거 어카지... + var content: String = content + protected set } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Mission.kt b/src/main/kotlin/com/record/zooc/domain/entity/Mission.kt new file mode 100644 index 0000000..439198b --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/Mission.kt @@ -0,0 +1,23 @@ +package com.record.zooc.domain.entity + +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.Table + +@Entity +@Table(name = "mission") +class Mission( + missionContent: String +) { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long? = 0 + protected set + + @Column(name = "mission_content") + var missionContent: String = missionContent + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt index 671b1bb..06a36b7 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt @@ -1,10 +1,16 @@ +import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Mission") class Missionmemory( image: String, - content: String + content: String, + missionId: Int, ) : Memory( image, content -) +) { + @Column(name = "mission_id") + var missionId: Int = missionId + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt index 38b8118..efcaa85 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt @@ -3,21 +3,24 @@ import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue import jakarta.persistence.GenerationType import jakarta.persistence.Id +import jakarta.persistence.Table @Entity +@Table(name = "pet") class Pet( name: String, + profileImage: String? = null ) { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null protected set - @Column(name = "profile_image") - var profileImage: String? = null - protected set - @Column var name: String = name protected set + + @Column(name = "profile_image") + var profileImage: String? = profileImage + protected set } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt index e0f2773..e9c732c 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt @@ -2,5 +2,7 @@ import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Text") class Textcomment( - content: String -) : Comment() + content: String, + writerId: Int, + recordId: Int, +) : Comment(content, writerId, recordId) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/User.kt b/src/main/kotlin/com/record/zooc/domain/entity/User.kt index 9194a78..f85cc95 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/User.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/User.kt @@ -12,12 +12,12 @@ import jakarta.persistence.Table @Table(name = "user") class User( role: String, - userEmail: String? = null, - profileImage: String? = null, everRecorded: Boolean = false, refreshToken: String, snsToken: String, snsType: String, + userEmail: String? = null, + profileImage: String? = null ) { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -57,10 +57,7 @@ class User( role: String? = null, profileImage: String? = null, ) { - - if(role != null) this.role = role - - //role이 null이 아니면 this에 role 저장 + // role이 null이 아니면 this에 role 저장 role?.let { this.role = it } profileImage?.let { this.profileImage = it } } @@ -68,5 +65,4 @@ class User( fun userRecordedForTheFirstTime() { this.everRecorded = true } - } From d6f1c7cab38654ea58bf8b62e30db35b698b9b40 Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Thu, 30 Mar 2023 21:10:20 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=EA=B9=8C=EB=A8=B9=EA=B3=A0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=95=88=20=ED=95=9C=20=EA=B1=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20> Date: Wed, 5 Apr 2023 22:34:10 +0900 Subject: [PATCH 4/8] =?UTF-8?q?Time=20Entity=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=83=81=EC=86=8D=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EC=83=9D=EC=84=B1=20&=20Family=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/record/zooc/domain/entity/Alarm.kt | 4 ++-- .../com/record/zooc/domain/entity/Comment.kt | 4 ++-- .../com/record/zooc/domain/entity/Family.kt | 15 ++++++++++++--- .../com/record/zooc/domain/entity/Memory.kt | 4 ++-- .../kotlin/com/record/zooc/domain/entity/Pet.kt | 1 - .../CreatedTimeEntity.kt} | 6 ++++-- .../ModifiedTimeEntity.kt} | 11 +++-------- 7 files changed, 25 insertions(+), 20 deletions(-) rename src/main/kotlin/com/record/zooc/domain/entity/{BaseTimeEntityCreated.kt => time/CreatedTimeEntity.kt} (75%) rename src/main/kotlin/com/record/zooc/domain/entity/{BaseTimeEntityModified.kt => time/ModifiedTimeEntity.kt} (64%) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt b/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt index b1aae4f..e930f83 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt @@ -1,4 +1,4 @@ -import com.record.zooc.domain.entity.BaseTimeEntityCreated +import com.record.zooc.domain.entity.time.CreatedTimeEntity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue @@ -13,7 +13,7 @@ class Alarm( writerId: Long, familyId: Long, recordId: Long, -) : BaseTimeEntityCreated() { +) : CreatedTimeEntity() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = 0 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt b/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt index 2deafc8..da9c140 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt @@ -1,4 +1,4 @@ -import com.record.zooc.domain.entity.BaseTimeEntityModified +import com.record.zooc.domain.entity.time.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn import jakarta.persistence.Entity @@ -18,7 +18,7 @@ class Comment( writerId: Long, recordId: Int, -) : BaseTimeEntityModified() { +) : ModifiedTimeEntity() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = 0 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt index 62283b6..e19a6d7 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt @@ -1,10 +1,19 @@ -package com.record.zooc.domain.entity +import com.record.zooc.domain.entity.time.ModifiedTimeEntity +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id @Entity -class Family { - +class Family( + code: String, +) : ModifiedTimeEntity() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = 0 protected set + + @Column + val code: String = code } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt b/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt index 89a61cb..bd57582 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt @@ -1,4 +1,4 @@ -import com.record.zooc.domain.entity.BaseTimeEntityModified +import com.record.zooc.domain.entity.time.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn import jakarta.persistence.Entity @@ -16,7 +16,7 @@ import jakarta.persistence.Table class Memory( image: String, content: String, -) : BaseTimeEntityModified() { +) : ModifiedTimeEntity() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long = 0 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt index efcaa85..e6e5e57 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt @@ -14,7 +14,6 @@ class Pet( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null - protected set @Column var name: String = name diff --git a/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt b/src/main/kotlin/com/record/zooc/domain/entity/time/CreatedTimeEntity.kt similarity index 75% rename from src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt rename to src/main/kotlin/com/record/zooc/domain/entity/time/CreatedTimeEntity.kt index 7dc06a4..9fd9ae0 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityCreated.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/time/CreatedTimeEntity.kt @@ -1,5 +1,6 @@ -package com.record.zooc.domain.entity +package com.record.zooc.domain.entity.time +import com.fasterxml.jackson.annotation.JsonFormat import jakarta.persistence.Column import jakarta.persistence.EntityListeners import jakarta.persistence.MappedSuperclass @@ -9,9 +10,10 @@ import java.time.LocalDateTime @MappedSuperclass @EntityListeners(AuditingEntityListener::class) -abstract class BaseTimeEntityCreated { +abstract class CreatedTimeEntity { @CreatedDate @Column(nullable = false, updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") var createdAt: LocalDateTime = LocalDateTime.now() protected set // var로 해야지 시간 저장될 때 오류 안남 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt b/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt similarity index 64% rename from src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt rename to src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt index 0408b92..b887551 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/BaseTimeEntityModified.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt @@ -1,22 +1,17 @@ -package com.record.zooc.domain.entity +package com.record.zooc.domain.entity.time import com.fasterxml.jackson.annotation.JsonFormat +import com.record.zooc.domain.entity.time.CreatedTimeEntity import jakarta.persistence.Column import jakarta.persistence.EntityListeners import jakarta.persistence.MappedSuperclass -import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedDate import org.springframework.data.jpa.domain.support.AuditingEntityListener import java.time.LocalDateTime @MappedSuperclass @EntityListeners(AuditingEntityListener::class) -abstract class BaseTimeEntityModified { - @CreatedDate - @Column(nullable = false, updatable = false) - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - var createdAt: LocalDateTime = LocalDateTime.now() - protected set +abstract class ModifiedTimeEntity : CreatedTimeEntity() { @LastModifiedDate @Column(nullable = false) From 2d40e98e6132dc1a4c75b6e28bd5088aade01b1b Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Tue, 11 Apr 2023 23:33:18 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=ED=8B=B0..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/record/zooc/ZoocApplication.kt | 1 - .../com/record/zooc/domain/entity/Family.kt | 5 ++ .../record/zooc/domain/entity/Memory_pet.kt | 0 .../com/record/zooc/domain/entity/Pet.kt | 6 ++ .../com/record/zooc/domain/entity/User.kt | 5 ++ .../record/zooc/domain/entity/User_family.kt | 0 .../domain/entity/{ => comment}/Comment.kt | 2 + .../entity/{ => comment}/Emojicomment.kt | 2 + .../entity/{ => comment}/Textcomment.kt | 2 + .../domain/entity/hi/MemoryPetRelation.kt | 56 +++++++++++++++++++ .../domain/entity/hi/UserFamilyRelation.kt | 54 ++++++++++++++++++ .../zooc/domain/entity/{ => memory}/Memory.kt | 10 +++- .../domain/entity/{ => memory}/Mission.kt | 2 +- .../entity/{ => memory}/Missionmemory.kt | 2 + .../entity/{ => memory}/Recordmemory.kt | 2 + .../domain/entity/{ => pushAlarm}/Alarm.kt | 2 + .../domain/entity/{ => pushAlarm}/FcmToken.kt | 2 + .../domain/entity/time/ModifiedTimeEntity.kt | 1 - .../zooc/domain/repository/UserRepository.kt | 6 ++ 19 files changed, 156 insertions(+), 4 deletions(-) delete mode 100644 src/main/kotlin/com/record/zooc/domain/entity/Memory_pet.kt delete mode 100644 src/main/kotlin/com/record/zooc/domain/entity/User_family.kt rename src/main/kotlin/com/record/zooc/domain/entity/{ => comment}/Comment.kt (95%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => comment}/Emojicomment.kt (86%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => comment}/Textcomment.kt (80%) create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt create mode 100644 src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt rename src/main/kotlin/com/record/zooc/domain/entity/{ => memory}/Memory.kt (76%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => memory}/Mission.kt (91%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => memory}/Missionmemory.kt (87%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => memory}/Recordmemory.kt (78%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => pushAlarm}/Alarm.kt (94%) rename src/main/kotlin/com/record/zooc/domain/entity/{ => pushAlarm}/FcmToken.kt (91%) create mode 100644 src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt diff --git a/src/main/kotlin/com/record/zooc/ZoocApplication.kt b/src/main/kotlin/com/record/zooc/ZoocApplication.kt index c479d78..4c39dbf 100644 --- a/src/main/kotlin/com/record/zooc/ZoocApplication.kt +++ b/src/main/kotlin/com/record/zooc/ZoocApplication.kt @@ -8,5 +8,4 @@ class ZoocApplication fun main(args: Array) { runApplication(*args) - } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt index e19a6d7..d0a7a5b 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt @@ -4,6 +4,7 @@ import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue import jakarta.persistence.GenerationType import jakarta.persistence.Id +import jakarta.persistence.OneToMany @Entity class Family( @@ -16,4 +17,8 @@ class Family( @Column val code: String = code + + @OneToMany(mappedBy = "family") + var relationsWithUser: ArrayList = ArrayList() + protected set } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Memory_pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Memory_pet.kt deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt index e6e5e57..f69cb70 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt @@ -3,6 +3,7 @@ import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue import jakarta.persistence.GenerationType import jakarta.persistence.Id +import jakarta.persistence.OneToMany import jakarta.persistence.Table @Entity @@ -22,4 +23,9 @@ class Pet( @Column(name = "profile_image") var profileImage: String? = profileImage protected set + + @OneToMany(mappedBy = "pet") + var relationsWithMemory: ArrayList = ArrayList() + protected set + } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/User.kt b/src/main/kotlin/com/record/zooc/domain/entity/User.kt index f85cc95..ffac23d 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/User.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/User.kt @@ -3,6 +3,7 @@ import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue import jakarta.persistence.GenerationType import jakarta.persistence.Id +import jakarta.persistence.OneToMany import jakarta.persistence.Table // @Builder가 필요한 상황 찾아보기 @@ -53,6 +54,10 @@ class User( var snsType: String = snsType protected set + @OneToMany(mappedBy = "user") + var relationsWithFamily: ArrayList = ArrayList() + protected set + fun updateUserRoleAndProfile( role: String? = null, profileImage: String? = null, diff --git a/src/main/kotlin/com/record/zooc/domain/entity/User_family.kt b/src/main/kotlin/com/record/zooc/domain/entity/User_family.kt deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt b/src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt similarity index 95% rename from src/main/kotlin/com/record/zooc/domain/entity/Comment.kt rename to src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt index da9c140..594f525 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Comment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.comment + import com.record.zooc.domain.entity.time.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt similarity index 86% rename from src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt rename to src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt index 65dd6df..f1400dd 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Emojicomment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.comment + import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt similarity index 80% rename from src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt rename to src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt index a5349ad..f81e27d 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Textcomment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.comment + import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Text") diff --git a/src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt b/src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt new file mode 100644 index 0000000..ec32d83 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt @@ -0,0 +1,56 @@ +import com.record.zooc.domain.entity.memory.Memory +import jakarta.persistence.Column +import jakarta.persistence.Embeddable +import jakarta.persistence.EmbeddedId +import jakarta.persistence.Entity +import jakarta.persistence.JoinColumn +import jakarta.persistence.ManyToOne +import jakarta.persistence.MapsId +import jakarta.persistence.Table +import java.io.Serializable + +@Embeddable +class MemoryPetRelationId( + memoryId: Long?, + petId: Long? +) : Serializable { + // 사실 이게 notnull인게 맞는데... Memory에 id가 nullable이다보니까... + + @Column(name = "memory_id", nullable = false) + val memoryId = memoryId + + @Column(name = "pet_id", nullable = false) + val petId = petId + + override fun equals(other: Any?): Boolean { + return super.equals(other) + // 구현 예정 + } + + override fun hashCode(): Int { + return super.hashCode() + // 구현 예정 + } +} + +@Entity +@Table(name = "memory_pet") +class MemoryPetRelation(memory: Memory, pet: Pet) { + + @EmbeddedId + var memoryPetId: MemoryPetRelationId = MemoryPetRelationId(memory.id, pet.id) + protected set + + @MapsId("memory_id") + @ManyToOne + @JoinColumn(name = "memory_id") + var memory: Memory = memory + protected set + + @MapsId("pet_id") + @ManyToOne + @JoinColumn(name = "pet_id") + var pet: Pet = pet + protected set +} + diff --git a/src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt b/src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt new file mode 100644 index 0000000..8903d94 --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt @@ -0,0 +1,54 @@ +import jakarta.persistence.Column +import jakarta.persistence.Embeddable +import jakarta.persistence.EmbeddedId +import jakarta.persistence.Entity +import jakarta.persistence.Id +import jakarta.persistence.JoinColumn +import jakarta.persistence.ManyToOne +import jakarta.persistence.Table +import java.io.Serializable + +@Embeddable +class UserFamilyRelationId( + userId: Long?, + familyId: Long? +) : Serializable { + // 사실 이게 notnull인게 맞는데... Memory에 id가 nullable이다보니까... + + @Column(name = "user_id", nullable = false) + val userId = userId + + @Column(name = "family_id", nullable = false) + val familyId = familyId + + override fun equals(other: Any?): Boolean { + return super.equals(other) + // 구현 예정 + } + + override fun hashCode(): Int { + return super.hashCode() + // 구현 예정 + } +} + +@Entity +@Table(name = "user_family") +class UserFamilyRelation(user: User, family: Family) { + + @EmbeddedId + var userFamilyId = UserFamilyRelationId(user.id, family.id) + protected set + + @Id + @ManyToOne + @JoinColumn(name = "user_id") + var user: User = user + protected set + + @Id + @ManyToOne + @JoinColumn(name = "family_id") + var family: Family = family + protected set +} diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt similarity index 76% rename from src/main/kotlin/com/record/zooc/domain/entity/Memory.kt rename to src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt index bd57582..f95ad4b 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Memory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt @@ -1,3 +1,6 @@ +package com.record.zooc.domain.entity.memory + +import MemoryPetRelation import com.record.zooc.domain.entity.time.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn @@ -7,6 +10,7 @@ import jakarta.persistence.GenerationType import jakarta.persistence.Id import jakarta.persistence.Inheritance import jakarta.persistence.InheritanceType +import jakarta.persistence.OneToMany import jakarta.persistence.Table @DiscriminatorColumn(name = "mission_type") @@ -19,7 +23,7 @@ class Memory( ) : ModifiedTimeEntity() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - var id: Long = 0 + var id: Long? = 0 protected set @Column @@ -29,4 +33,8 @@ class Memory( @Column var content: String = content protected set + + @OneToMany(mappedBy = "memory") + var relationsWithPet: ArrayList = ArrayList() + protected set } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Mission.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Mission.kt similarity index 91% rename from src/main/kotlin/com/record/zooc/domain/entity/Mission.kt rename to src/main/kotlin/com/record/zooc/domain/entity/memory/Mission.kt index 439198b..f904700 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Mission.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Mission.kt @@ -1,4 +1,4 @@ -package com.record.zooc.domain.entity +package com.record.zooc.domain.entity.memory import jakarta.persistence.Column import jakarta.persistence.Entity diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt similarity index 87% rename from src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt rename to src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt index 06a36b7..b01b0f7 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Missionmemory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.memory + import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt similarity index 78% rename from src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt rename to src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt index f137628..8907b5d 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Recordmemory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.memory + import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Record") diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt similarity index 94% rename from src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt rename to src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt index e930f83..7b12ede 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Alarm.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.pushAlarm + import com.record.zooc.domain.entity.time.CreatedTimeEntity import jakarta.persistence.Column import jakarta.persistence.Entity diff --git a/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt similarity index 91% rename from src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt rename to src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt index 55b9928..a51d43a 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/FcmToken.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt @@ -1,3 +1,5 @@ +package com.record.zooc.domain.entity.pushAlarm + import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue diff --git a/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt b/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt index b887551..1890469 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt @@ -1,7 +1,6 @@ package com.record.zooc.domain.entity.time import com.fasterxml.jackson.annotation.JsonFormat -import com.record.zooc.domain.entity.time.CreatedTimeEntity import jakarta.persistence.Column import jakarta.persistence.EntityListeners import jakarta.persistence.MappedSuperclass diff --git a/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt b/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt new file mode 100644 index 0000000..25b0eaa --- /dev/null +++ b/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt @@ -0,0 +1,6 @@ +package com.record.zooc.domain.repository + +import User +import org.springframework.data.jpa.repository.JpaRepository + +interface UserRepository : JpaRepository From c348e614cdc76b5963f7e3a02d623e03a29a8048 Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Sat, 10 Jun 2023 18:54:21 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[FIX]=20comment=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EC=97=90=20=EC=9E=91=EC=84=B1=EC=9E=90=20join=20?= =?UTF-8?q?=EC=B0=B8=EC=A1=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../zooc/domain/entity/{User.kt => Account.kt} | 9 ++++++--- .../com/record/zooc/domain/entity/Family.kt | 5 ++++- .../com/record/zooc/domain/entity/Pet.kt | 4 +++- .../entity/{time => base}/CreatedTimeEntity.kt | 2 +- .../{time => base}/ModifiedTimeEntity.kt | 2 +- .../zooc/domain/entity/comment/Comment.kt | 18 +++++++++++------- .../zooc/domain/entity/comment/Emojicomment.kt | 5 +++-- .../zooc/domain/entity/comment/Textcomment.kt | 5 +++-- .../record/zooc/domain/entity/memory/Memory.kt | 4 ++-- .../zooc/domain/entity/pushAlarm/Alarm.kt | 2 +- .../{hi => relation}/MemoryPetRelation.kt | 4 +++- .../{hi => relation}/UserFamilyRelation.kt | 16 ++++++++++------ .../zooc/domain/repository/UserRepository.kt | 12 ++++++------ 14 files changed, 55 insertions(+), 34 deletions(-) rename src/main/kotlin/com/record/zooc/domain/entity/{User.kt => Account.kt} (91%) rename src/main/kotlin/com/record/zooc/domain/entity/{time => base}/CreatedTimeEntity.kt (94%) rename src/main/kotlin/com/record/zooc/domain/entity/{time => base}/ModifiedTimeEntity.kt (93%) rename src/main/kotlin/com/record/zooc/domain/entity/{hi => relation}/MemoryPetRelation.kt (93%) rename src/main/kotlin/com/record/zooc/domain/entity/{hi => relation}/UserFamilyRelation.kt (74%) diff --git a/.gitignore b/.gitignore index c2065bc..0e65c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ bin/ out/ !**/src/main/**/out/ !**/src/test/**/out/ +src/test/resources/application.yml ### NetBeans ### /nbproject/private/ diff --git a/src/main/kotlin/com/record/zooc/domain/entity/User.kt b/src/main/kotlin/com/record/zooc/domain/entity/Account.kt similarity index 91% rename from src/main/kotlin/com/record/zooc/domain/entity/User.kt rename to src/main/kotlin/com/record/zooc/domain/entity/Account.kt index ffac23d..336d27e 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/User.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Account.kt @@ -1,3 +1,6 @@ +package com.record.zooc.domain.entity + +import com.record.zooc.domain.entity.relation.UserFamilyRelation import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue @@ -10,8 +13,8 @@ import jakarta.persistence.Table // reflection 개념 찾아보기 @Entity -@Table(name = "user") -class User( +@Table(name = "account") +class Account( role: String, everRecorded: Boolean = false, refreshToken: String, @@ -54,7 +57,7 @@ class User( var snsType: String = snsType protected set - @OneToMany(mappedBy = "user") + @OneToMany(mappedBy = "account") var relationsWithFamily: ArrayList = ArrayList() protected set diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt index d0a7a5b..1c0fa0f 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Family.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Family.kt @@ -1,4 +1,7 @@ -import com.record.zooc.domain.entity.time.ModifiedTimeEntity +package com.record.zooc.domain.entity + +import com.record.zooc.domain.entity.relation.UserFamilyRelation +import com.record.zooc.domain.entity.base.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue diff --git a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt index f69cb70..d392948 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/Pet.kt @@ -1,3 +1,6 @@ +package com.record.zooc.domain.entity + +import com.record.zooc.domain.entity.relation.MemoryPetRelation import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue @@ -27,5 +30,4 @@ class Pet( @OneToMany(mappedBy = "pet") var relationsWithMemory: ArrayList = ArrayList() protected set - } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/time/CreatedTimeEntity.kt b/src/main/kotlin/com/record/zooc/domain/entity/base/CreatedTimeEntity.kt similarity index 94% rename from src/main/kotlin/com/record/zooc/domain/entity/time/CreatedTimeEntity.kt rename to src/main/kotlin/com/record/zooc/domain/entity/base/CreatedTimeEntity.kt index 9fd9ae0..3ac4e89 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/time/CreatedTimeEntity.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/base/CreatedTimeEntity.kt @@ -1,4 +1,4 @@ -package com.record.zooc.domain.entity.time +package com.record.zooc.domain.entity.base import com.fasterxml.jackson.annotation.JsonFormat import jakarta.persistence.Column diff --git a/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt b/src/main/kotlin/com/record/zooc/domain/entity/base/ModifiedTimeEntity.kt similarity index 93% rename from src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt rename to src/main/kotlin/com/record/zooc/domain/entity/base/ModifiedTimeEntity.kt index 1890469..b12622e 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/time/ModifiedTimeEntity.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/base/ModifiedTimeEntity.kt @@ -1,4 +1,4 @@ -package com.record.zooc.domain.entity.time +package com.record.zooc.domain.entity.base import com.fasterxml.jackson.annotation.JsonFormat import jakarta.persistence.Column diff --git a/src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt b/src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt index 594f525..fee5ca8 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/comment/Comment.kt @@ -1,6 +1,7 @@ package com.record.zooc.domain.entity.comment -import com.record.zooc.domain.entity.time.ModifiedTimeEntity +import com.record.zooc.domain.entity.Account +import com.record.zooc.domain.entity.base.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn import jakarta.persistence.Entity @@ -9,6 +10,8 @@ import jakarta.persistence.GenerationType import jakarta.persistence.Id import jakarta.persistence.Inheritance import jakarta.persistence.InheritanceType +import jakarta.persistence.JoinColumn +import jakarta.persistence.OneToOne import jakarta.persistence.Table @DiscriminatorColumn(name = "comment_type") @@ -17,8 +20,8 @@ import jakarta.persistence.Table @Inheritance(strategy = InheritanceType.JOINED) class Comment( content: String, - writerId: Long, - recordId: Int, + account: Account, + memoryId: Int, ) : ModifiedTimeEntity() { @Id @@ -30,12 +33,13 @@ class Comment( var content: String = content protected set - @Column - var writer: Long = writerId + @OneToOne + @JoinColumn(name = "writer_id") + var writer: Account = account protected set - @Column(name = "record_id") - var recordId: Int = recordId + @Column + var memoryId: Int = memoryId protected set fun updateContent( diff --git a/src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt index f1400dd..9a7a157 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/comment/Emojicomment.kt @@ -1,15 +1,16 @@ package com.record.zooc.domain.entity.comment +import com.record.zooc.domain.entity.Account import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Emoji") class Emojicomment( content: String, - writerId: Long, + account: Account, recordId: Int, emoji: Int -) : Comment(content, writerId, recordId) { +) : Comment(content, account, recordId) { @Column var emoji: Int = emoji protected set diff --git a/src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt b/src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt index f81e27d..bd46e2c 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/comment/Textcomment.kt @@ -1,10 +1,11 @@ package com.record.zooc.domain.entity.comment +import com.record.zooc.domain.entity.Account import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Text") class Textcomment( content: String, - writerId: Long, + account: Account, recordId: Int, -) : Comment(content, writerId, recordId) +) : Comment(content, account, recordId) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt index f95ad4b..faac6f7 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt @@ -1,7 +1,7 @@ package com.record.zooc.domain.entity.memory -import MemoryPetRelation -import com.record.zooc.domain.entity.time.ModifiedTimeEntity +import com.record.zooc.domain.entity.relation.MemoryPetRelation +import com.record.zooc.domain.entity.base.ModifiedTimeEntity import jakarta.persistence.Column import jakarta.persistence.DiscriminatorColumn import jakarta.persistence.Entity diff --git a/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt index 7b12ede..1333eda 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/Alarm.kt @@ -1,6 +1,6 @@ package com.record.zooc.domain.entity.pushAlarm -import com.record.zooc.domain.entity.time.CreatedTimeEntity +import com.record.zooc.domain.entity.base.CreatedTimeEntity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.GeneratedValue diff --git a/src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt b/src/main/kotlin/com/record/zooc/domain/entity/relation/MemoryPetRelation.kt similarity index 93% rename from src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt rename to src/main/kotlin/com/record/zooc/domain/entity/relation/MemoryPetRelation.kt index ec32d83..93ef315 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/hi/MemoryPetRelation.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/relation/MemoryPetRelation.kt @@ -1,3 +1,6 @@ +package com.record.zooc.domain.entity.relation + +import com.record.zooc.domain.entity.Pet import com.record.zooc.domain.entity.memory.Memory import jakarta.persistence.Column import jakarta.persistence.Embeddable @@ -53,4 +56,3 @@ class MemoryPetRelation(memory: Memory, pet: Pet) { var pet: Pet = pet protected set } - diff --git a/src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt b/src/main/kotlin/com/record/zooc/domain/entity/relation/UserFamilyRelation.kt similarity index 74% rename from src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt rename to src/main/kotlin/com/record/zooc/domain/entity/relation/UserFamilyRelation.kt index 8903d94..5a30c66 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/hi/UserFamilyRelation.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/relation/UserFamilyRelation.kt @@ -1,10 +1,14 @@ +package com.record.zooc.domain.entity.relation + +import com.record.zooc.domain.entity.Family +import com.record.zooc.domain.entity.Account import jakarta.persistence.Column import jakarta.persistence.Embeddable import jakarta.persistence.EmbeddedId import jakarta.persistence.Entity -import jakarta.persistence.Id import jakarta.persistence.JoinColumn import jakarta.persistence.ManyToOne +import jakarta.persistence.MapsId import jakarta.persistence.Table import java.io.Serializable @@ -34,19 +38,19 @@ class UserFamilyRelationId( @Entity @Table(name = "user_family") -class UserFamilyRelation(user: User, family: Family) { +class UserFamilyRelation(account: Account, family: Family) { @EmbeddedId - var userFamilyId = UserFamilyRelationId(user.id, family.id) + var userFamilyId = UserFamilyRelationId(account.id, family.id) protected set - @Id + @MapsId("user_id") @ManyToOne @JoinColumn(name = "user_id") - var user: User = user + var account: Account = account protected set - @Id + @MapsId("family_id") @ManyToOne @JoinColumn(name = "family_id") var family: Family = family diff --git a/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt b/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt index 25b0eaa..ca45788 100644 --- a/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt +++ b/src/main/kotlin/com/record/zooc/domain/repository/UserRepository.kt @@ -1,6 +1,6 @@ -package com.record.zooc.domain.repository - -import User -import org.springframework.data.jpa.repository.JpaRepository - -interface UserRepository : JpaRepository +// package com.record.zooc.domain.repository +// +// import com.record.zooc.domain.entity.User +// import org.springframework.data.jpa.repository.JpaRepository +// +// interface UserRepository : JpaRepository From d27c3a4a9cc289305dd4f0b8bb6428733ae3f525 Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Sun, 11 Jun 2023 14:31:47 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[FIX]=20memory=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=EC=9E=90=20=EC=B0=B8=EC=A1=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/record/zooc/domain/entity/memory/Memory.kt | 12 +++++++++++- .../zooc/domain/entity/memory/Missionmemory.kt | 5 ++++- .../record/zooc/domain/entity/memory/Recordmemory.kt | 7 +++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt index faac6f7..e68a367 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Memory.kt @@ -1,5 +1,6 @@ package com.record.zooc.domain.entity.memory +import com.record.zooc.domain.entity.Account import com.record.zooc.domain.entity.relation.MemoryPetRelation import com.record.zooc.domain.entity.base.ModifiedTimeEntity import jakarta.persistence.Column @@ -10,16 +11,19 @@ import jakarta.persistence.GenerationType import jakarta.persistence.Id import jakarta.persistence.Inheritance import jakarta.persistence.InheritanceType +import jakarta.persistence.JoinColumn import jakarta.persistence.OneToMany +import jakarta.persistence.OneToOne import jakarta.persistence.Table -@DiscriminatorColumn(name = "mission_type") +@DiscriminatorColumn(name = "memory_type") @Entity @Table(name = "memory") @Inheritance(strategy = InheritanceType.JOINED) class Memory( image: String, content: String, + writer: Account ) : ModifiedTimeEntity() { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -35,6 +39,12 @@ class Memory( protected set @OneToMany(mappedBy = "memory") + @JoinColumn(name = "memory_pet") var relationsWithPet: ArrayList = ArrayList() protected set + + @OneToOne + @JoinColumn(name = "writer_id") + var writer: Account = writer + protected set } diff --git a/src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt index b01b0f7..735f2e3 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Missionmemory.kt @@ -1,5 +1,6 @@ package com.record.zooc.domain.entity.memory +import com.record.zooc.domain.entity.Account import jakarta.persistence.Column import jakarta.persistence.DiscriminatorValue @@ -8,9 +9,11 @@ class Missionmemory( image: String, content: String, missionId: Int, + writer: Account ) : Memory( image, - content + content, + writer ) { @Column(name = "mission_id") var missionId: Int = missionId diff --git a/src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt b/src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt index 8907b5d..5aa30f2 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/memory/Recordmemory.kt @@ -1,12 +1,15 @@ package com.record.zooc.domain.entity.memory +import com.record.zooc.domain.entity.Account import jakarta.persistence.DiscriminatorValue @DiscriminatorValue("Record") class Recordmemory( image: String, - content: String + content: String, + writer: Account ) : Memory( image, - content + content, + writer ) From b088acee25fcd3983633c887fb2ef539efd0427a Mon Sep 17 00:00:00 2001 From: sunseo18 Date: Sun, 11 Jun 2023 14:32:17 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[ADD]=20=ED=91=B8=EC=8B=9C=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EC=84=A4=EC=A0=95=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/record/zooc/domain/entity/pushAlarm/FcmToken.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt index a51d43a..912b83d 100644 --- a/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt +++ b/src/main/kotlin/com/record/zooc/domain/entity/pushAlarm/FcmToken.kt @@ -10,8 +10,8 @@ import jakarta.persistence.Table @Entity @Table(name = "fcmtoken") class FcmToken( - userId: Long, fcmToken: String, + setting: Boolean, ) { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -21,4 +21,8 @@ class FcmToken( @Column(name = "fcm_token") var fcmToken: String = fcmToken protected set + + @Column + var setting: Boolean = setting + protected set }