Skip to content

Commit

Permalink
refactor: (#281) application response 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Jan 14, 2023
1 parent b053e14 commit d85d5aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package team.comit.simtong.domain.file.usecase

import team.comit.simtong.domain.file.dto.response.UploadImageListResponse
import team.comit.simtong.domain.file.dto.response.UploadImageResponse
import team.comit.simtong.domain.file.spi.UploadFilePort
import team.comit.simtong.global.annotation.UseCase
import java.io.File
Expand All @@ -10,18 +12,20 @@ import java.io.File
*
* @author Chokyunghyeon
* @date 2022/09/20
* @version 1.0.0
* @version 1.2.5
**/
@UseCase
class UploadImageUseCase(
private val uploadFilePort: UploadFilePort
) {

fun execute(file: File): String {
fun execute(file: File): UploadImageResponse {
return uploadFilePort.upload(file)
.let(::UploadImageResponse)
}

fun execute(files: List<File>): List<String> {
fun execute(files: List<File>): UploadImageListResponse {
return uploadFilePort.upload(files)
.let(::UploadImageListResponse)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import team.comit.simtong.domain.file.dto.response.UploadImageListWebResponse
import team.comit.simtong.domain.file.dto.response.UploadImageWebResponse
import team.comit.simtong.domain.file.converter.ExcelFileConverter
import team.comit.simtong.domain.file.converter.ImageFileConverter
import team.comit.simtong.domain.file.dto.response.UploadImageListResponse
import team.comit.simtong.domain.file.dto.response.UploadImageResponse
import team.comit.simtong.domain.file.usecase.RegisterEmployeeCertificateUseCase
import team.comit.simtong.domain.file.usecase.UploadImageUseCase

Expand All @@ -19,7 +19,7 @@ import team.comit.simtong.domain.file.usecase.UploadImageUseCase
*
* @author Chokyunghyeon
* @date 2022/09/21
* @version 1.0.0
* @version 1.2.5
**/
@RestController
@RequestMapping("/files")
Expand All @@ -30,21 +30,17 @@ class WebFileAdapter(

@PostMapping
@ResponseStatus(HttpStatus.CREATED)
fun uploadSingleImage(file: MultipartFile): UploadImageWebResponse {
return UploadImageWebResponse(
uploadImageUseCase.execute(
file.let(ImageFileConverter::transferTo)
)
fun uploadSingleImage(file: MultipartFile): UploadImageResponse {
return uploadImageUseCase.execute(
file.let(ImageFileConverter::transferTo)
)
}

@PostMapping("/list")
@ResponseStatus(HttpStatus.CREATED)
fun uploadMultipleImage(files: List<MultipartFile>): UploadImageListWebResponse {
return UploadImageListWebResponse(
uploadImageUseCase.execute(
files.let(ImageFileConverter::transferToList)
)
fun uploadMultipleImage(files: List<MultipartFile>): UploadImageListResponse {
return uploadImageUseCase.execute(
files.let(ImageFileConverter::transferToList)
)
}

Expand Down

0 comments on commit d85d5aa

Please sign in to comment.