| @@ -140,6 +140,7 @@ class AdminAudioContentQueryRepositoryImpl( | ||||
|                 audioContent.duration.isNotNull | ||||
|                     .and(audioContent.member.isNotNull) | ||||
|                     .and(audioContentHashTag.audioContent.id.eq(audioContentId)) | ||||
|                     .and(audioContentHashTag.isActive.isTrue) | ||||
|             ) | ||||
|             .fetch() | ||||
|     } | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import com.querydsl.core.types.dsl.StringTemplate | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.content.AudioContent | ||||
| import kr.co.vividnext.sodalive.content.QAudioContent.audioContent | ||||
| import kr.co.vividnext.sodalive.content.hashtag.AudioContentHashTag | ||||
| import kr.co.vividnext.sodalive.content.hashtag.QAudioContentHashTag.audioContentHashTag | ||||
| import kr.co.vividnext.sodalive.content.hashtag.QHashTag.hashTag | ||||
| import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme | ||||
| @@ -27,6 +28,10 @@ interface CreatorAdminAudioContentQueryRepository { | ||||
|     fun getHashTagList(audioContentId: Long): List<String> | ||||
|  | ||||
|     fun getAudioContent(memberId: Long, audioContentId: Long): AudioContent? | ||||
|  | ||||
|     fun findContentHashTagByContentIdAndIsActive(contentId: Long, isActive: Boolean): List<AudioContentHashTag> | ||||
|  | ||||
|     fun findContentIdAndHashTagId(contentId: Long, hashTagId: Int): AudioContentHashTag? | ||||
| } | ||||
|  | ||||
| class CreatorAdminAudioContentQueryRepositoryImpl( | ||||
| @@ -111,6 +116,7 @@ class CreatorAdminAudioContentQueryRepositoryImpl( | ||||
|                 audioContent.duration.isNotNull | ||||
|                     .and(audioContent.member.isNotNull) | ||||
|                     .and(audioContentHashTag.audioContent.id.eq(audioContentId)) | ||||
|                     .and(audioContentHashTag.isActive.isTrue) | ||||
|             ) | ||||
|             .fetch() | ||||
|     } | ||||
| @@ -127,6 +133,33 @@ class CreatorAdminAudioContentQueryRepositoryImpl( | ||||
|             .fetchFirst() | ||||
|     } | ||||
|  | ||||
|     override fun findContentHashTagByContentIdAndIsActive( | ||||
|         contentId: Long, | ||||
|         isActive: Boolean | ||||
|     ): List<AudioContentHashTag> { | ||||
|         return queryFactory | ||||
|             .selectFrom(audioContentHashTag) | ||||
|             .innerJoin(audioContentHashTag.audioContent, audioContent) | ||||
|             .where( | ||||
|                 audioContentHashTag.isActive.eq(isActive) | ||||
|                     .and(audioContent.id.eq(contentId)) | ||||
|             ) | ||||
|             .fetch() | ||||
|     } | ||||
|  | ||||
|     override fun findContentIdAndHashTagId(contentId: Long, hashTagId: Int): AudioContentHashTag? { | ||||
|         return queryFactory | ||||
|             .selectFrom(audioContentHashTag) | ||||
|             .innerJoin(audioContentHashTag.audioContent, audioContent) | ||||
|             .innerJoin(audioContentHashTag.hashTag, hashTag) | ||||
|             .where( | ||||
|                 audioContent.id.eq(contentId), | ||||
|                 hashTag.id.eq(hashTagId) | ||||
|             ) | ||||
|             .orderBy(audioContentHashTag.id.asc()) | ||||
|             .fetchFirst() | ||||
|     } | ||||
|  | ||||
|     private fun formattedDateExpression( | ||||
|         dateTime: DateTimePath<LocalDateTime>, | ||||
|         format: String = "%Y-%m-%d" | ||||
|   | ||||
| @@ -7,6 +7,9 @@ import kr.co.vividnext.sodalive.aws.s3.S3Uploader | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.content.ContentPriceChangeLog | ||||
| import kr.co.vividnext.sodalive.content.ContentPriceChangeLogRepository | ||||
| import kr.co.vividnext.sodalive.content.hashtag.AudioContentHashTag | ||||
| import kr.co.vividnext.sodalive.content.hashtag.HashTag | ||||
| import kr.co.vividnext.sodalive.content.hashtag.HashTagRepository | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import kr.co.vividnext.sodalive.utils.generateFileName | ||||
| import org.springframework.beans.factory.annotation.Value | ||||
| @@ -18,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile | ||||
| @Service | ||||
| class CreatorAdminContentService( | ||||
|     private val repository: CreatorAdminContentRepository, | ||||
|     private val hashTagRepository: HashTagRepository, | ||||
|     private val contentPriceChangeLogRepository: ContentPriceChangeLogRepository, | ||||
|     private val audioContentCloudFront: AudioContentCloudFront, | ||||
|     private val objectMapper: ObjectMapper, | ||||
| @@ -156,5 +160,40 @@ class CreatorAdminContentService( | ||||
|  | ||||
|             audioContent.price = request.price | ||||
|         } | ||||
|  | ||||
|         if (!request.tags.isNullOrBlank()) { | ||||
|             val normalizedTags = request.tags | ||||
|                 .replace("#", " #") | ||||
|                 .split(" ") | ||||
|                 .map { it.trim() } | ||||
|                 .filter { it.isNotBlank() } | ||||
|                 .map { if (it.startsWith("#")) it else "#$it" } | ||||
|                 .distinct() | ||||
|  | ||||
|             val currentContentTags = repository.findContentHashTagByContentIdAndIsActive(request.id, true) | ||||
|             val currentTagMap = currentContentTags.associateBy { it.hashTag!!.tag } | ||||
|  | ||||
|             val tagsToAdd = normalizedTags.subtract(currentTagMap.keys) | ||||
|             val tagsToDeactivate = currentTagMap.keys.subtract(normalizedTags.toSet()) | ||||
|  | ||||
|             tagsToDeactivate.forEach { | ||||
|                 currentTagMap[it]?.let { cht -> cht.isActive = false } | ||||
|             } | ||||
|  | ||||
|             val newAudioContentHashTagList = tagsToAdd.map { tag -> | ||||
|                 val hashTag = hashTagRepository.findByTag(tag) | ||||
|                     ?: hashTagRepository.save(HashTag(tag)) | ||||
|  | ||||
|                 val audioContentHashTag = repository.findContentIdAndHashTagId(request.id, hashTag.id!!) | ||||
|                     ?: AudioContentHashTag() | ||||
|                 audioContentHashTag.audioContent = audioContent | ||||
|                 audioContentHashTag.hashTag = hashTag | ||||
|                 audioContentHashTag.isActive = true | ||||
|  | ||||
|                 audioContentHashTag | ||||
|             } | ||||
|  | ||||
|             audioContent.audioContentHashTags.addAll(newAudioContentHashTagList) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -4,6 +4,7 @@ data class UpdateCreatorAdminContentRequest( | ||||
|     val id: Long, | ||||
|     val title: String?, | ||||
|     val detail: String?, | ||||
|     val tags: String?, | ||||
|     val price: Int?, | ||||
|     val isAdult: Boolean?, | ||||
|     val isActive: Boolean?, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user