refactor: Application Serviceをリファクタリング2

This commit is contained in:
usbharu 2024-09-14 21:43:56 +09:00
parent bde0b31d28
commit 3a923c7c57
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
25 changed files with 58 additions and 191 deletions

View File

@ -1,5 +0,0 @@
package dev.usbharu.hideout.core.application.actor
import dev.usbharu.hideout.core.domain.model.actor.ActorId
data class DeleteLocalActor(val actorId: ActorId)

View File

@ -1,8 +0,0 @@
package dev.usbharu.hideout.core.application.actor
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
data class GetActorDetail(
val actorName: Acct? = null,
val id: Long? = null
)

View File

@ -7,6 +7,7 @@ import dev.usbharu.hideout.core.config.ApplicationConfig
import dev.usbharu.hideout.core.domain.model.actor.ActorId
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.media.MediaRepository
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
@ -48,3 +49,8 @@ class GetActorDetailApplicationService(
private val logger = LoggerFactory.getLogger(GetActorDetailApplicationService::class.java)
}
}
data class GetActorDetail(
val actorName: Acct? = null,
val id: Long? = null
)

View File

@ -1,19 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.actor
data class GetUserDetail(val id: Long)

View File

@ -51,3 +51,5 @@ class GetUserDetailApplicationService(
val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java)
}
}
data class GetUserDetail(val id: Long)

View File

@ -1,3 +0,0 @@
package dev.usbharu.hideout.core.application.actor
data class MigrationLocalActor(val from: Long, val to: Long)

View File

@ -74,3 +74,5 @@ class MigrationLocalActorApplicationService(
private val logger = LoggerFactory.getLogger(MigrationLocalActorApplicationService::class.java)
}
}
data class MigrationLocalActor(val from: Long, val to: Long)

View File

@ -1,22 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.actor
data class RegisterLocalActor(
val name: String,
val password: String,
)

View File

@ -76,3 +76,8 @@ class RegisterLocalActorApplicationService(
private val logger = LoggerFactory.getLogger(RegisterLocalActorApplicationService::class.java)
}
}
data class RegisterLocalActor(
val name: String,
val password: String,
)

View File

@ -1,8 +0,0 @@
package dev.usbharu.hideout.core.application.actor
import org.springframework.stereotype.Service
@Service
interface SetAlsoKnownAsLocalActorApplicationService {
suspend fun setAlsoKnownAs(actorId: Long, alsoKnownAs: List<Long>)
}

View File

@ -20,6 +20,7 @@ import dev.usbharu.hideout.core.application.exception.InternalServerException
import dev.usbharu.hideout.core.application.exception.PermissionDeniedException
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
import dev.usbharu.hideout.core.application.shared.Transaction
import dev.usbharu.hideout.core.domain.model.actor.ActorId
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
import dev.usbharu.hideout.core.domain.model.support.principal.LocalUser
import org.slf4j.LoggerFactory
@ -44,3 +45,5 @@ class StartDeleteLocalActorApplicationService(
private val logger = LoggerFactory.getLogger(StartDeleteLocalActorApplicationService::class.java)
}
}
data class DeleteLocalActor(val actorId: ActorId)

View File

@ -1,3 +0,0 @@
package dev.usbharu.hideout.core.application.actor
data class SuspendLocalActor(val actorId: Long)

View File

@ -42,3 +42,5 @@ class SuspendLocalActorApplicationService(
private val logger = LoggerFactory.getLogger(SuspendLocalActorApplicationService::class.java)
}
}
data class SuspendLocalActor(val actorId: Long)

View File

@ -1,3 +0,0 @@
package dev.usbharu.hideout.core.application.actor
data class UnsuspendLocalActor(val actorId: Long)

View File

@ -42,3 +42,5 @@ class UnsuspendLocalActorApplicationService(
private val logger = LoggerFactory.getLogger(UnsuspendLocalActorApplicationService::class.java)
}
}
data class UnsuspendLocalActor(val actorId: Long)

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.application
import java.net.URI
data class RegisterApplication(
val name: String,
val redirectUris: Set<URI>,
val useRefreshToken: Boolean,
val scopes: Set<String>,
)

View File

@ -16,6 +16,7 @@
package dev.usbharu.hideout.core.application.application
import dev.usbharu.hideout.core.application.model.Application
import dev.usbharu.hideout.core.application.shared.AbstractApplicationService
import dev.usbharu.hideout.core.application.shared.Transaction
import dev.usbharu.hideout.core.domain.model.application.Application
@ -34,6 +35,7 @@ import org.springframework.security.oauth2.server.authorization.client.Registere
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings
import org.springframework.stereotype.Service
import java.net.URI
import java.time.Duration
@Service
@ -44,9 +46,15 @@ class RegisterApplicationApplicationService(
private val registeredClientRepository: RegisteredClientRepository,
transaction: Transaction,
private val applicationRepository: ApplicationRepository,
) : AbstractApplicationService<RegisterApplication, RegisteredApplication>(transaction, logger) {
) : AbstractApplicationService<RegisterApplication, dev.usbharu.hideout.core.application.model.Application>(
transaction,
logger
) {
override suspend fun internalExecute(command: RegisterApplication, principal: Principal): RegisteredApplication {
override suspend fun internalExecute(
command: RegisterApplication,
principal: Principal
): dev.usbharu.hideout.core.application.model.Application {
val id = idGenerateService.generateId()
val clientSecret = secureTokenGenerator.generate()
val registeredClient = RegisteredClient
@ -82,7 +90,7 @@ class RegisterApplicationApplicationService(
val application = Application(ApplicationId(id), ApplicationName(command.name))
applicationRepository.save(application)
return RegisteredApplication(
return dev.usbharu.hideout.core.application.model.Application(
id = id,
name = command.name,
clientSecret = clientSecret,
@ -95,3 +103,10 @@ class RegisterApplicationApplicationService(
private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java)
}
}
data class RegisterApplication(
val name: String,
val redirectUris: Set<URI>,
val useRefreshToken: Boolean,
val scopes: Set<String>,
)

View File

@ -1,19 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.filter
data class DeleteFilter(val filterId: Long)

View File

@ -1,19 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.filter
data class GetFilter(val filterId: Long)

View File

@ -1,27 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.filter
import dev.usbharu.hideout.core.domain.model.filter.FilterAction
import dev.usbharu.hideout.core.domain.model.filter.FilterContext
data class RegisterFilter(
val filterName: String,
val filterContext: Set<FilterContext>,
val filterAction: FilterAction,
val filterKeywords: Set<RegisterFilterKeyword>,
)

View File

@ -1,24 +0,0 @@
/*
* Copyright (C) 2024 usbharu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.filter
import dev.usbharu.hideout.core.domain.model.filter.FilterMode
data class RegisterFilterKeyword(
val keyword: String,
val filterMode: FilterMode,
)

View File

@ -44,3 +44,5 @@ class UserDeleteFilterApplicationService(private val filterRepository: FilterRep
private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java)
}
}
data class DeleteFilter(val filterId: Long)

View File

@ -45,3 +45,5 @@ class UserGetFilterApplicationService(private val filterRepository: FilterReposi
private val logger = LoggerFactory.getLogger(UserGetFilterApplicationService::class.java)
}
}
data class GetFilter(val filterId: Long)

View File

@ -61,3 +61,15 @@ class UserRegisterFilterApplicationService(
private val logger = LoggerFactory.getLogger(UserRegisterFilterApplicationService::class.java)
}
}
data class RegisterFilter(
val filterName: String,
val filterContext: Set<FilterContext>,
val filterAction: FilterAction,
val filterKeywords: Set<RegisterFilterKeyword>,
)
data class RegisterFilterKeyword(
val keyword: String,
val filterMode: FilterMode,
)

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
package dev.usbharu.hideout.core.application.application
package dev.usbharu.hideout.core.application.model
import java.net.URI
data class RegisteredApplication(
data class Application(
val id: Long,
val name: String,
val redirectUris: Set<URI>,