mirror of https://github.com/usbharu/Hideout.git
refactor: Application Serviceをリファクタリング2
This commit is contained in:
parent
bde0b31d28
commit
3a923c7c57
|
@ -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)
|
|
|
@ -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
|
|
||||||
)
|
|
|
@ -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.ActorId
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
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.media.MediaRepository
|
||||||
|
import dev.usbharu.hideout.core.domain.model.support.acct.Acct
|
||||||
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
import dev.usbharu.hideout.core.domain.model.support.principal.Principal
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
@ -48,3 +49,8 @@ class GetActorDetailApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(GetActorDetailApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(GetActorDetailApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class GetActorDetail(
|
||||||
|
val actorName: Acct? = null,
|
||||||
|
val id: Long? = null
|
||||||
|
)
|
|
@ -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)
|
|
|
@ -51,3 +51,5 @@ class GetUserDetailApplicationService(
|
||||||
val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java)
|
val logger = LoggerFactory.getLogger(GetUserDetailApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class GetUserDetail(val id: Long)
|
|
@ -1,3 +0,0 @@
|
||||||
package dev.usbharu.hideout.core.application.actor
|
|
||||||
|
|
||||||
data class MigrationLocalActor(val from: Long, val to: Long)
|
|
|
@ -74,3 +74,5 @@ class MigrationLocalActorApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(MigrationLocalActorApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(MigrationLocalActorApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class MigrationLocalActor(val from: Long, val to: Long)
|
|
@ -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,
|
|
||||||
)
|
|
|
@ -76,3 +76,8 @@ class RegisterLocalActorApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(RegisterLocalActorApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(RegisterLocalActorApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class RegisterLocalActor(
|
||||||
|
val name: String,
|
||||||
|
val password: String,
|
||||||
|
)
|
|
@ -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>)
|
|
||||||
}
|
|
|
@ -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.exception.PermissionDeniedException
|
||||||
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
import dev.usbharu.hideout.core.application.shared.LocalUserAbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
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.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.domain.model.support.principal.LocalUser
|
import dev.usbharu.hideout.core.domain.model.support.principal.LocalUser
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
@ -44,3 +45,5 @@ class StartDeleteLocalActorApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(StartDeleteLocalActorApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(StartDeleteLocalActorApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class DeleteLocalActor(val actorId: ActorId)
|
|
@ -1,3 +0,0 @@
|
||||||
package dev.usbharu.hideout.core.application.actor
|
|
||||||
|
|
||||||
data class SuspendLocalActor(val actorId: Long)
|
|
|
@ -42,3 +42,5 @@ class SuspendLocalActorApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(SuspendLocalActorApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(SuspendLocalActorApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class SuspendLocalActor(val actorId: Long)
|
|
@ -1,3 +0,0 @@
|
||||||
package dev.usbharu.hideout.core.application.actor
|
|
||||||
|
|
||||||
data class UnsuspendLocalActor(val actorId: Long)
|
|
|
@ -42,3 +42,5 @@ class UnsuspendLocalActorApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(UnsuspendLocalActorApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(UnsuspendLocalActorApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class UnsuspendLocalActor(val actorId: Long)
|
|
@ -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>,
|
|
||||||
)
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.application
|
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.AbstractApplicationService
|
||||||
import dev.usbharu.hideout.core.application.shared.Transaction
|
import dev.usbharu.hideout.core.application.shared.Transaction
|
||||||
import dev.usbharu.hideout.core.domain.model.application.Application
|
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.ClientSettings
|
||||||
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings
|
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
import java.net.URI
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -44,9 +46,15 @@ class RegisterApplicationApplicationService(
|
||||||
private val registeredClientRepository: RegisteredClientRepository,
|
private val registeredClientRepository: RegisteredClientRepository,
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
private val applicationRepository: ApplicationRepository,
|
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 id = idGenerateService.generateId()
|
||||||
val clientSecret = secureTokenGenerator.generate()
|
val clientSecret = secureTokenGenerator.generate()
|
||||||
val registeredClient = RegisteredClient
|
val registeredClient = RegisteredClient
|
||||||
|
@ -82,7 +90,7 @@ class RegisterApplicationApplicationService(
|
||||||
val application = Application(ApplicationId(id), ApplicationName(command.name))
|
val application = Application(ApplicationId(id), ApplicationName(command.name))
|
||||||
|
|
||||||
applicationRepository.save(application)
|
applicationRepository.save(application)
|
||||||
return RegisteredApplication(
|
return dev.usbharu.hideout.core.application.model.Application(
|
||||||
id = id,
|
id = id,
|
||||||
name = command.name,
|
name = command.name,
|
||||||
clientSecret = clientSecret,
|
clientSecret = clientSecret,
|
||||||
|
@ -95,3 +103,10 @@ class RegisterApplicationApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(RegisterApplicationApplicationService::class.java)
|
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>,
|
||||||
|
)
|
|
@ -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)
|
|
|
@ -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)
|
|
|
@ -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>,
|
|
||||||
)
|
|
|
@ -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,
|
|
||||||
)
|
|
|
@ -44,3 +44,5 @@ class UserDeleteFilterApplicationService(private val filterRepository: FilterRep
|
||||||
private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(UserDeleteFilterApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class DeleteFilter(val filterId: Long)
|
|
@ -45,3 +45,5 @@ class UserGetFilterApplicationService(private val filterRepository: FilterReposi
|
||||||
private val logger = LoggerFactory.getLogger(UserGetFilterApplicationService::class.java)
|
private val logger = LoggerFactory.getLogger(UserGetFilterApplicationService::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class GetFilter(val filterId: Long)
|
|
@ -61,3 +61,15 @@ class UserRegisterFilterApplicationService(
|
||||||
private val logger = LoggerFactory.getLogger(UserRegisterFilterApplicationService::class.java)
|
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,
|
||||||
|
)
|
|
@ -14,11 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package dev.usbharu.hideout.core.application.application
|
package dev.usbharu.hideout.core.application.model
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
data class RegisteredApplication(
|
data class Application(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val name: String,
|
val name: String,
|
||||||
val redirectUris: Set<URI>,
|
val redirectUris: Set<URI>,
|
Loading…
Reference in New Issue