mirror of https://github.com/usbharu/Hideout.git
feat: Timelineを追加
This commit is contained in:
parent
0f0b2037f6
commit
8c34019728
|
@ -110,6 +110,7 @@ dependencies {
|
||||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
implementation("org.springframework.security:spring-security-oauth2-jose")
|
implementation("org.springframework.security:spring-security-oauth2-jose")
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
|
||||||
|
|
||||||
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
|
implementation("io.ktor:ktor-client-logging-jvm:$ktor_version")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package dev.usbharu.hideout.domain.model.hideout.entity
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
data class Timeline(
|
||||||
|
@Id
|
||||||
|
val id: Long,
|
||||||
|
val userId: Long,
|
||||||
|
val timelineId: Long,
|
||||||
|
val postId: Long,
|
||||||
|
val postUserId: Long,
|
||||||
|
val createdAt: Instant,
|
||||||
|
val replyId: Long,
|
||||||
|
val repostId: Long,
|
||||||
|
val visibility: Visibility,
|
||||||
|
val sensitive: Boolean
|
||||||
|
)
|
|
@ -0,0 +1,9 @@
|
||||||
|
package dev.usbharu.hideout.repository
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
|
||||||
|
import org.springframework.data.mongodb.repository.MongoRepository
|
||||||
|
|
||||||
|
interface MongoTimelineRepository : TimelineRepository, MongoRepository<Timeline, Long> {
|
||||||
|
override fun findByUserId(id: Long): List<Timeline>
|
||||||
|
override fun findByUserIdAndTimelineId(userId: Long, timelineId: Long): List<Timeline>
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package dev.usbharu.hideout.repository
|
||||||
|
|
||||||
|
import dev.usbharu.hideout.domain.model.hideout.entity.Timeline
|
||||||
|
|
||||||
|
interface TimelineRepository {
|
||||||
|
fun findByUserId(id: Long): List<Timeline>
|
||||||
|
fun findByUserIdAndTimelineId(userId: Long, timelineId: Long): List<Timeline>
|
||||||
|
}
|
|
@ -23,13 +23,18 @@ class PostServiceImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun createRemote(post: Post): Post {
|
override suspend fun createRemote(post: Post): Post {
|
||||||
return postRepository.save(post)
|
return internalCreate(post)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addInterceptor(postCreateInterceptor: PostCreateInterceptor) {
|
override fun addInterceptor(postCreateInterceptor: PostCreateInterceptor) {
|
||||||
interceptors.add(postCreateInterceptor)
|
interceptors.add(postCreateInterceptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun internalCreate(post: Post): Post {
|
||||||
|
|
||||||
|
return postRepository.save(post)
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun internalCreate(post: PostCreateDto): Post {
|
private suspend fun internalCreate(post: PostCreateDto): Post {
|
||||||
val user = userRepository.findById(post.userId) ?: throw UserNotFoundException("${post.userId} was not found")
|
val user = userRepository.findById(post.userId) ?: throw UserNotFoundException("${post.userId} was not found")
|
||||||
val id = postRepository.generateId()
|
val id = postRepository.generateId()
|
||||||
|
@ -44,6 +49,6 @@ class PostServiceImpl(
|
||||||
repostId = null,
|
repostId = null,
|
||||||
replyId = null
|
replyId = null
|
||||||
)
|
)
|
||||||
return postRepository.save(createPost)
|
return internalCreate(post)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ spring:
|
||||||
url: "jdbc:h2:./test-dev2;MODE=POSTGRESQL"
|
url: "jdbc:h2:./test-dev2;MODE=POSTGRESQL"
|
||||||
username: ""
|
username: ""
|
||||||
password: ""
|
password: ""
|
||||||
|
data:
|
||||||
|
mongodb:
|
||||||
|
|
||||||
|
|
||||||
h2:
|
h2:
|
||||||
console:
|
console:
|
||||||
|
|
Loading…
Reference in New Issue