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.event.actor.ActorEvent.*
|
||||||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
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.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.model.shared.Domain
|
||||||
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
@ -53,8 +54,26 @@ class Actor(
|
||||||
emojiIds: Set<EmojiId>,
|
emojiIds: Set<EmojiId>,
|
||||||
deleted: Boolean,
|
deleted: Boolean,
|
||||||
roles: Set<Role>,
|
roles: Set<Role>,
|
||||||
|
icon: MediaId?,
|
||||||
|
banner: MediaId?,
|
||||||
) : DomainEventStorable() {
|
) : 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
|
var roles = roles
|
||||||
private set
|
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.actor.*
|
||||||
import dev.usbharu.hideout.core.domain.model.emoji.EmojiId
|
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.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.model.shared.Domain
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
|
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Actors
|
||||||
import org.jetbrains.exposed.sql.ResultRow
|
import org.jetbrains.exposed.sql.ResultRow
|
||||||
|
@ -59,7 +60,9 @@ class ActorResultRowMapper : ResultRowMapper<Actor> {
|
||||||
.map { EmojiId(it.toLong()) }
|
.map { EmojiId(it.toLong()) }
|
||||||
.toSet(),
|
.toSet(),
|
||||||
deleted = resultRow[Actors.deleted],
|
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[suspend] = actor.suspend
|
||||||
it[moveTo] = actor.moveTo?.id
|
it[moveTo] = actor.moveTo?.id
|
||||||
it[emojis] = actor.emojis.joinToString(",")
|
it[emojis] = actor.emojis.joinToString(",")
|
||||||
|
it[icon] = actor.icon?.id
|
||||||
|
it[banner] = actor.banner?.id
|
||||||
|
|
||||||
}
|
}
|
||||||
ActorsAlsoKnownAs.deleteWhere {
|
ActorsAlsoKnownAs.deleteWhere {
|
||||||
actorId eq actor.id.id
|
actorId eq actor.id.id
|
||||||
|
@ -127,6 +130,8 @@ object Actors : Table("actors") {
|
||||||
val moveTo = long("move_to").references(id).nullable()
|
val moveTo = long("move_to").references(id).nullable()
|
||||||
val emojis = varchar("emojis", 3000)
|
val emojis = varchar("emojis", 3000)
|
||||||
val deleted = bool("deleted")
|
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)
|
override val primaryKey = PrimaryKey(id)
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,9 @@ class ActorFactoryImpl(
|
||||||
suspend = false,
|
suspend = false,
|
||||||
emojiIds = emptySet(),
|
emojiIds = emptySet(),
|
||||||
deleted = false,
|
deleted = false,
|
||||||
roles = emptySet()
|
roles = emptySet(),
|
||||||
|
banner = null,
|
||||||
|
icon = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,9 @@ object TestActorFactory {
|
||||||
moveTo = moveTo,
|
moveTo = moveTo,
|
||||||
emojiIds = emojiIds,
|
emojiIds = emojiIds,
|
||||||
deleted = deleted,
|
deleted = deleted,
|
||||||
roles = emptySet()
|
roles = emptySet(),
|
||||||
|
icon = null,
|
||||||
|
banner = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue