-
Notifications
You must be signed in to change notification settings - Fork 0
타임캡슐 도메인 엔티티 및 리포지토리 구성 #11
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
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
55 changes: 55 additions & 0 deletions
55
src/main/kotlin/team/cklob/mudda/domain/block/domain/entity/Block.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,55 @@ | ||
| package team.cklob.mudda.domain.block.domain.entity | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.FetchType | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.ManyToOne | ||
| import jakarta.persistence.PrePersist | ||
| import jakarta.persistence.Table | ||
| import jakarta.persistence.UniqueConstraint | ||
| import team.cklob.mudda.domain.member.domain.entity.Member | ||
| import team.cklob.mudda.domain.member.domain.type.ProfileVisibility | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity | ||
| @Table( | ||
| name = "tbl_block", | ||
| uniqueConstraints = [ | ||
| UniqueConstraint( | ||
| name = "uq_block_blocker_blocked", | ||
| columnNames = ["blocker_id", "blocked_id"], | ||
| ), | ||
| ], | ||
| ) | ||
| class Block( | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "blocker_id", nullable = false) | ||
| val blocker: Member, | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "blocked_id", nullable = false) | ||
| val blocked: Member, | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| val id: Long? = null, | ||
| ) { | ||
| @Column(name = "created_at", nullable = false) | ||
| var createdAt: LocalDateTime = LocalDateTime.now() | ||
| protected set | ||
|
|
||
| protected constructor() : this(emptyMember(), emptyMember()) | ||
|
|
||
| @PrePersist | ||
| fun prePersist() { | ||
| createdAt = LocalDateTime.now() | ||
| } | ||
|
|
||
| companion object { | ||
| private fun emptyMember() = Member("", "", "", null, null, ProfileVisibility.PRIVATE) | ||
| } | ||
| } | ||
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/team/cklob/mudda/domain/block/domain/repository/BlockRepository.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,9 @@ | ||
| package team.cklob.mudda.domain.block.domain.repository | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import team.cklob.mudda.domain.block.domain.entity.Block | ||
|
|
||
| interface BlockRepository : JpaRepository<Block, Long> { | ||
| fun existsByBlockerIdAndBlockedId(blockerId: Long, blockedId: Long): Boolean | ||
| fun findByBlockerId(blockerId: Long): List<Block> | ||
| } |
65 changes: 65 additions & 0 deletions
65
src/main/kotlin/team/cklob/mudda/domain/friend/domain/entity/Friend.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,65 @@ | ||
| package team.cklob.mudda.domain.friend.domain.entity | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.EnumType | ||
| import jakarta.persistence.Enumerated | ||
| import jakarta.persistence.FetchType | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.ManyToOne | ||
| import jakarta.persistence.PrePersist | ||
| import jakarta.persistence.Table | ||
| import jakarta.persistence.UniqueConstraint | ||
| import team.cklob.mudda.domain.friend.domain.type.FriendStatus | ||
| import team.cklob.mudda.domain.member.domain.entity.Member | ||
| import team.cklob.mudda.domain.member.domain.type.ProfileVisibility | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity | ||
| @Table( | ||
| name = "tbl_friend", | ||
| uniqueConstraints = [ | ||
| UniqueConstraint( | ||
| name = "uq_friend_requester_receiver", | ||
| columnNames = ["requester_id", "receiver_id"], | ||
| ), | ||
| ], | ||
| ) | ||
| class Friend( | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "requester_id", nullable = false) | ||
| val requester: Member, | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "receiver_id", nullable = false) | ||
| val receiver: Member, | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false, length = 20) | ||
| val status: FriendStatus, | ||
|
|
||
| @Column(name = "accepted_at") | ||
| val acceptedAt: LocalDateTime? = null, | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| val id: Long? = null, | ||
| ) { | ||
| @Column(name = "created_at", nullable = false) | ||
| var createdAt: LocalDateTime = LocalDateTime.now() | ||
| protected set | ||
|
|
||
| protected constructor() : this(emptyMember(), emptyMember(), FriendStatus.PENDING, null) | ||
|
|
||
| @PrePersist | ||
| fun prePersist() { | ||
| createdAt = LocalDateTime.now() | ||
| } | ||
|
|
||
| companion object { | ||
| private fun emptyMember() = Member("", "", "", null, null, ProfileVisibility.PRIVATE) | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/team/cklob/mudda/domain/friend/domain/repository/FriendRepository.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,11 @@ | ||
| package team.cklob.mudda.domain.friend.domain.repository | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import team.cklob.mudda.domain.friend.domain.entity.Friend | ||
| import java.util.Optional | ||
|
|
||
| interface FriendRepository : JpaRepository<Friend, Long> { | ||
| fun findByRequesterIdOrReceiverId(requesterId: Long, receiverId: Long): List<Friend> | ||
| fun findByRequesterIdAndReceiverId(requesterId: Long, receiverId: Long): Optional<Friend> | ||
| fun existsByRequesterIdAndReceiverId(requesterId: Long, receiverId: Long): Boolean | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/team/cklob/mudda/domain/friend/domain/type/FriendStatus.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,7 @@ | ||
| package team.cklob.mudda.domain.friend.domain.type | ||
|
|
||
| enum class FriendStatus { | ||
| PENDING, | ||
| ACCEPTED, | ||
| REJECTED, | ||
| } |
76 changes: 76 additions & 0 deletions
76
src/main/kotlin/team/cklob/mudda/domain/media/domain/entity/Media.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,76 @@ | ||
| package team.cklob.mudda.domain.media.domain.entity | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.EnumType | ||
| import jakarta.persistence.Enumerated | ||
| import jakarta.persistence.FetchType | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.ManyToOne | ||
| import jakarta.persistence.PrePersist | ||
| import jakarta.persistence.Table | ||
| import team.cklob.mudda.domain.media.domain.type.MediaType | ||
| import team.cklob.mudda.domain.member.domain.entity.Member | ||
| import team.cklob.mudda.domain.member.domain.type.ProfileVisibility | ||
| import team.cklob.mudda.domain.timecapsule.domain.entity.TimeCapsule | ||
| import team.cklob.mudda.domain.timecapsule.domain.type.CapsuleLockType | ||
| import team.cklob.mudda.domain.timecapsule.domain.type.CapsuleVisibility | ||
| import team.cklob.mudda.domain.timecapsule.domain.type.TimeCapsuleType | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity | ||
| @Table(name = "tbl_media") | ||
| class Media( | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "time_capsule_id", nullable = false) | ||
| val timeCapsule: TimeCapsule, | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "media_type", nullable = false, length = 20) | ||
| val mediaType: MediaType, | ||
|
|
||
| @Column(name = "media_url", nullable = false, length = 255) | ||
| val mediaUrl: String, | ||
|
|
||
| @Column(name = "s3_key", nullable = false, length = 255) | ||
| val s3Key: String, | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| val id: Long? = null, | ||
| ) { | ||
| @Column(name = "created_at", nullable = false) | ||
| var createdAt: LocalDateTime = LocalDateTime.now() | ||
| protected set | ||
|
|
||
| protected constructor() : this(emptyTimeCapsule(), MediaType.IMAGE, "", "") | ||
|
|
||
| @PrePersist | ||
| fun prePersist() { | ||
| createdAt = LocalDateTime.now() | ||
| } | ||
|
|
||
| companion object { | ||
| private fun emptyTimeCapsule() = TimeCapsule( | ||
| Member("", "", "", null, null, ProfileVisibility.PRIVATE), | ||
| "", | ||
| null, | ||
| TimeCapsuleType.NORMAL, | ||
| CapsuleVisibility.PRIVATE, | ||
| CapsuleLockType.NONE, | ||
| null, | ||
| null, | ||
| null, | ||
| org.locationtech.jts.geom.GeometryFactory().createPoint(org.locationtech.jts.geom.Coordinate(0.0, 0.0)), | ||
| null, | ||
| 0, | ||
| LocalDateTime.now(), | ||
| false, | ||
| false, | ||
| false, | ||
| ) | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/team/cklob/mudda/domain/media/domain/repository/MediaRepository.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,6 @@ | ||
| package team.cklob.mudda.domain.media.domain.repository | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import team.cklob.mudda.domain.media.domain.entity.Media | ||
|
|
||
| interface MediaRepository : JpaRepository<Media, Long> |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/team/cklob/mudda/domain/media/domain/type/MediaType.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,7 @@ | ||
| package team.cklob.mudda.domain.media.domain.type | ||
|
|
||
| enum class MediaType { | ||
| IMAGE, | ||
| VIDEO, | ||
| VOICE, | ||
| } |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/team/cklob/mudda/domain/member/domain/entity/Member.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,63 @@ | ||
| package team.cklob.mudda.domain.member.domain.entity | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.EnumType | ||
| import jakarta.persistence.Enumerated | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.PrePersist | ||
| import jakarta.persistence.PreUpdate | ||
| import jakarta.persistence.Table | ||
| import team.cklob.mudda.domain.member.domain.type.ProfileVisibility | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity | ||
| @Table(name = "tbl_member") | ||
| class Member( | ||
| @Column(nullable = false, length = 30) | ||
| val name: String, | ||
|
|
||
| @Column(nullable = false, unique = true, length = 30) | ||
| val nickname: String, | ||
|
|
||
| @Column(nullable = false, unique = true, length = 255) | ||
| val email: String, | ||
|
|
||
| @Column(name = "profile_image_url", length = 255) | ||
| val profileImageUrl: String? = null, | ||
|
|
||
| @Column(length = 100) | ||
| val bio: String? = null, | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "profile_visibility", nullable = false, length = 20) | ||
| val profileVisibility: ProfileVisibility, | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| val id: Long? = null, | ||
| ) { | ||
|
exijn marked this conversation as resolved.
Outdated
|
||
| @Column(name = "created_at", nullable = false) | ||
| var createdAt: LocalDateTime = LocalDateTime.now() | ||
| protected set | ||
|
|
||
| @Column(name = "updated_at", nullable = false) | ||
| var updatedAt: LocalDateTime = LocalDateTime.now() | ||
| protected set | ||
|
|
||
| protected constructor() : this("", "", "", null, null, ProfileVisibility.PRIVATE) | ||
|
|
||
| @PrePersist | ||
| fun prePersist() { | ||
| val now = LocalDateTime.now() | ||
| createdAt = now | ||
| updatedAt = now | ||
| } | ||
|
|
||
| @PreUpdate | ||
| fun preUpdate() { | ||
| updatedAt = LocalDateTime.now() | ||
| } | ||
|
exijn marked this conversation as resolved.
Outdated
|
||
| } | ||
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/team/cklob/mudda/domain/member/domain/repository/MemberRepository.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,12 @@ | ||
| package team.cklob.mudda.domain.member.domain.repository | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import team.cklob.mudda.domain.member.domain.entity.Member | ||
| import java.util.Optional | ||
|
|
||
| interface MemberRepository : JpaRepository<Member, Long> { | ||
| fun existsByEmail(email: String): Boolean | ||
| fun existsByNickname(nickname: String): Boolean | ||
| fun findByEmail(email: String): Optional<Member> | ||
| fun findByNickname(nickname: String): Optional<Member> | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/team/cklob/mudda/domain/member/domain/type/ProfileVisibility.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,7 @@ | ||
| package team.cklob.mudda.domain.member.domain.type | ||
|
|
||
| enum class ProfileVisibility { | ||
| PRIVATE, | ||
| FRIEND, | ||
| PUBLIC, | ||
| } |
59 changes: 59 additions & 0 deletions
59
src/main/kotlin/team/cklob/mudda/domain/notification/domain/entity/Notification.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,59 @@ | ||
| package team.cklob.mudda.domain.notification.domain.entity | ||
|
|
||
| import jakarta.persistence.Column | ||
| import jakarta.persistence.Entity | ||
| import jakarta.persistence.EnumType | ||
| import jakarta.persistence.Enumerated | ||
| import jakarta.persistence.FetchType | ||
| import jakarta.persistence.GeneratedValue | ||
| import jakarta.persistence.GenerationType | ||
| import jakarta.persistence.Id | ||
| import jakarta.persistence.JoinColumn | ||
| import jakarta.persistence.ManyToOne | ||
| import jakarta.persistence.PrePersist | ||
| import jakarta.persistence.Table | ||
| import team.cklob.mudda.domain.member.domain.entity.Member | ||
| import team.cklob.mudda.domain.member.domain.type.ProfileVisibility | ||
| import team.cklob.mudda.domain.notification.domain.type.NotificationType | ||
| import team.cklob.mudda.domain.timecapsule.domain.entity.TimeCapsule | ||
| import java.time.LocalDateTime | ||
|
|
||
| @Entity | ||
| @Table(name = "tbl_notification") | ||
| class Notification( | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "recipient_id", nullable = false) | ||
| val recipient: Member, | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "time_capsule_id") | ||
| val timeCapsule: TimeCapsule? = null, | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "notification_type", nullable = false, length = 30) | ||
| val notificationType: NotificationType, | ||
|
|
||
| @Column(nullable = false, length = 255) | ||
| val title: String, | ||
|
|
||
| @Column(nullable = false, length = 255) | ||
| val body: String, | ||
|
|
||
| @Column(name = "is_read", nullable = false) | ||
| val isRead: Boolean = false, | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| val id: Long? = null, | ||
| ) { | ||
| @Column(name = "created_at", nullable = false) | ||
| var createdAt: LocalDateTime = LocalDateTime.now() | ||
| protected set | ||
|
|
||
| protected constructor() : this(Member("", "", "", null, null, ProfileVisibility.PRIVATE), null, NotificationType.SYSTEM, "", "", false) | ||
|
|
||
| @PrePersist | ||
| fun prePersist() { | ||
| createdAt = LocalDateTime.now() | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...n/kotlin/team/cklob/mudda/domain/notification/domain/repository/NotificationRepository.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,9 @@ | ||
| package team.cklob.mudda.domain.notification.domain.repository | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository | ||
| import team.cklob.mudda.domain.notification.domain.entity.Notification | ||
|
|
||
| interface NotificationRepository : JpaRepository<Notification, Long> { | ||
| fun findByRecipientIdOrderByCreatedAtDesc(recipientId: Long): List<Notification> | ||
| fun findByRecipientIdAndIsReadFalseOrderByCreatedAtDesc(recipientId: Long): List<Notification> | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.