diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt index 68143c7..7143dc2 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunity.kt @@ -17,6 +17,8 @@ data class CreatorCommunity( var isCommentAvailable: Boolean, var isAdult: Boolean, @Column(nullable = true) + var audioPath: String? = null, + @Column(nullable = true) var imagePath: String? = null, var isActive: Boolean = true ) : BaseEntity() { diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt index 0307940..7c72840 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityController.kt @@ -27,6 +27,9 @@ class CreatorCommunityController(private val service: CreatorCommunityService) { @PostMapping @PreAuthorize("hasRole('CREATOR')") fun createCommunityPost( + @Nullable + @RequestPart("contentFile") + audioFile: MultipartFile?, @Nullable @RequestPart("postImage") postImage: MultipartFile?, @@ -37,6 +40,7 @@ class CreatorCommunityController(private val service: CreatorCommunityService) { ApiResponse.ok( service.createCommunityPost( + audioFile = audioFile, postImage = postImage, requestString = requestString, member = member diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt index cf429c1..da14f5a 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/profile/creatorCommunity/CreatorCommunityService.kt @@ -50,13 +50,22 @@ class CreatorCommunityService( private val imageHost: String ) { @Transactional - fun createCommunityPost(postImage: MultipartFile?, requestString: String, member: Member) { + fun createCommunityPost( + audioFile: MultipartFile?, + postImage: MultipartFile?, + requestString: String, + member: Member + ) { val request = objectMapper.readValue(requestString, CreateCommunityPostRequest::class.java) if (request.price > 0 && postImage == null) { throw SodaException("유료 게시글 등록을 위해서는 이미지가 필요합니다.") } + if (audioFile != null && postImage == null) { + throw SodaException("오디오 등록을 위해서는 이미지가 필요합니다.") + } + val post = CreatorCommunity( content = request.content, price = request.price, @@ -84,6 +93,20 @@ class CreatorCommunityService( post.imagePath = imagePath } + if (audioFile != null) { + val metadata = ObjectMetadata() + metadata.contentLength = audioFile.size + + val audioPath = s3Uploader.upload( + inputStream = audioFile.inputStream, + bucket = imageBucket, + filePath = "creator_community/${post.id}/${generateFileName(prefix = "${post.id}-audio")}.m4a", + metadata = metadata + ) + + post.audioPath = audioPath + } + applicationEventPublisher.publishEvent( FcmEvent( type = FcmEventType.CHANGE_NOTICE,