From c0df2aacb59d32b65b829a3d174058bf5cad56eb Mon Sep 17 00:00:00 2001 From: San Kim Date: Sun, 2 Feb 2025 18:30:17 +0900 Subject: [PATCH] =?UTF-8?q?refactor(chat)=20:=20ID=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?UUID=20v8=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/threedays/domain/chat/entity/Message.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/domain/src/main/kotlin/com/threedays/domain/chat/entity/Message.kt b/domain/src/main/kotlin/com/threedays/domain/chat/entity/Message.kt index e639764..b47e23c 100644 --- a/domain/src/main/kotlin/com/threedays/domain/chat/entity/Message.kt +++ b/domain/src/main/kotlin/com/threedays/domain/chat/entity/Message.kt @@ -3,7 +3,7 @@ package com.threedays.domain.chat.entity import com.threedays.domain.user.entity.User import com.threedays.domain.user.vo.Gender import com.threedays.support.common.base.domain.AggregateRoot -import com.threedays.support.common.base.domain.TypeId +import com.threedays.support.common.base.domain.UUIDTypeId import java.time.LocalDateTime import java.util.* @@ -17,7 +17,7 @@ data class Message( val updatedAt: LocalDateTime? = null, ) : AggregateRoot() { - data class Id(override val value: UUID) : TypeId(value) + data class Id(override val value: UUID) : UUIDTypeId(value) sealed class Content { data class Text(val text: String) : Content() @@ -38,18 +38,19 @@ data class Message( } companion object { + fun createCardMessage( channelId: Channel.Id, sender: User, text: String, ): Message { - val color: Content.Card.Color = when(sender.profile.gender) { + val color: Content.Card.Color = when (sender.profile.gender) { Gender.MALE -> Content.Card.Color.BLUE Gender.FEMALE -> Content.Card.Color.PINK } return Message( - id = Id(UUID.randomUUID()), + id = UUIDTypeId.random(), channelId = channelId, senderUserId = sender.id, content = Content.Card(text, color) @@ -62,7 +63,7 @@ data class Message( text: String ): Message { return Message( - id = Id(UUID.randomUUID()), + id = UUIDTypeId.random(), channelId = channelId, senderUserId = sender.id, content = Content.Text(text)