diff --git a/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceCommandService.kt b/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceCommandService.kt index 18561a9..029673c 100644 --- a/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceCommandService.kt +++ b/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceCommandService.kt @@ -48,10 +48,13 @@ class SpaceCommandService( userId = userId, spaceId = DomainId(command.spaceId), ).apply { + if (isMain) { + updateMainSpace(userId) + } + delete() spaceManagementPort.deleteBy(this) } - updateMainSpace(userId) reIndexingSpaceOrder(userId) } @@ -62,10 +65,13 @@ class SpaceCommandService( userId = userId, spaceIds = command.spaceIds.map { DomainId(it) }, ).forEach { + if (it.isMain) { + updateMainSpace(userId) + } it.delete() spaceManagementPort.deleteBy(it) } - updateMainSpace(userId) + reIndexingSpaceOrder(userId) } diff --git a/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceQueryService.kt b/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceQueryService.kt index e64dc80..602a0be 100644 --- a/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceQueryService.kt +++ b/Application-Module/src/main/kotlin/com/asap/application/space/service/SpaceQueryService.kt @@ -39,7 +39,7 @@ class SpaceQueryService( val spaces = spaceManagementPort.getAllSpaceBy( userId = DomainId(query.userId), - ) + ).sortedBy { it.index } return GetSpaceUsecase.GetAllResponse( spaces = diff --git a/Infrastructure-Module/Persistence/src/main/resources/db/V1_18__drop_trigger.sql b/Infrastructure-Module/Persistence/src/main/resources/db/V1_18__drop_trigger.sql new file mode 100644 index 0000000..71b58ca --- /dev/null +++ b/Infrastructure-Module/Persistence/src/main/resources/db/V1_18__drop_trigger.sql @@ -0,0 +1 @@ +drop trigger if exists update_space_is_main; \ No newline at end of file