Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
[WEAV-000] AggregateRoot, Domain Entity 인터페이스 상속 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
waterfogSW committed Apr 16, 2024
1 parent 9e159f2 commit c7d1146
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.studentcenter.weave.domain.chat.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.time.LocalDateTime
import java.util.*

data class ChatMessage(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val roomId: UUID,
val senderId: UUID,
val senderType: SenderType,
val contents: List<Content>,
val createdAt: LocalDateTime = LocalDateTime.now(),
) {
) : DomainEntity {

init {
require(contents.isNotEmpty()) { "메시지를 입력해 주세요" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.studentcenter.weave.domain.chat.entity

import com.studentcenter.weave.domain.common.AggregateRoot
import com.studentcenter.weave.domain.meeting.entity.Meeting
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.time.LocalDateTime
import java.util.*

data class ChatRoom(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val meetingId: UUID,
val receivingTeamId: UUID,
val requestingTeamId: UUID,
val createdAt: LocalDateTime = LocalDateTime.now(),
) {
) : AggregateRoot {

companion object {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.studentcenter.weave.domain.meeting.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.time.LocalDateTime
import java.util.*

data class MeetingAttendance(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val meetingId: UUID,
val meetingMemberId: UUID,
val isAttend: Boolean,
val createdAt: LocalDateTime = LocalDateTime.now(),
val updatedAt: LocalDateTime = createdAt,
) {
) : DomainEntity {

companion object {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.studentcenter.weave.domain.meetingTeam.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.domain.meetingTeam.enums.MeetingMemberRole
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.util.*

data class MeetingMember(
val id: UUID,
override val id: UUID,
val userId: UUID,
val role: MeetingMemberRole,
) {
) : DomainEntity {

companion object {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.studentcenter.weave.domain.meetingTeam.entity

import com.studentcenter.weave.domain.common.AggregateRoot
import com.studentcenter.weave.domain.meetingTeam.enums.Location
import com.studentcenter.weave.domain.meetingTeam.enums.MeetingMemberRole
import com.studentcenter.weave.domain.meetingTeam.enums.MeetingTeamStatus
Expand All @@ -10,14 +11,14 @@ import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.util.*

data class MeetingTeam(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val teamIntroduce: TeamIntroduce,
val memberCount: Int,
val members: List<MeetingMember>,
val location: Location,
val status: MeetingTeamStatus,
val gender: Gender,
) {
) : AggregateRoot {

val leader: MeetingMember
get() = members.first { it.role == MeetingMemberRole.LEADER }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.studentcenter.weave.domain.meetingTeam.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.domain.user.entity.User
import com.studentcenter.weave.domain.user.vo.BirthYear
import com.studentcenter.weave.domain.user.vo.Mbti
Expand All @@ -8,13 +9,13 @@ import java.time.LocalDateTime
import java.util.*

data class MeetingTeamMemberSummary(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val meetingTeamId: UUID,
val teamMbti: Mbti,
val youngestMemberBirthYear: BirthYear,
val oldestMemberBirthYear: BirthYear,
val createdAt: LocalDateTime = LocalDateTime.now(),
) {
) : DomainEntity {

init {
require(youngestMemberBirthYear.value >= oldestMemberBirthYear.value) {
Expand All @@ -26,7 +27,7 @@ data class MeetingTeamMemberSummary(

fun create(
meetingTeamId: UUID,
members: List<User>
members: List<User>,
): MeetingTeamMemberSummary {
require(members.isNotEmpty()) {
"팀에 속한 멤버가 존재해야 합니다."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package com.studentcenter.weave.domain.university.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.domain.university.vo.MajorName
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.time.LocalDateTime
import java.util.*

data class Major(
val id: UUID = UuidCreator.create(),
val univId:UUID,
override val id: UUID = UuidCreator.create(),
val univId: UUID,
val name: MajorName,
val createdAt: LocalDateTime = LocalDateTime.now(),
) {
) : DomainEntity {


companion object {
fun create(univId: UUID, name: MajorName): Major {

fun create(
univId: UUID,
name: MajorName,
): Major {
return Major(univId = univId, name = name)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.studentcenter.weave.domain.university.entity

import com.studentcenter.weave.domain.common.AggregateRoot
import com.studentcenter.weave.domain.university.vo.UniversityName
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.time.LocalDateTime
import java.util.*

data class University(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val name: UniversityName,
val displayName: String,
val domainAddress: String,
val logoAddress: String?,
val createdAt: LocalDateTime = LocalDateTime.now(),
val updatedAt: LocalDateTime = LocalDateTime.now(),
) {
) : AggregateRoot {


companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.studentcenter.weave.domain.user.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.domain.user.enums.SocialLoginProvider
import com.studentcenter.weave.support.common.uuid.UuidCreator
import com.studentcenter.weave.support.common.vo.Email
import java.time.LocalDateTime
import java.util.UUID

data class DeletedUserInfo(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val email: Email,
val socialLoginProvider: SocialLoginProvider,
val reason: String? = null,
val registeredAt: LocalDateTime,
val deletedAt: LocalDateTime = LocalDateTime.now(),
) {
) : DomainEntity {

init {
require(reason?.isNotBlank()?.let { it && reason.length <= 100 } ?: true) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.studentcenter.weave.domain.user.entity

import com.studentcenter.weave.domain.common.AggregateRoot
import com.studentcenter.weave.domain.user.enums.AnimalType
import com.studentcenter.weave.domain.user.enums.Gender
import com.studentcenter.weave.domain.user.vo.BirthYear
Expand All @@ -16,7 +17,7 @@ import java.time.LocalDateTime
import java.util.*

data class User(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val nickname: Nickname,
val email: Email,
val gender: Gender,
Expand All @@ -31,7 +32,7 @@ data class User(
val isUnivVerified: Boolean = false,
val registeredAt: LocalDateTime = LocalDateTime.now(),
val updatedAt: LocalDateTime = LocalDateTime.now(),
) {
) : AggregateRoot {

val avatar: Url?
get() = profileImages.firstOrNull()?.imageUrl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.studentcenter.weave.domain.user.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.domain.user.enums.SocialLoginProvider
import com.studentcenter.weave.support.common.uuid.UuidCreator
import com.studentcenter.weave.support.common.vo.Email
import java.time.LocalDateTime
import java.util.*

data class UserAuthInfo(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val userId: UUID,
val email: Email,
val socialLoginProvider: SocialLoginProvider,
val registeredAt: LocalDateTime,
) {
) : DomainEntity {

companion object {

fun create(
user: User,
socialLoginProvider: SocialLoginProvider,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.studentcenter.weave.domain.user.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.domain.user.exception.UserExceptionType
import com.studentcenter.weave.support.common.exception.CustomException
import com.studentcenter.weave.support.common.vo.Url
import java.util.*

data class UserProfileImage(
val id: UUID,
override val id: UUID,
val extension: Extension,
val imageUrl: Url,
) {
) : DomainEntity {

enum class Extension(val value: String) {
JPG("jpg"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.studentcenter.weave.domain.user.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.support.common.uuid.UuidCreator
import java.util.*

/**
* 유저의 실(재화) 정보
*/
data class UserSil(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val userId: UUID,
val amount: Long = 0,
) {
) : DomainEntity {

init {
require(amount >= 0) { "amount는 0 이상이어야 합니다." }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.studentcenter.weave.domain.user.entity

import com.studentcenter.weave.domain.common.DomainEntity
import com.studentcenter.weave.support.common.uuid.UuidCreator
import com.studentcenter.weave.support.common.vo.Email
import java.time.LocalDateTime
import java.util.*

data class UserUniversityVerificationInfo(
val id: UUID = UuidCreator.create(),
override val id: UUID = UuidCreator.create(),
val userId: UUID,
val universityId: UUID,
val universityEmail: Email,
val verifiedAt: LocalDateTime,
) {
) : DomainEntity {

companion object {
fun create(user: User, universityEmail: Email): UserUniversityVerificationInfo {
Expand Down

0 comments on commit c7d1146

Please sign in to comment.