From 29c9cc9cc944b5ff387b4be4131a18ab318eb12b Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:36:12 +0900 Subject: [PATCH 01/31] feat ( #53 ) : PathList --- .../kotlin/hs/kr/entrydsm/domain/file/object/PathList.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/object/PathList.kt diff --git a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/object/PathList.kt b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/object/PathList.kt new file mode 100644 index 00000000..dfb812aa --- /dev/null +++ b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/object/PathList.kt @@ -0,0 +1,5 @@ +package hs.kr.entrydsm.domain.file.`object` + +object PathList { + const val PHOTO = "entry_photo/" +} \ No newline at end of file From df337411eedf450ed1b5d082ca9ec1c71b5841eb Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:36:21 +0900 Subject: [PATCH 02/31] feat ( #53 ) : ImageFileConverter --- .../presentation/converter/ImageFileConverter.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/ImageFileConverter.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/ImageFileConverter.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/ImageFileConverter.kt new file mode 100644 index 00000000..080a0842 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/ImageFileConverter.kt @@ -0,0 +1,16 @@ +package hs.kr.entrydsm.application.domain.file.presentation.converter + +import hs.kr.entrydsm.application.domain.file.presentation.converter.FileExtensions.HEIC +import hs.kr.entrydsm.application.domain.file.presentation.converter.FileExtensions.JPEG +import hs.kr.entrydsm.application.domain.file.presentation.converter.FileExtensions.JPG +import hs.kr.entrydsm.application.domain.file.presentation.converter.FileExtensions.PNG +import org.springframework.web.multipart.MultipartFile + +object ImageFileConverter : FileConverter { + override fun isCorrectExtension(multipartFile: MultipartFile): Boolean { + return when (multipartFile.extension) { + JPG, JPEG, PNG, HEIC -> true + else -> false + } + } +} \ No newline at end of file From 3a526558b33154cb498acd160ef06fbfba640061 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:36:28 +0900 Subject: [PATCH 03/31] feat ( #53 ) : PhotoJpaEntity --- .../application/domain/entity/PhotoJpaEntity.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/PhotoJpaEntity.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/PhotoJpaEntity.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/PhotoJpaEntity.kt new file mode 100644 index 00000000..77b2379a --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/PhotoJpaEntity.kt @@ -0,0 +1,17 @@ +package hs.kr.entrydsm.application.domain.application.domain.entity + +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.Id +import jakarta.persistence.Table +import java.util.UUID + +@Entity +@Table(name = "tbl_photo") +class PhotoJpaEntity( + @Id + val userId: UUID, + + @Column(name = "photo_path", nullable = false) + var photo: String, +) From 506701f9441a5b61e0f4d427f12dbfb6729ffc0f Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:36:38 +0900 Subject: [PATCH 04/31] feat ( #53 ) : PhotoJpaRepository --- .../domain/repository/PhotoJpaRepository.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt new file mode 100644 index 00000000..7de4001e --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt @@ -0,0 +1,10 @@ +package hs.kr.entrydsm.application.domain.application.domain.repository + +import hs.kr.entrydsm.application.domain.application.domain.entity.PhotoJpaEntity +import org.springframework.data.jpa.repository.JpaRepository +import java.util.UUID + +interface PhotoJpaRepository : JpaRepository { + + fun findByUserId(userId: UUID): PhotoJpaEntity? +} \ No newline at end of file From e9f41762b7debce0b562a87d10b15a359569e697 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:36:47 +0900 Subject: [PATCH 05/31] feat ( #53 ) : UploadFilePort --- .../hs/kr/entrydsm/domain/file/spi/UploadFilePort.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/UploadFilePort.kt diff --git a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/UploadFilePort.kt b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/UploadFilePort.kt new file mode 100644 index 00000000..9b57890f --- /dev/null +++ b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/UploadFilePort.kt @@ -0,0 +1,7 @@ +package hs.kr.entrydsm.domain.file.spi + +import java.io.File + +interface UploadFilePort { + fun upload(file: File, path: String): String +} \ No newline at end of file From f6f2007f512570adb7306ebfddcc1671b6207b27 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:36:55 +0900 Subject: [PATCH 06/31] feat ( #53 ) : WebException --- .../kotlin/hs/kr/entrydsm/global/exception/WebException.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/WebException.kt diff --git a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/WebException.kt b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/WebException.kt new file mode 100644 index 00000000..5e4fcbb8 --- /dev/null +++ b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/WebException.kt @@ -0,0 +1,6 @@ +package hs.kr.entrydsm.global.exception + +abstract class WebException( + open val status: Int, + override val message: String, +) : RuntimeException() \ No newline at end of file From e98bae4e7ffc7ec8a8c4829437f36249b0e99b76 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:02 +0900 Subject: [PATCH 07/31] feat ( #53 ) : WebFileExceptions --- .../presentation/exception/WebFileExceptions.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/WebFileExceptions.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/WebFileExceptions.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/WebFileExceptions.kt new file mode 100644 index 00000000..f670b6c7 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/WebFileExceptions.kt @@ -0,0 +1,14 @@ +package hs.kr.entrydsm.application.domain.file.presentation.exception + +import hs.kr.entrydsm.global.exception.WebException + +sealed class WebFileExceptions( + override val status: Int, + override val message: String, +) : WebException(status, message) { + class InvalidExtension(message: String = INVALID_EXTENSION) : WebFileExceptions(400, message) + + companion object { + private const val INVALID_EXTENSION = "확장자가 유효하지 않습니다." + } +} \ No newline at end of file From 6654be68032df0587a8a7841d2ae411c17bb0c21 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:11 +0900 Subject: [PATCH 08/31] feat ( #53 ) : FileConverter --- .../presentation/converter/FileConverter.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileConverter.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileConverter.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileConverter.kt new file mode 100644 index 00000000..6018767b --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileConverter.kt @@ -0,0 +1,31 @@ +package hs.kr.entrydsm.application.domain.file.presentation.converter + +import hs.kr.entrydsm.application.domain.file.presentation.exception.WebFileExceptions +import org.springframework.web.multipart.MultipartFile +import java.io.File +import java.io.FileOutputStream +import java.util.UUID + +interface FileConverter { + val MultipartFile.extension: String + get() = originalFilename?.substringAfterLast(".", "")?.uppercase() ?: "" + + fun isCorrectExtension(multipartFile: MultipartFile): Boolean + + fun transferTo(multipartFile: MultipartFile): File { + if (!isCorrectExtension(multipartFile)) { + throw WebFileExceptions.InvalidExtension() + } + + return transferFile(multipartFile) + } + + private fun transferFile(multipartFile: MultipartFile): File { + return File("${UUID.randomUUID()}_${multipartFile.originalFilename}") + .apply { + FileOutputStream(this).use { + it.write(multipartFile.bytes) + } + } + } +} \ No newline at end of file From cf82228211351c8e0b7bdae72b9a2ed447dc4dc1 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:18 +0900 Subject: [PATCH 09/31] feat ( #53 ) : FileExtensions --- .../domain/file/presentation/converter/FileExtensions.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileExtensions.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileExtensions.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileExtensions.kt new file mode 100644 index 00000000..e6317d5a --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/converter/FileExtensions.kt @@ -0,0 +1,8 @@ +package hs.kr.entrydsm.application.domain.file.presentation.converter + +object FileExtensions { + const val JPG = "JPG" + const val JPEG = "JPEG" + const val PNG = "PNG" + const val HEIC = "HEIC" +} From 6008d21f4ed1a5158a98d90808af891703991323 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:25 +0900 Subject: [PATCH 10/31] feat ( #53 ) : FileUploadUseCase --- .../application/usecase/FileUploadUseCase.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt new file mode 100644 index 00000000..08c9e5c3 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt @@ -0,0 +1,35 @@ +package hs.kr.entrydsm.application.domain.application.usecase + +import hs.kr.entrydsm.application.domain.application.domain.entity.PhotoJpaEntity +import hs.kr.entrydsm.application.domain.application.domain.repository.PhotoJpaRepository +import hs.kr.entrydsm.application.global.security.SecurityAdapter +import hs.kr.entrydsm.domain.file.spi.UploadFilePort +import hs.kr.entrydsm.domain.file.`object`.PathList +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional +import java.io.File + +@Component +class FileUploadUseCase( + private val uploadFilePort: UploadFilePort, + private val photoJpaRepository: PhotoJpaRepository, + private val securityAdapter: SecurityAdapter, +) { + @Transactional + fun execute(file: File): String { + val userId = securityAdapter.getCurrentUserId() + val photoUrl = uploadFilePort.upload(file, PathList.PHOTO) + + photoJpaRepository.findByUserId(userId)?.apply { + photo = photoUrl + photoJpaRepository.save(this) + } ?: photoJpaRepository.save( + PhotoJpaEntity( + userId = userId, + photo = photoUrl + ) + ) + + return photoUrl + } +} \ No newline at end of file From 569418878d9cccc398a8b7eaf44252e2e2550209 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:33 +0900 Subject: [PATCH 11/31] feat ( #53 ) : GenerateFileUrlPort --- .../hs/kr/entrydsm/domain/file/spi/GenerateFileUrlPort.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/GenerateFileUrlPort.kt diff --git a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/GenerateFileUrlPort.kt b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/GenerateFileUrlPort.kt new file mode 100644 index 00000000..06febd57 --- /dev/null +++ b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/file/spi/GenerateFileUrlPort.kt @@ -0,0 +1,5 @@ +package hs.kr.entrydsm.domain.file.spi + +interface GenerateFileUrlPort { + fun generateFileUrl(fileName: String, path: String): String +} \ No newline at end of file From bad8c7301ae25a7c1555fdd2ecf7dc365c245d79 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:39 +0900 Subject: [PATCH 12/31] feat ( #53 ) : FileController --- .../presentation/FileController.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt new file mode 100644 index 00000000..709165b5 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt @@ -0,0 +1,24 @@ +package hs.kr.entrydsm.application.domain.application.presentation + +import hs.kr.entrydsm.application.domain.application.usecase.FileUploadUseCase +import hs.kr.entrydsm.application.domain.file.presentation.converter.ImageFileConverter +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestPart +import org.springframework.web.bind.annotation.RestController +import org.springframework.web.multipart.MultipartFile + +@RequestMapping("/photo") +@RestController +class FileController( + private val fileUploadUseCase: FileUploadUseCase +) { + @PostMapping + fun uploadPhoto(@RequestPart(name = "image") file: MultipartFile): ResponseEntity> { + val photoUrl = fileUploadUseCase.execute( + file.let(ImageFileConverter::transferTo) + ) + return ResponseEntity.ok(mapOf("photo_url" to photoUrl)) + } +} \ No newline at end of file From 7474b3515c11d6a0849998b0f5e5d265819a754c Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:37:53 +0900 Subject: [PATCH 13/31] feat ( #53 ) : AwsS3Adapter --- .../global/storage/AwsS3Adapter.kt | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt new file mode 100644 index 00000000..39f992b1 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt @@ -0,0 +1,70 @@ +package hs.kr.entrydsm.application.global.storage + +import com.amazonaws.HttpMethod +import com.amazonaws.services.s3.AmazonS3Client +import com.amazonaws.services.s3.internal.Mimetypes +import com.amazonaws.services.s3.model.CannedAccessControlList +import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest +import com.amazonaws.services.s3.model.ObjectMetadata +import com.amazonaws.services.s3.model.PutObjectRequest +import hs.kr.entrydsm.domain.file.spi.GenerateFileUrlPort +import hs.kr.entrydsm.domain.file.spi.UploadFilePort +import org.springframework.stereotype.Component +import java.io.File +import java.io.IOException +import java.util.Date + +@Component +class AwsS3Adapter( + private val amazonS3Client: AmazonS3Client, + private val awsProperties: AwsProperties +) : UploadFilePort, GenerateFileUrlPort { + + companion object { + const val EXP_TIME = 1000 * 60 * 2 + } + + override fun upload(file: File, path: String): String { + runCatching { inputS3(file, path) } + .also { file.delete() } + + return getS3Url(path) + } + + private fun inputS3(file: File, path: String) { + try { + val inputStream = file.inputStream() + val objectMetadata = ObjectMetadata().apply { + contentLength = file.length() + contentType = Mimetypes.getInstance().getMimetype(file) + } + + amazonS3Client.putObject( + PutObjectRequest( + awsProperties.bucket, + path, + inputStream, + objectMetadata + ).withCannedAcl(CannedAccessControlList.PublicRead) + ) + } catch (e: IOException) { + throw IllegalArgumentException("File Exception") + } + } + + private fun getS3Url(path: String): String { + return amazonS3Client.getUrl(awsProperties.bucket, path).toString() + } + + override fun generateFileUrl(fileName: String, path: String): String { + val expiration = Date().apply { + time += EXP_TIME + } + return amazonS3Client.generatePresignedUrl( + GeneratePresignedUrlRequest( + awsProperties.bucket, + "${path}$fileName" + ).withMethod(HttpMethod.GET).withExpiration(expiration) + ).toString() + } +} \ No newline at end of file From dcfee8123098aed6c71a8b66d37c23ebe356d414 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:06 +0900 Subject: [PATCH 14/31] feat ( #53 ) : AwsS3Config --- .../application/global/config/AwsS3Config.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt new file mode 100644 index 00000000..53e8aca4 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt @@ -0,0 +1,29 @@ +package hs.kr.entrydsm.application.global.config + +import com.amazonaws.auth.AWSStaticCredentialsProvider +import com.amazonaws.auth.BasicAWSCredentials +import com.amazonaws.services.s3.AmazonS3Client +import com.amazonaws.services.s3.AmazonS3ClientBuilder +import hs.kr.entrydsm.application.global.storage.AwsCredentialsProperties +import hs.kr.entrydsm.application.global.storage.AwsProperties +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +@EnableConfigurationProperties(AwsProperties::class, AwsCredentialsProperties::class) +class AwsS3Config( + private val awsProperties: AwsProperties, + private val awsCredentialsProperties: AwsCredentialsProperties +) { + + @Bean + fun amazonS3Client(): AmazonS3Client { + val credentials = BasicAWSCredentials(awsCredentialsProperties.accessKey, awsCredentialsProperties.secretKey) + + return AmazonS3ClientBuilder.standard() + .withRegion(awsProperties.region) + .withCredentials(AWSStaticCredentialsProvider(credentials)) + .build() as AmazonS3Client + } +} From 242ed5edd88fcc33c0a104aa73a1057b183e2848 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:13 +0900 Subject: [PATCH 15/31] feat ( #53 ) : AwsProperties --- .../entrydsm/application/global/storage/AwsProperties.kt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt new file mode 100644 index 00000000..5631d5e1 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt @@ -0,0 +1,9 @@ +package hs.kr.entrydsm.application.global.storage + +import org.springframework.boot.context.properties.ConfigurationProperties + +@ConfigurationProperties("cloud.aws.s3") +class AwsProperties( + val bucket: String, + val region: String, +) \ No newline at end of file From 53d8b9936ea14e8264f680a237149f3171531b48 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:20 +0900 Subject: [PATCH 16/31] feat ( #53 ) : AwsCredentialsProperties --- .../global/storage/AwsCredentialsProperties.kt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsCredentialsProperties.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsCredentialsProperties.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsCredentialsProperties.kt new file mode 100644 index 00000000..f9d1b46b --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsCredentialsProperties.kt @@ -0,0 +1,9 @@ +package hs.kr.entrydsm.application.global.storage + +import org.springframework.boot.context.properties.ConfigurationProperties + +@ConfigurationProperties("cloud.aws.credentials") +class AwsCredentialsProperties( + val accessKey: String, + val secretKey: String, +) \ No newline at end of file From e42db3ce9a2c94e689eab464863a0ae0f2b53e2e Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:33 +0900 Subject: [PATCH 17/31] =?UTF-8?q?refactor=20(=20#53=20)=20:=20ApplicationD?= =?UTF-8?q?etailResponse=20photo=20path=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/ApplicationDetailResponse.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/ApplicationDetailResponse.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/ApplicationDetailResponse.kt index fb1a995e..b0bebfe5 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/ApplicationDetailResponse.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/ApplicationDetailResponse.kt @@ -22,5 +22,6 @@ data class ApplicationDetailResponse( val reviewedAt: LocalDateTime?, val createdAt: LocalDateTime, val updatedAt: LocalDateTime, + val photoPath: String?, ) } From ddb5e8c7237f673a889c5e318b7dcd5225f30c16 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:40 +0900 Subject: [PATCH 18/31] refactor ( #53 ) : ApplicationJpaEntity --- .../domain/application/domain/entity/ApplicationJpaEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/ApplicationJpaEntity.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/ApplicationJpaEntity.kt index 0ce45b13..35f31b89 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/ApplicationJpaEntity.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/entity/ApplicationJpaEntity.kt @@ -52,7 +52,7 @@ class ApplicationJpaEntity( @get:JvmName("getIsOutOfHeadcount") var isOutOfHeadcount: Boolean?, @Column(columnDefinition = "TEXT") - val photoPath: String?, + var photoPath: String?, val parentRelation: String?, val postalCode: String?, val detailAddress: String?, From 923f64c5d4bd941501150fcbde5ed95b6157443e Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:47 +0900 Subject: [PATCH 19/31] refactor ( #53 ) : ApplicationQueryUseCase --- .../application/usecase/ApplicationQueryUseCase.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/ApplicationQueryUseCase.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/ApplicationQueryUseCase.kt index 46c48010..dc007b41 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/ApplicationQueryUseCase.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/ApplicationQueryUseCase.kt @@ -5,11 +5,15 @@ import hs.kr.entrydsm.application.domain.application.domain.repository.Applicati import hs.kr.entrydsm.application.domain.application.domain.repository.ApplicationScoreJpaRepository import hs.kr.entrydsm.application.domain.application.domain.repository.CalculationResultJpaRepository import hs.kr.entrydsm.application.domain.application.domain.repository.CalculationStepJpaRepository +import hs.kr.entrydsm.application.domain.application.domain.repository.PhotoJpaRepository import hs.kr.entrydsm.application.domain.application.presentation.dto.response.ApplicationDetailResponse import hs.kr.entrydsm.application.domain.application.presentation.dto.response.ApplicationListResponse import hs.kr.entrydsm.application.domain.application.presentation.dto.response.ApplicationScoresResponse import hs.kr.entrydsm.application.domain.application.presentation.dto.response.CalculationHistoryResponse import hs.kr.entrydsm.application.domain.application.presentation.dto.response.CalculationResponse +import hs.kr.entrydsm.application.global.security.SecurityAdapter +import hs.kr.entrydsm.domain.file.`object`.PathList +import hs.kr.entrydsm.domain.file.spi.GenerateFileUrlPort import org.springframework.data.domain.PageRequest import org.springframework.data.domain.Pageable import org.springframework.data.domain.Sort @@ -25,6 +29,9 @@ class ApplicationQueryUseCase( private val calculationResultRepository: CalculationResultJpaRepository, private val calculationStepRepository: CalculationStepJpaRepository, private val objectMapper: ObjectMapper, + private val photoJpaRepository: PhotoJpaRepository, + private val securityAdapter: SecurityAdapter, + private val generateFileUrlPort: GenerateFileUrlPort ) { fun getApplicationById(applicationId: String): ApplicationDetailResponse { val uuid = UUID.fromString(applicationId) @@ -32,6 +39,9 @@ class ApplicationQueryUseCase( applicationRepository.findById(uuid) .orElseThrow { IllegalArgumentException("원서를 찾을 수 없습니다: $applicationId") } + val user = securityAdapter.getCurrentUserId() + val photoPath = photoJpaRepository.findByUserId(user)?.photo + return ApplicationDetailResponse( success = true, data = @@ -51,6 +61,7 @@ class ApplicationQueryUseCase( reviewedAt = application.reviewedAt, createdAt = application.createdAt, updatedAt = application.updatedAt, + photoPath = generateFileUrlPort.generateFileUrl(photoPath!!, PathList.PHOTO) ), ) } From 1087db00c632f0b8ad29a4ef4c8c0608209d31e0 Mon Sep 17 00:00:00 2001 From: coehgns Date: Fri, 26 Sep 2025 22:38:57 +0900 Subject: [PATCH 20/31] =?UTF-8?q?build=20(=20#53=20)=20:=20aws=20s3=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- casper-application-infrastructure/build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/casper-application-infrastructure/build.gradle.kts b/casper-application-infrastructure/build.gradle.kts index 72f8ae4c..2eb3c1d9 100644 --- a/casper-application-infrastructure/build.gradle.kts +++ b/casper-application-infrastructure/build.gradle.kts @@ -134,6 +134,9 @@ dependencies { // swagger implementation(Dependencies.SWAGGER) + + // aws s3 + implementation("com.amazonaws:aws-java-sdk-s3:1.12.767") } allOpen { From dd442405f9991f8279cc70dc7f819e66251d110f Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 00:17:33 +0900 Subject: [PATCH 21/31] =?UTF-8?q?refactor=20(=20#53=20)=20:=20FileControll?= =?UTF-8?q?er=20=ED=8C=8C=EC=9D=BC=20=EA=B5=AC=EC=A1=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/{application => file}/presentation/FileController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/{application => file}/presentation/FileController.kt (93%) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt similarity index 93% rename from casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt rename to casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt index 709165b5..e27b543a 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/FileController.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt @@ -1,4 +1,4 @@ -package hs.kr.entrydsm.application.domain.application.presentation +package hs.kr.entrydsm.application.domain.file.presentation import hs.kr.entrydsm.application.domain.application.usecase.FileUploadUseCase import hs.kr.entrydsm.application.domain.file.presentation.converter.ImageFileConverter From e44014fbaed3392ed83fc27bae523e25d7e90984 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 00:22:49 +0900 Subject: [PATCH 22/31] feat ( #53 ) : AwsRegionProperties --- .../application/global/storage/AwsRegionProperties.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsRegionProperties.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsRegionProperties.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsRegionProperties.kt new file mode 100644 index 00000000..dd2de030 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsRegionProperties.kt @@ -0,0 +1,8 @@ +package hs.kr.entrydsm.application.global.storage + +import org.springframework.boot.context.properties.ConfigurationProperties + +@ConfigurationProperties("cloud.aws.region") +class AwsRegionProperties( + val static: String +) \ No newline at end of file From 4ef512885faba4b2dcccebbee0e19987c827aa88 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 00:22:58 +0900 Subject: [PATCH 23/31] refactor ( #53 ) : AwsProperties --- .../hs/kr/entrydsm/application/global/storage/AwsProperties.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt index 5631d5e1..f43eef28 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsProperties.kt @@ -4,6 +4,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties("cloud.aws.s3") class AwsProperties( - val bucket: String, - val region: String, + val bucket: String ) \ No newline at end of file From 3811e3ab7fcf2a9f4ba6479f3823927dd024702f Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 00:23:04 +0900 Subject: [PATCH 24/31] refactor ( #53 ) : AwsS3Config --- .../kr/entrydsm/application/global/config/AwsS3Config.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt index 53e8aca4..0dee148a 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/AwsS3Config.kt @@ -6,6 +6,7 @@ import com.amazonaws.services.s3.AmazonS3Client import com.amazonaws.services.s3.AmazonS3ClientBuilder import hs.kr.entrydsm.application.global.storage.AwsCredentialsProperties import hs.kr.entrydsm.application.global.storage.AwsProperties +import hs.kr.entrydsm.application.global.storage.AwsRegionProperties import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -13,8 +14,8 @@ import org.springframework.context.annotation.Configuration @Configuration @EnableConfigurationProperties(AwsProperties::class, AwsCredentialsProperties::class) class AwsS3Config( - private val awsProperties: AwsProperties, - private val awsCredentialsProperties: AwsCredentialsProperties + private val awsCredentialsProperties: AwsCredentialsProperties, + private val awsRegionProperties: AwsRegionProperties ) { @Bean @@ -22,7 +23,7 @@ class AwsS3Config( val credentials = BasicAWSCredentials(awsCredentialsProperties.accessKey, awsCredentialsProperties.secretKey) return AmazonS3ClientBuilder.standard() - .withRegion(awsProperties.region) + .withRegion(awsRegionProperties.static) .withCredentials(AWSStaticCredentialsProvider(credentials)) .build() as AmazonS3Client } From 1003f7095eb4c6f29c145cb9779105be8ad6d0c2 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 00:24:18 +0900 Subject: [PATCH 25/31] refactor ( #53 ) : PhotoJpaRepository --- .../domain/application/domain/repository/PhotoJpaRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt index 7de4001e..6ce92d04 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/domain/repository/PhotoJpaRepository.kt @@ -4,7 +4,7 @@ import hs.kr.entrydsm.application.domain.application.domain.entity.PhotoJpaEntit import org.springframework.data.jpa.repository.JpaRepository import java.util.UUID -interface PhotoJpaRepository : JpaRepository { +interface PhotoJpaRepository : JpaRepository { fun findByUserId(userId: UUID): PhotoJpaEntity? } \ No newline at end of file From db82271a4cfd7c8dfb72446a95379b73732c7324 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 02:23:43 +0900 Subject: [PATCH 26/31] refactor ( #53 ) : FileUploadUseCase --- .../domain/application/usecase/FileUploadUseCase.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt index 08c9e5c3..c334f48f 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/FileUploadUseCase.kt @@ -18,18 +18,18 @@ class FileUploadUseCase( @Transactional fun execute(file: File): String { val userId = securityAdapter.getCurrentUserId() - val photoUrl = uploadFilePort.upload(file, PathList.PHOTO) + val photo = uploadFilePort.upload(file, PathList.PHOTO) photoJpaRepository.findByUserId(userId)?.apply { - photo = photoUrl + this.photo = photo photoJpaRepository.save(this) } ?: photoJpaRepository.save( PhotoJpaEntity( userId = userId, - photo = photoUrl + photo = photo ) ) - return photoUrl + return photo } } \ No newline at end of file From 84b479d908dc7a82670d0efc0fa6a97f3516997b Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 02:23:57 +0900 Subject: [PATCH 27/31] refactor ( #53 ) : AwsS3Adapter --- .../entrydsm/application/global/storage/AwsS3Adapter.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt index 39f992b1..6645de81 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/storage/AwsS3Adapter.kt @@ -7,6 +7,7 @@ import com.amazonaws.services.s3.model.CannedAccessControlList import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest import com.amazonaws.services.s3.model.ObjectMetadata import com.amazonaws.services.s3.model.PutObjectRequest +import hs.kr.entrydsm.application.domain.file.presentation.exception.FileExceptions import hs.kr.entrydsm.domain.file.spi.GenerateFileUrlPort import hs.kr.entrydsm.domain.file.spi.UploadFilePort import org.springframework.stereotype.Component @@ -28,7 +29,7 @@ class AwsS3Adapter( runCatching { inputS3(file, path) } .also { file.delete() } - return getS3Url(path) + return getS3Url(file.name) } private fun inputS3(file: File, path: String) { @@ -48,12 +49,12 @@ class AwsS3Adapter( ).withCannedAcl(CannedAccessControlList.PublicRead) ) } catch (e: IOException) { - throw IllegalArgumentException("File Exception") + throw FileExceptions.IOInterrupted() } } - private fun getS3Url(path: String): String { - return amazonS3Client.getUrl(awsProperties.bucket, path).toString() + private fun getS3Url(fileName: String): String { + return amazonS3Client.getUrl(awsProperties.bucket, fileName).toString() } override fun generateFileUrl(fileName: String, path: String): String { From 15d4e6db8cc2732ff3e3fc758f49d44315fe2e5d Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 02:24:06 +0900 Subject: [PATCH 28/31] refactor ( #53 ) : FileController --- .../application/domain/file/presentation/FileController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt index e27b543a..b561b027 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/FileController.kt @@ -19,6 +19,6 @@ class FileController( val photoUrl = fileUploadUseCase.execute( file.let(ImageFileConverter::transferTo) ) - return ResponseEntity.ok(mapOf("photo_url" to photoUrl)) + return ResponseEntity.ok(mapOf("fileName" to photoUrl)) } } \ No newline at end of file From f1823b99e3e30006d7ccd5e8251c31b3da8424fd Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 02:24:38 +0900 Subject: [PATCH 29/31] refactor ( #53 ) : BusinessException --- .../hs/kr/entrydsm/global/exception/BusinessException.kt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/BusinessException.kt diff --git a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/BusinessException.kt b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/BusinessException.kt new file mode 100644 index 00000000..355afaeb --- /dev/null +++ b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/global/exception/BusinessException.kt @@ -0,0 +1,6 @@ +package hs.kr.entrydsm.global.exception + +abstract class BusinessException( + open val status: Int, + override val message: String, +) : RuntimeException() \ No newline at end of file From f25fdabebb5214c7c54006707031e4ab8c48e03c Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 02:24:45 +0900 Subject: [PATCH 30/31] refactor ( #53 ) : FileExceptions --- .../presentation/exception/FileExceptions.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/FileExceptions.kt diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/FileExceptions.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/FileExceptions.kt new file mode 100644 index 00000000..78f9b397 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/file/presentation/exception/FileExceptions.kt @@ -0,0 +1,23 @@ +package hs.kr.entrydsm.application.domain.file.presentation.exception + +import hs.kr.entrydsm.global.exception.BusinessException + +sealed class FileExceptions( + override val status: Int, + override val message: String, +) : BusinessException(status, message) { + // 400 + class NotValidContent(message: String = NOT_VALID_CONTENT) : FileExceptions(400, message) + + // 404 + class PathNotFound(message: String = PATH_NOT_FOUND) : FileExceptions(404, message) + + // 500 + class IOInterrupted(message: String = IO_INTERRUPTED) : FileExceptions(500, message) + + companion object { + private const val NOT_VALID_CONTENT = "파일의 내용이 올바르지 않습니다." + private const val PATH_NOT_FOUND = "경로를 찾을 수 없습니다." + private const val IO_INTERRUPTED = "파일 입출력 처리가 중단되었습니다." + } +} \ No newline at end of file From ce24d72e784fc0b70ba4c777e3fe9c18088972f3 Mon Sep 17 00:00:00 2001 From: coehgns Date: Sat, 27 Sep 2025 02:25:26 +0900 Subject: [PATCH 31/31] refactor ( #53 ) : SecurityConfig --- .../hs/kr/entrydsm/application/global/config/SecurityConfig.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt index e5142001..31bc890a 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt @@ -44,9 +44,10 @@ class SecurityConfig( .requestMatchers("/webjars/**").permitAll() .requestMatchers("/admin/**").hasRole(UserRole.ADMIN.name) .requestMatchers("/api/v1/applications/**").hasRole(UserRole.USER.name) + .requestMatchers("/photo").hasRole(UserRole.USER.name) .anyRequest().authenticated() } - .apply(filterConfig) + .with(filterConfig) { } return http.build() }