mirror of https://github.com/usbharu/Hideout.git
feat: contentを永続化するように
This commit is contained in:
parent
b76e1d19a5
commit
d9b1f0dfd7
|
@ -1,6 +1,7 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.post
|
package dev.usbharu.hideout.core.domain.model.post
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.config.CharacterLimit
|
import dev.usbharu.hideout.application.config.CharacterLimit
|
||||||
|
import dev.usbharu.hideout.core.service.post.PostContentFormatter
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
|
@ -23,7 +24,10 @@ data class Post private constructor(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class PostBuilder(private val characterLimit: CharacterLimit) {
|
class PostBuilder(
|
||||||
|
private val characterLimit: CharacterLimit,
|
||||||
|
private val postContentFormatter: PostContentFormatter
|
||||||
|
) {
|
||||||
@Suppress("FunctionMinLength", "LongParameterList")
|
@Suppress("FunctionMinLength", "LongParameterList")
|
||||||
fun of(
|
fun of(
|
||||||
id: Long,
|
id: Long,
|
||||||
|
@ -56,6 +60,8 @@ data class Post private constructor(
|
||||||
content
|
content
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val (html, content1) = postContentFormatter.format(limitedText)
|
||||||
|
|
||||||
require(url.isNotBlank()) { "url must contain non-blank characters" }
|
require(url.isNotBlank()) { "url must contain non-blank characters" }
|
||||||
require(url.length <= characterLimit.general.url) {
|
require(url.length <= characterLimit.general.url) {
|
||||||
"url must not exceed ${characterLimit.general.url} characters."
|
"url must not exceed ${characterLimit.general.url} characters."
|
||||||
|
@ -68,8 +74,8 @@ data class Post private constructor(
|
||||||
id = id,
|
id = id,
|
||||||
actorId = actorId,
|
actorId = actorId,
|
||||||
overview = limitedOverview,
|
overview = limitedOverview,
|
||||||
content = content,
|
content = html,
|
||||||
text = limitedText,
|
text = content1,
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
url = url,
|
url = url,
|
||||||
|
|
|
@ -27,6 +27,7 @@ class PostRepositoryImpl(
|
||||||
it[id] = post.id
|
it[id] = post.id
|
||||||
it[actorId] = post.actorId
|
it[actorId] = post.actorId
|
||||||
it[overview] = post.overview
|
it[overview] = post.overview
|
||||||
|
it[content] = post.content
|
||||||
it[text] = post.text
|
it[text] = post.text
|
||||||
it[createdAt] = post.createdAt
|
it[createdAt] = post.createdAt
|
||||||
it[visibility] = post.visibility.ordinal
|
it[visibility] = post.visibility.ordinal
|
||||||
|
@ -63,6 +64,7 @@ class PostRepositoryImpl(
|
||||||
Posts.update({ Posts.id eq post.id }) {
|
Posts.update({ Posts.id eq post.id }) {
|
||||||
it[actorId] = post.actorId
|
it[actorId] = post.actorId
|
||||||
it[overview] = post.overview
|
it[overview] = post.overview
|
||||||
|
it[content] = post.content
|
||||||
it[text] = post.text
|
it[text] = post.text
|
||||||
it[createdAt] = post.createdAt
|
it[createdAt] = post.createdAt
|
||||||
it[visibility] = post.visibility.ordinal
|
it[visibility] = post.visibility.ordinal
|
||||||
|
@ -128,6 +130,7 @@ object Posts : Table() {
|
||||||
val id: Column<Long> = long("id")
|
val id: Column<Long> = long("id")
|
||||||
val actorId: Column<Long> = long("actor_id").references(Actors.id)
|
val actorId: Column<Long> = long("actor_id").references(Actors.id)
|
||||||
val overview: Column<String?> = varchar("overview", 100).nullable()
|
val overview: Column<String?> = varchar("overview", 100).nullable()
|
||||||
|
val content = varchar("content", 5000)
|
||||||
val text: Column<String> = varchar("text", 3000)
|
val text: Column<String> = varchar("text", 3000)
|
||||||
val createdAt: Column<Long> = long("created_at")
|
val createdAt: Column<Long> = long("created_at")
|
||||||
val visibility: Column<Int> = integer("visibility").default(0)
|
val visibility: Column<Int> = integer("visibility").default(0)
|
||||||
|
|
|
@ -90,6 +90,7 @@ create table if not exists posts
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
actor_id bigint not null,
|
actor_id bigint not null,
|
||||||
overview varchar(100) null,
|
overview varchar(100) null,
|
||||||
|
content varchar(5000) not null,
|
||||||
text varchar(3000) not null,
|
text varchar(3000) not null,
|
||||||
created_at bigint not null,
|
created_at bigint not null,
|
||||||
visibility int default 0 not null,
|
visibility int default 0 not null,
|
||||||
|
|
Loading…
Reference in New Issue