mirror of https://github.com/usbharu/Hideout.git
feat: serviceとrepositoryにアノテーションを追加
This commit is contained in:
parent
60706ee413
commit
e5b744eef0
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.query
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.User
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface FollowerQueryService {
|
||||
suspend fun findFollowersById(id: Long): List<User>
|
||||
suspend fun findFollowersByNameAndDomain(name: String, domain: String): List<User>
|
||||
|
|
|
@ -6,9 +6,11 @@ import dev.usbharu.hideout.repository.UsersFollowers
|
|||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.Instant
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class FollowerQueryServiceImpl : FollowerQueryService {
|
||||
override suspend fun findFollowersById(id: Long): List<User> {
|
||||
val followers = Users.alias("FOLLOWERS")
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.query
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.JwtRefreshToken
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface JwtRefreshTokenQueryService {
|
||||
suspend fun findById(id: Long): JwtRefreshToken
|
||||
suspend fun findByToken(token: String): JwtRefreshToken
|
||||
|
|
|
@ -10,8 +10,10 @@ import org.jetbrains.exposed.sql.deleteAll
|
|||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class JwtRefreshTokenQueryServiceImpl : JwtRefreshTokenQueryService {
|
||||
override suspend fun findById(id: Long): JwtRefreshToken =
|
||||
JwtRefreshTokens.select { JwtRefreshTokens.id.eq(id) }
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.query
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Post
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface PostQueryService {
|
||||
suspend fun findById(id: Long): Post
|
||||
suspend fun findByUrl(url: String): Post
|
||||
|
|
|
@ -7,8 +7,10 @@ import dev.usbharu.hideout.repository.toPost
|
|||
import dev.usbharu.hideout.util.singleOr
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class PostQueryServiceImpl : PostQueryService {
|
||||
override suspend fun findById(id: Long): Post =
|
||||
Posts.select { Posts.id eq id }
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package dev.usbharu.hideout.query
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.dto.PostResponse
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Repository
|
||||
interface PostResponseQueryService {
|
||||
suspend fun findById(id: Long, userId: Long?): PostResponse
|
||||
suspend fun findAll(
|
||||
|
|
|
@ -12,8 +12,10 @@ import org.jetbrains.exposed.sql.innerJoin
|
|||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class PostResponseQueryServiceImpl : PostResponseQueryService {
|
||||
override suspend fun findById(id: Long, userId: Long?): PostResponse {
|
||||
return Posts
|
||||
|
|
|
@ -2,7 +2,9 @@ package dev.usbharu.hideout.query
|
|||
|
||||
import dev.usbharu.hideout.domain.model.hideout.dto.ReactionResponse
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Reaction
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface ReactionQueryService {
|
||||
suspend fun findByPostId(postId: Long, userId: Long? = null): List<Reaction>
|
||||
|
||||
|
|
|
@ -11,8 +11,10 @@ import dev.usbharu.hideout.util.singleOr
|
|||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class ReactionQueryServiceImpl : ReactionQueryService {
|
||||
override suspend fun findByPostId(postId: Long, userId: Long?): List<Reaction> {
|
||||
return Reactions.select {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.query
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.User
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface UserQueryService {
|
||||
suspend fun findAll(limit: Int, offset: Long): List<User>
|
||||
suspend fun findById(id: Long): User
|
||||
|
|
|
@ -10,8 +10,10 @@ import org.jetbrains.exposed.sql.select
|
|||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.koin.core.annotation.Single
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class UserQueryServiceImpl : UserQueryService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(UserQueryServiceImpl::class.java)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.repository
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.JwtRefreshToken
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface JwtRefreshTokenRepository {
|
||||
suspend fun generateId(): Long
|
||||
|
||||
|
|
|
@ -6,9 +6,11 @@ import org.jetbrains.exposed.sql.*
|
|||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.Instant
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class JwtRefreshTokenRepositoryImpl(
|
||||
private val database: Database,
|
||||
private val idGenerateService: IdGenerateService
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.repository
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Meta
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface MetaRepository {
|
||||
|
||||
suspend fun save(meta: Meta)
|
||||
|
|
|
@ -4,9 +4,11 @@ import dev.usbharu.hideout.domain.model.hideout.entity.Jwt
|
|||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.util.*
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class MetaRepositoryImpl(private val database: Database) : MetaRepository {
|
||||
|
||||
init {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package dev.usbharu.hideout.repository
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Post
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Repository
|
||||
interface PostRepository {
|
||||
suspend fun generateId(): Long
|
||||
suspend fun save(post: Post): Post
|
||||
|
|
|
@ -8,8 +8,10 @@ import org.jetbrains.exposed.sql.*
|
|||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class PostRepositoryImpl(database: Database, private val idGenerateService: IdGenerateService) : PostRepository {
|
||||
|
||||
init {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.repository
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Reaction
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface ReactionRepository {
|
||||
suspend fun generateId(): Long
|
||||
suspend fun save(reaction: Reaction): Reaction
|
||||
|
|
|
@ -7,8 +7,10 @@ import org.jetbrains.exposed.sql.*
|
|||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class ReactionRepositoryImpl(
|
||||
private val database: Database,
|
||||
private val idGenerateService: IdGenerateService
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package dev.usbharu.hideout.repository
|
||||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.User
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@Repository
|
||||
interface UserRepository {
|
||||
suspend fun save(user: User): User
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ import org.jetbrains.exposed.sql.*
|
|||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.Instant
|
||||
|
||||
@Single
|
||||
@Repository
|
||||
class UserRepositoryImpl(private val database: Database, private val idGenerateService: IdGenerateService) :
|
||||
UserRepository {
|
||||
init {
|
||||
|
|
|
@ -11,12 +11,15 @@ import dev.usbharu.hideout.service.core.Transaction
|
|||
import dev.usbharu.hideout.service.user.UserService
|
||||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface APAcceptService {
|
||||
suspend fun receiveAccept(accept: Accept): ActivityPubResponse
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APAcceptServiceImpl(
|
||||
private val userService: UserService,
|
||||
private val userQueryService: UserQueryService,
|
||||
|
|
|
@ -8,12 +8,16 @@ import dev.usbharu.hideout.exception.ap.IllegalActivityPubObjectException
|
|||
import dev.usbharu.hideout.service.core.Transaction
|
||||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
|
||||
@Service
|
||||
interface APCreateService {
|
||||
suspend fun receiveCreate(create: Create): ActivityPubResponse
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APCreateServiceImpl(
|
||||
private val apNoteService: APNoteService,
|
||||
private val transaction: Transaction
|
||||
|
|
|
@ -9,12 +9,15 @@ import dev.usbharu.hideout.service.core.Transaction
|
|||
import dev.usbharu.hideout.service.reaction.ReactionService
|
||||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface APLikeService {
|
||||
suspend fun receiveLike(like: Like): ActivityPubResponse
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APLikeServiceImpl(
|
||||
private val reactionService: ReactionService,
|
||||
private val apUserService: APUserService,
|
||||
|
|
|
@ -21,8 +21,10 @@ import io.ktor.client.statement.*
|
|||
import kjob.core.job.JobProps
|
||||
import org.koin.core.annotation.Single
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
|
||||
@Service
|
||||
interface APNoteService {
|
||||
|
||||
suspend fun createNote(post: Post)
|
||||
|
@ -33,6 +35,7 @@ interface APNoteService {
|
|||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APNoteServiceImpl(
|
||||
private val httpClient: HttpClient,
|
||||
private val jobQueueParentService: JobQueueParentService,
|
||||
|
|
|
@ -15,8 +15,10 @@ import dev.usbharu.hideout.service.job.JobQueueParentService
|
|||
import io.ktor.client.*
|
||||
import kjob.core.job.JobProps
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
|
||||
@Service
|
||||
interface APReactionService {
|
||||
suspend fun reaction(like: Reaction)
|
||||
suspend fun removeReaction(like: Reaction)
|
||||
|
@ -25,6 +27,7 @@ interface APReactionService {
|
|||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APReactionServiceImpl(
|
||||
private val jobQueueParentService: JobQueueParentService,
|
||||
private val httpClient: HttpClient,
|
||||
|
|
|
@ -16,13 +16,16 @@ import io.ktor.client.*
|
|||
import io.ktor.http.*
|
||||
import kjob.core.job.JobProps
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface APReceiveFollowService {
|
||||
suspend fun receiveFollow(follow: Follow): ActivityPubResponse
|
||||
suspend fun receiveFollowJob(props: JobProps<ReceiveFollowJob>)
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APReceiveFollowServiceImpl(
|
||||
private val jobQueueParentService: JobQueueParentService,
|
||||
private val apUserService: APUserService,
|
||||
|
|
|
@ -5,12 +5,15 @@ import dev.usbharu.hideout.domain.model.hideout.dto.SendFollowDto
|
|||
import dev.usbharu.hideout.plugins.postAp
|
||||
import io.ktor.client.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface APSendFollowService {
|
||||
suspend fun sendFollow(sendFollowDto: SendFollowDto)
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APSendFollowServiceImpl(private val httpClient: HttpClient) : APSendFollowService {
|
||||
override suspend fun sendFollow(sendFollowDto: SendFollowDto) {
|
||||
val follow = Follow(
|
||||
|
|
|
@ -12,7 +12,9 @@ import kjob.core.job.JobProps
|
|||
import org.koin.core.annotation.Single
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface APService {
|
||||
fun parseActivity(json: String): ActivityType
|
||||
|
||||
|
@ -173,6 +175,7 @@ enum class ExtendedVocabulary {
|
|||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APServiceImpl(
|
||||
private val apReceiveFollowService: APReceiveFollowService,
|
||||
private val apNoteService: APNoteService,
|
||||
|
|
|
@ -9,12 +9,16 @@ import dev.usbharu.hideout.service.core.Transaction
|
|||
import dev.usbharu.hideout.service.user.UserService
|
||||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
|
||||
@Service
|
||||
interface APUndoService {
|
||||
suspend fun receiveUndo(undo: Undo): ActivityPubResponse
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
@Suppress("UnsafeCallOnNullableType")
|
||||
class APUndoServiceImpl(
|
||||
private val userService: UserService,
|
||||
|
|
|
@ -19,7 +19,9 @@ import io.ktor.client.request.*
|
|||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface APUserService {
|
||||
suspend fun getPersonByName(name: String): Person
|
||||
|
||||
|
@ -36,6 +38,7 @@ interface APUserService {
|
|||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class APUserServiceImpl(
|
||||
private val userService: UserService,
|
||||
private val httpClient: HttpClient,
|
||||
|
|
|
@ -13,9 +13,11 @@ import dev.usbharu.hideout.service.post.PostService
|
|||
import dev.usbharu.hideout.service.reaction.ReactionService
|
||||
import dev.usbharu.hideout.util.AcctUtil
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Service
|
||||
interface PostApiService {
|
||||
suspend fun createPost(postForm: dev.usbharu.hideout.domain.model.hideout.form.Post, userId: Long): PostResponse
|
||||
suspend fun getById(id: Long, userId: Long?): PostResponse
|
||||
|
@ -44,6 +46,7 @@ interface PostApiService {
|
|||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class PostApiServiceImpl(
|
||||
private val postService: PostService,
|
||||
private val userRepository: UserRepository,
|
||||
|
|
|
@ -10,9 +10,11 @@ import dev.usbharu.hideout.query.UserQueryService
|
|||
import dev.usbharu.hideout.service.core.Transaction
|
||||
import dev.usbharu.hideout.service.user.UserService
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import kotlin.math.min
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@Service
|
||||
interface UserApiService {
|
||||
suspend fun findAll(limit: Int? = 100, offset: Long = 0): List<UserResponse>
|
||||
|
||||
|
@ -37,6 +39,7 @@ interface UserApiService {
|
|||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class UserApiServiceImpl(
|
||||
private val userQueryService: UserQueryService,
|
||||
private val followerQueryService: FollowerQueryService,
|
||||
|
|
|
@ -9,13 +9,16 @@ import dev.usbharu.hideout.service.auth.JwtService
|
|||
import dev.usbharu.hideout.service.core.Transaction
|
||||
import dev.usbharu.hideout.service.user.UserAuthServiceImpl
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface UserAuthApiService {
|
||||
suspend fun login(username: String, password: String): JwtToken
|
||||
suspend fun refreshToken(refreshToken: RefreshToken): JwtToken
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class UserAuthApiServiceImpl(
|
||||
private val userAuthService: UserAuthServiceImpl,
|
||||
private val userQueryService: UserQueryService,
|
||||
|
|
|
@ -4,12 +4,15 @@ import dev.usbharu.hideout.domain.model.hideout.entity.User
|
|||
import dev.usbharu.hideout.query.UserQueryService
|
||||
import dev.usbharu.hideout.service.core.Transaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface WebFingerApiService {
|
||||
suspend fun findByNameAndDomain(name: String, domain: String): User
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class WebFingerApiServiceImpl(private val transaction: Transaction, private val userQueryService: UserQueryService) :
|
||||
WebFingerApiService {
|
||||
override suspend fun findByNameAndDomain(name: String, domain: String): User {
|
||||
|
|
|
@ -5,13 +5,16 @@ import dev.usbharu.hideout.query.UserQueryService
|
|||
import dev.usbharu.hideout.service.core.Transaction
|
||||
import io.ktor.http.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import tech.barbero.http.message.signing.SignatureHeaderVerifier
|
||||
|
||||
@Service
|
||||
interface HttpSignatureVerifyService {
|
||||
fun verify(headers: Headers): Boolean
|
||||
}
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class HttpSignatureVerifyServiceImpl(
|
||||
private val userQueryService: UserQueryService,
|
||||
private val transaction: Transaction
|
||||
|
|
|
@ -15,10 +15,12 @@ import dev.usbharu.hideout.service.core.MetaService
|
|||
import dev.usbharu.hideout.util.RsaUtil
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
import java.time.temporal.ChronoUnit
|
||||
import java.util.*
|
||||
|
||||
@Service
|
||||
interface JwtService {
|
||||
suspend fun createToken(user: User): JwtToken
|
||||
suspend fun refreshToken(refreshToken: RefreshToken): JwtToken
|
||||
|
@ -30,6 +32,7 @@ interface JwtService {
|
|||
|
||||
@Suppress("InjectDispatcher")
|
||||
@Single
|
||||
@Service
|
||||
class JwtServiceImpl(
|
||||
private val metaService: MetaService,
|
||||
private val refreshTokenRepository: JwtRefreshTokenRepository,
|
||||
|
|
|
@ -2,8 +2,10 @@ package dev.usbharu.hideout.service.core
|
|||
|
||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class ExposedTransaction : Transaction {
|
||||
override suspend fun <T> transaction(block: suspend () -> T): T {
|
||||
return newSuspendedTransaction(transactionIsolation = java.sql.Connection.TRANSACTION_SERIALIZABLE) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package dev.usbharu.hideout.service.core
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface IdGenerateService {
|
||||
suspend fun generateId(): Long
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package dev.usbharu.hideout.service.core
|
|||
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Jwt
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Meta
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface MetaService {
|
||||
suspend fun getMeta(): Meta
|
||||
suspend fun updateMeta(meta: Meta)
|
||||
|
|
|
@ -5,8 +5,10 @@ import dev.usbharu.hideout.domain.model.hideout.entity.Meta
|
|||
import dev.usbharu.hideout.exception.NotInitException
|
||||
import dev.usbharu.hideout.repository.MetaRepository
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class MetaServiceImpl(private val metaRepository: MetaRepository, private val transaction: Transaction) :
|
||||
MetaService {
|
||||
override suspend fun getMeta(): Meta =
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package dev.usbharu.hideout.service.core
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface ServerInitialiseService {
|
||||
suspend fun init()
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ import dev.usbharu.hideout.util.ServerUtil
|
|||
import org.koin.core.annotation.Single
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import java.security.KeyPairGenerator
|
||||
import java.util.*
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class ServerInitialiseServiceImpl(
|
||||
private val metaRepository: MetaRepository,
|
||||
private val transaction: Transaction
|
||||
|
|
|
@ -3,9 +3,11 @@ package dev.usbharu.hideout.service.core
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
@Service
|
||||
open class SnowflakeIdGenerateService(private val baseTime: Long) : IdGenerateService {
|
||||
var lastTimeStamp: Long = -1
|
||||
var sequenceId: Int = 0
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package dev.usbharu.hideout.service.core
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface Transaction {
|
||||
suspend fun <T> transaction(block: suspend () -> T): T
|
||||
suspend fun <T> transaction(transactionLevel: Int, block: suspend () -> T): T
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package dev.usbharu.hideout.service.core
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
// 2010-11-04T01:42:54.657
|
||||
@Suppress("MagicNumber")
|
||||
@Service
|
||||
object TwitterSnowflakeIdGenerateService : SnowflakeIdGenerateService(1288834974657L)
|
||||
|
|
|
@ -2,7 +2,9 @@ package dev.usbharu.hideout.service.job
|
|||
|
||||
import kjob.core.Job
|
||||
import kjob.core.dsl.ScheduleContext
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface JobQueueParentService {
|
||||
|
||||
fun init(jobDefines: List<Job>)
|
||||
|
|
|
@ -2,9 +2,11 @@ package dev.usbharu.hideout.service.job
|
|||
|
||||
import kjob.core.Job
|
||||
import kjob.core.dsl.KJobFunctions
|
||||
import org.springframework.stereotype.Service
|
||||
import kjob.core.dsl.JobContextWithProps as JCWP
|
||||
import kjob.core.dsl.JobRegisterContext as JRC
|
||||
|
||||
@Service
|
||||
interface JobQueueWorkerService {
|
||||
fun init(defines: List<Pair<Job, JRC<Job, JCWP<Job>>.(Job) -> KJobFunctions<Job, JCWP<Job>>>>)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ import kjob.core.dsl.ScheduleContext
|
|||
import kjob.core.kjob
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class KJobJobQueueParentService(private val database: Database) : JobQueueParentService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
|
|
|
@ -5,9 +5,11 @@ import kjob.core.Job
|
|||
import kjob.core.dsl.KJobFunctions
|
||||
import kjob.core.kjob
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.springframework.stereotype.Service
|
||||
import kjob.core.dsl.JobContextWithProps as JCWP
|
||||
import kjob.core.dsl.JobRegisterContext as JRC
|
||||
|
||||
@Service
|
||||
class KJobJobQueueWorkerService(private val database: Database) : JobQueueWorkerService {
|
||||
|
||||
val kjob by lazy {
|
||||
|
|
|
@ -2,7 +2,9 @@ package dev.usbharu.hideout.service.post
|
|||
|
||||
import dev.usbharu.hideout.domain.model.hideout.dto.PostCreateDto
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.Post
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface PostService {
|
||||
suspend fun createLocal(post: PostCreateDto): Post
|
||||
}
|
||||
|
|
|
@ -7,8 +7,10 @@ import dev.usbharu.hideout.repository.PostRepository
|
|||
import dev.usbharu.hideout.repository.UserRepository
|
||||
import dev.usbharu.hideout.service.ap.APNoteService
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
|
||||
@Service
|
||||
@Single
|
||||
class PostServiceImpl(
|
||||
private val postRepository: PostRepository,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package dev.usbharu.hideout.service.reaction
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
interface ReactionService {
|
||||
suspend fun receiveReaction(name: String, domain: String, userId: Long, postId: Long)
|
||||
suspend fun sendReaction(name: String, userId: Long, postId: Long)
|
||||
|
|
|
@ -5,8 +5,10 @@ import dev.usbharu.hideout.query.ReactionQueryService
|
|||
import dev.usbharu.hideout.repository.ReactionRepository
|
||||
import dev.usbharu.hideout.service.ap.APReactionService
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class ReactionServiceImpl(
|
||||
private val reactionRepository: ReactionRepository,
|
||||
private val apReactionService: APReactionService,
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package dev.usbharu.hideout.service.user
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
import java.security.KeyPair
|
||||
|
||||
@Service
|
||||
interface UserAuthService {
|
||||
fun hash(password: String): String
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@ import dev.usbharu.hideout.config.Config
|
|||
import dev.usbharu.hideout.query.UserQueryService
|
||||
import io.ktor.util.*
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import java.security.*
|
||||
import java.util.*
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class UserAuthServiceImpl(
|
||||
val userQueryService: UserQueryService
|
||||
) : UserAuthService {
|
||||
|
|
|
@ -3,8 +3,10 @@ package dev.usbharu.hideout.service.user
|
|||
import dev.usbharu.hideout.domain.model.hideout.dto.RemoteUserCreateDto
|
||||
import dev.usbharu.hideout.domain.model.hideout.dto.UserCreateDto
|
||||
import dev.usbharu.hideout.domain.model.hideout.entity.User
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
@Service
|
||||
interface UserService {
|
||||
|
||||
suspend fun usernameAlreadyUse(username: String): Boolean
|
||||
|
|
|
@ -11,9 +11,11 @@ import dev.usbharu.hideout.query.UserQueryService
|
|||
import dev.usbharu.hideout.repository.UserRepository
|
||||
import dev.usbharu.hideout.service.ap.APSendFollowService
|
||||
import org.koin.core.annotation.Single
|
||||
import org.springframework.stereotype.Service
|
||||
import java.time.Instant
|
||||
|
||||
@Single
|
||||
@Service
|
||||
class UserServiceImpl(
|
||||
private val userRepository: UserRepository,
|
||||
private val userAuthService: UserAuthService,
|
||||
|
|
Loading…
Reference in New Issue