From 21ab0e0dfd7efa3570ecdce4dfeb2c545fdb3603 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:54:18 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=81=A8=E3=83=90=E3=83=8A=E3=83=BC=E3=82=92=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hideout/core/domain/model/actor/Actor.kt | 19 +++++++++++++++++++ .../exposed/ActorResultRowMapper.kt | 5 ++++- .../ExposedActorRepository.kt | 5 +++++ .../factory/ActorFactoryImpl.kt | 4 +++- .../domain/model/actor/TestActorFactory.kt | 4 +++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt index cbbb29db..73f5d15c 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/domain/model/actor/Actor.kt @@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.domain.event.actor.ActorDomainEventFactory import dev.usbharu.hideout.core.domain.event.actor.ActorEvent.* import dev.usbharu.hideout.core.domain.model.emoji.EmojiId import dev.usbharu.hideout.core.domain.model.instance.InstanceId +import dev.usbharu.hideout.core.domain.model.media.MediaId import dev.usbharu.hideout.core.domain.model.shared.Domain import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable import java.net.URI @@ -53,8 +54,26 @@ class Actor( emojiIds: Set, deleted: Boolean, roles: Set, + icon: MediaId?, + banner: MediaId?, ) : DomainEventStorable() { + var banner = banner + private set + + fun setBannerUrl(banner: MediaId?, actor: Actor) { + addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + this.banner = banner + } + + var icon = icon + private set + + fun setIconUrl(icon: MediaId?, actor: Actor) { + addDomainEvent(ActorDomainEventFactory(this).createEvent(update)) + this.icon = icon + } + var roles = roles private set diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt index 3b26139e..3bb58e43 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposed/ActorResultRowMapper.kt @@ -19,6 +19,7 @@ package dev.usbharu.hideout.core.infrastructure.exposed import dev.usbharu.hideout.core.domain.model.actor.* import dev.usbharu.hideout.core.domain.model.emoji.EmojiId import dev.usbharu.hideout.core.domain.model.instance.InstanceId +import dev.usbharu.hideout.core.domain.model.media.MediaId import dev.usbharu.hideout.core.domain.model.shared.Domain import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors import org.jetbrains.exposed.sql.ResultRow @@ -59,7 +60,9 @@ class ActorResultRowMapper : ResultRowMapper { .map { EmojiId(it.toLong()) } .toSet(), deleted = resultRow[Actors.deleted], - roles = emptySet() + roles = emptySet(), + icon = resultRow[Actors.icon]?.let { MediaId(it) }, + banner = resultRow[Actors.banner]?.let { MediaId(it) } ) } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt index d8f560c9..fbdc1d62 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/exposedrepository/ExposedActorRepository.kt @@ -53,6 +53,9 @@ class ExposedActorRepository( it[suspend] = actor.suspend it[moveTo] = actor.moveTo?.id it[emojis] = actor.emojis.joinToString(",") + it[icon] = actor.icon?.id + it[banner] = actor.banner?.id + } ActorsAlsoKnownAs.deleteWhere { actorId eq actor.id.id @@ -127,6 +130,8 @@ object Actors : Table("actors") { val moveTo = long("move_to").references(id).nullable() val emojis = varchar("emojis", 3000) val deleted = bool("deleted") + val banner = long("banner").references(Media.id).nullable() + val icon = long("icon").references(Media.id).nullable() override val primaryKey = PrimaryKey(id) diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt index 09ba2411..0fb961c5 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/infrastructure/factory/ActorFactoryImpl.kt @@ -61,7 +61,9 @@ class ActorFactoryImpl( suspend = false, emojiIds = emptySet(), deleted = false, - roles = emptySet() + roles = emptySet(), + banner = null, + icon = null ) } } diff --git a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt index 4bb92910..0fb9087d 100644 --- a/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt +++ b/hideout-core/src/test/kotlin/dev/usbharu/hideout/core/domain/model/actor/TestActorFactory.kt @@ -65,7 +65,9 @@ object TestActorFactory { moveTo = moveTo, emojiIds = emojiIds, deleted = deleted, - roles = emptySet() + roles = emptySet(), + icon = null, + banner = null ) } }