| @@ -140,6 +140,7 @@ class AdminAudioContentQueryRepositoryImpl( | |||||||
|                 audioContent.duration.isNotNull |                 audioContent.duration.isNotNull | ||||||
|                     .and(audioContent.member.isNotNull) |                     .and(audioContent.member.isNotNull) | ||||||
|                     .and(audioContentHashTag.audioContent.id.eq(audioContentId)) |                     .and(audioContentHashTag.audioContent.id.eq(audioContentId)) | ||||||
|  |                     .and(audioContentHashTag.isActive.isTrue) | ||||||
|             ) |             ) | ||||||
|             .fetch() |             .fetch() | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import com.querydsl.core.types.dsl.StringTemplate | |||||||
| import com.querydsl.jpa.impl.JPAQueryFactory | import com.querydsl.jpa.impl.JPAQueryFactory | ||||||
| import kr.co.vividnext.sodalive.content.AudioContent | import kr.co.vividnext.sodalive.content.AudioContent | ||||||
| import kr.co.vividnext.sodalive.content.QAudioContent.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.QAudioContentHashTag.audioContentHashTag | ||||||
| import kr.co.vividnext.sodalive.content.hashtag.QHashTag.hashTag | import kr.co.vividnext.sodalive.content.hashtag.QHashTag.hashTag | ||||||
| import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme | import kr.co.vividnext.sodalive.content.theme.QAudioContentTheme.audioContentTheme | ||||||
| @@ -27,6 +28,10 @@ interface CreatorAdminAudioContentQueryRepository { | |||||||
|     fun getHashTagList(audioContentId: Long): List<String> |     fun getHashTagList(audioContentId: Long): List<String> | ||||||
|  |  | ||||||
|     fun getAudioContent(memberId: Long, audioContentId: Long): AudioContent? |     fun getAudioContent(memberId: Long, audioContentId: Long): AudioContent? | ||||||
|  |  | ||||||
|  |     fun findContentHashTagByContentIdAndIsActive(contentId: Long, isActive: Boolean): List<AudioContentHashTag> | ||||||
|  |  | ||||||
|  |     fun findContentIdAndHashTagId(contentId: Long, hashTagId: Int): AudioContentHashTag? | ||||||
| } | } | ||||||
|  |  | ||||||
| class CreatorAdminAudioContentQueryRepositoryImpl( | class CreatorAdminAudioContentQueryRepositoryImpl( | ||||||
| @@ -111,6 +116,7 @@ class CreatorAdminAudioContentQueryRepositoryImpl( | |||||||
|                 audioContent.duration.isNotNull |                 audioContent.duration.isNotNull | ||||||
|                     .and(audioContent.member.isNotNull) |                     .and(audioContent.member.isNotNull) | ||||||
|                     .and(audioContentHashTag.audioContent.id.eq(audioContentId)) |                     .and(audioContentHashTag.audioContent.id.eq(audioContentId)) | ||||||
|  |                     .and(audioContentHashTag.isActive.isTrue) | ||||||
|             ) |             ) | ||||||
|             .fetch() |             .fetch() | ||||||
|     } |     } | ||||||
| @@ -127,6 +133,33 @@ class CreatorAdminAudioContentQueryRepositoryImpl( | |||||||
|             .fetchFirst() |             .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( |     private fun formattedDateExpression( | ||||||
|         dateTime: DateTimePath<LocalDateTime>, |         dateTime: DateTimePath<LocalDateTime>, | ||||||
|         format: String = "%Y-%m-%d" |         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.common.SodaException | ||||||
| import kr.co.vividnext.sodalive.content.ContentPriceChangeLog | import kr.co.vividnext.sodalive.content.ContentPriceChangeLog | ||||||
| import kr.co.vividnext.sodalive.content.ContentPriceChangeLogRepository | 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.member.Member | ||||||
| import kr.co.vividnext.sodalive.utils.generateFileName | import kr.co.vividnext.sodalive.utils.generateFileName | ||||||
| import org.springframework.beans.factory.annotation.Value | import org.springframework.beans.factory.annotation.Value | ||||||
| @@ -18,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile | |||||||
| @Service | @Service | ||||||
| class CreatorAdminContentService( | class CreatorAdminContentService( | ||||||
|     private val repository: CreatorAdminContentRepository, |     private val repository: CreatorAdminContentRepository, | ||||||
|  |     private val hashTagRepository: HashTagRepository, | ||||||
|     private val contentPriceChangeLogRepository: ContentPriceChangeLogRepository, |     private val contentPriceChangeLogRepository: ContentPriceChangeLogRepository, | ||||||
|     private val audioContentCloudFront: AudioContentCloudFront, |     private val audioContentCloudFront: AudioContentCloudFront, | ||||||
|     private val objectMapper: ObjectMapper, |     private val objectMapper: ObjectMapper, | ||||||
| @@ -156,5 +160,40 @@ class CreatorAdminContentService( | |||||||
|  |  | ||||||
|             audioContent.price = request.price |             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 id: Long, | ||||||
|     val title: String?, |     val title: String?, | ||||||
|     val detail: String?, |     val detail: String?, | ||||||
|  |     val tags: String?, | ||||||
|     val price: Int?, |     val price: Int?, | ||||||
|     val isAdult: Boolean?, |     val isAdult: Boolean?, | ||||||
|     val isActive: Boolean?, |     val isActive: Boolean?, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user