mirror of https://github.com/usbharu/Hideout.git
feat: アイコンとバナーを設定できるように
This commit is contained in:
parent
078547d5ff
commit
21ab0e0dfd
|
@ -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<EmojiId>,
|
||||
deleted: Boolean,
|
||||
roles: Set<Role>,
|
||||
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
|
||||
|
||||
|
|
|
@ -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<Actor> {
|
|||
.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) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ class ActorFactoryImpl(
|
|||
suspend = false,
|
||||
emojiIds = emptySet(),
|
||||
deleted = false,
|
||||
roles = emptySet()
|
||||
roles = emptySet(),
|
||||
banner = null,
|
||||
icon = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ object TestActorFactory {
|
|||
moveTo = moveTo,
|
||||
emojiIds = emojiIds,
|
||||
deleted = deleted,
|
||||
roles = emptySet()
|
||||
roles = emptySet(),
|
||||
icon = null,
|
||||
banner = null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue