diff --git a/piikii-application/src/main/kotlin/com/piikii/application/domain/place/PlaceService.kt b/piikii-application/src/main/kotlin/com/piikii/application/domain/place/PlaceService.kt index df564672..29397079 100644 --- a/piikii-application/src/main/kotlin/com/piikii/application/domain/place/PlaceService.kt +++ b/piikii-application/src/main/kotlin/com/piikii/application/domain/place/PlaceService.kt @@ -2,12 +2,12 @@ package com.piikii.application.domain.place import com.piikii.application.domain.generic.LongTypeId import com.piikii.application.domain.generic.UuidTypeId +import com.piikii.application.domain.image.ImageFolderType import com.piikii.application.port.input.PlaceUseCase import com.piikii.application.port.input.dto.request.AddPlaceRequest import com.piikii.application.port.input.dto.request.ModifyPlaceRequest import com.piikii.application.port.input.dto.response.PlaceResponse import com.piikii.application.port.input.dto.response.ScheduleTypeGroupResponse -import com.piikii.application.port.output.objectstorage.BucketFolderType import com.piikii.application.port.output.objectstorage.ObjectStoragePort import com.piikii.application.port.output.persistence.PlaceCommandPort import com.piikii.application.port.output.persistence.PlaceQueryPort @@ -32,25 +32,16 @@ class PlaceService( override fun addPlace( targetRoomUid: UuidTypeId, addPlaceRequest: AddPlaceRequest, - placeImages: List?, + placeImageUrls: List, ): List { - val imageUrls = - placeImages?.let { - objectStoragePort.uploadAll( - bucketFolderType = BUCKET_TYPE, - multipartFiles = it, - ).get() - } ?: listOf() - val room = roomQueryPort.findById(targetRoomUid) val schedules = scheduleQueryPort.findAllByIds(addPlaceRequest.scheduleIds.map(::LongTypeId)) - val places = schedules.map { schedule -> addPlaceRequest.toDomain( roomUid = room.roomUid, scheduleId = schedule.id, - imageUrls = imageUrls, + imageUrls = placeImageUrls, ) } @@ -83,7 +74,7 @@ class PlaceService( val updatedUrls = newPlaceImages?.let { objectStoragePort.updateAllByUrls( - bucketFolderType = BUCKET_TYPE, + imageFolderType = BUCKET_TYPE, deleteTargetUrls = modifyPlaceRequest.deleteTargetUrls, newMultipartFiles = it, ).get() @@ -107,7 +98,7 @@ class PlaceService( @Transactional override fun delete(targetPlaceId: LongTypeId) { objectStoragePort.deleteAllByUrls( - bucketFolderType = BUCKET_TYPE, + imageFolderType = BUCKET_TYPE, deleteTargetUrls = isPlaceNullOrGet(targetPlaceId).thumbnailLinks.convertToList, ) placeCommandPort.delete(targetPlaceId) @@ -128,6 +119,6 @@ class PlaceService( } companion object { - private val BUCKET_TYPE = BucketFolderType.PLACE + private val BUCKET_TYPE = ImageFolderType.PLACE } } diff --git a/piikii-application/src/main/kotlin/com/piikii/application/port/input/PlaceUseCase.kt b/piikii-application/src/main/kotlin/com/piikii/application/port/input/PlaceUseCase.kt index 7c29202d..c25647c0 100644 --- a/piikii-application/src/main/kotlin/com/piikii/application/port/input/PlaceUseCase.kt +++ b/piikii-application/src/main/kotlin/com/piikii/application/port/input/PlaceUseCase.kt @@ -12,7 +12,7 @@ interface PlaceUseCase { fun addPlace( targetRoomUid: UuidTypeId, addPlaceRequest: AddPlaceRequest, - placeImages: List?, + placeImageUrls: List, ): List fun findAllByRoomUidGroupByPlaceType(roomUid: UuidTypeId): List diff --git a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt index adbd1ed6..d2a279fd 100644 --- a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt +++ b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt @@ -2,6 +2,8 @@ package com.piikii.input.http.controller import com.piikii.application.domain.generic.LongTypeId import com.piikii.application.domain.generic.UuidTypeId +import com.piikii.application.domain.image.ImageFolderType +import com.piikii.application.port.input.ImageUploadUseCase import com.piikii.application.port.input.PlaceUseCase import com.piikii.application.port.input.dto.request.AddPlaceRequest import com.piikii.application.port.input.dto.request.ModifyPlaceRequest @@ -31,6 +33,7 @@ import java.util.UUID @RequestMapping("/v1/rooms/{roomUid}/places") class PlaceApi( private val placeUseCase: PlaceUseCase, + private val imageUploadUseCase: ImageUploadUseCase, ) : PlaceDocs { @ResponseStatus(HttpStatus.CREATED) @PostMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) @@ -39,7 +42,8 @@ class PlaceApi( @Valid @NotNull @RequestPart addPlaceRequest: AddPlaceRequest, @RequestPart(required = false) placeImages: List?, ): ResponseForm> { - return ResponseForm(placeUseCase.addPlace(UuidTypeId(roomUid), addPlaceRequest, placeImages)) + val placeImageUrls = imageUploadUseCase.upload(placeImages, ImageFolderType.PLACE) + return ResponseForm(placeUseCase.addPlace(UuidTypeId(roomUid), addPlaceRequest, placeImageUrls)) } @GetMapping