Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Comment thread
exijn marked this conversation as resolved.
Outdated

@PrePersist
fun prePersist() {
createdAt = LocalDateTime.now()
}

companion object {
private fun emptyMember() = Member("", "", "", null, null, ProfileVisibility.PRIVATE)
}
}
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>
}
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)
}
}
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
}
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,
}
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,
)
}
}
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>
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,
}
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,
) {
Comment thread
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()
}
Comment thread
exijn marked this conversation as resolved.
Outdated
}
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>
}
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,
}
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()
}
}
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>
}
Loading