Compare commits
5 Commits
2ddbfbccd6
...
9c271fc1f6
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c271fc1f6 | |||
| d90a872e79 | |||
| 328be036f7 | |||
| 3e41e763e3 | |||
| be6f7971c6 |
@@ -2,13 +2,15 @@ package kr.co.vividnext.sodalive.admin.content
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PutMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.RequestPart
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
|
||||
@RestController
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@@ -38,10 +40,11 @@ class AdminContentController(private val service: AdminContentService) {
|
||||
)
|
||||
)
|
||||
|
||||
@PutMapping
|
||||
@PutMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
|
||||
fun modifyAudioContent(
|
||||
@RequestBody request: UpdateAdminContentRequest
|
||||
) = ApiResponse.ok(service.updateAudioContent(request))
|
||||
@RequestPart("request") requestString: String,
|
||||
@RequestPart("coverImage", required = false) coverImage: MultipartFile? = null
|
||||
) = ApiResponse.ok(service.updateAudioContent(coverImage, requestString))
|
||||
|
||||
@GetMapping("/main/tab")
|
||||
fun getContentMainTabList() = ApiResponse.ok(service.getContentMainTabList())
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
package kr.co.vividnext.sodalive.admin.content
|
||||
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import kr.co.vividnext.sodalive.admin.content.curation.AdminContentCurationRepository
|
||||
import kr.co.vividnext.sodalive.admin.content.tab.AdminContentMainTabRepository
|
||||
import kr.co.vividnext.sodalive.admin.content.theme.AdminContentThemeRepository
|
||||
import kr.co.vividnext.sodalive.aws.cloudfront.AudioContentCloudFront
|
||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.content.main.tab.GetContentMainTabItem
|
||||
import kr.co.vividnext.sodalive.utils.generateFileName
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
|
||||
@Service
|
||||
class AdminContentService(
|
||||
@@ -17,7 +23,11 @@ class AdminContentService(
|
||||
private val themeRepository: AdminContentThemeRepository,
|
||||
private val audioContentCloudFront: AudioContentCloudFront,
|
||||
private val curationRepository: AdminContentCurationRepository,
|
||||
private val contentMainTabRepository: AdminContentMainTabRepository
|
||||
private val contentMainTabRepository: AdminContentMainTabRepository,
|
||||
private val objectMapper: ObjectMapper,
|
||||
private val s3Uploader: S3Uploader,
|
||||
@Value("\${cloud.aws.s3.bucket}")
|
||||
private val bucket: String
|
||||
) {
|
||||
fun getAudioContentList(status: ContentReleaseStatus, pageable: Pageable): GetAdminContentListResponse {
|
||||
val totalCount = repository.getAudioContentTotalCount(status = status)
|
||||
@@ -82,12 +92,25 @@ class AdminContentService(
|
||||
}
|
||||
|
||||
@Transactional
|
||||
fun updateAudioContent(request: UpdateAdminContentRequest) {
|
||||
fun updateAudioContent(coverImage: MultipartFile?, requestString: String) {
|
||||
val request = objectMapper.readValue(requestString, UpdateAdminContentRequest::class.java)
|
||||
val audioContent = repository.findByIdOrNull(id = request.id)
|
||||
?: throw SodaException(messageKey = "admin.content.not_found")
|
||||
|
||||
if (request.isDefaultCoverImage) {
|
||||
audioContent.coverImage = "`profile/default_profile.png`"
|
||||
if (coverImage != null) {
|
||||
val metadata = ObjectMetadata()
|
||||
metadata.contentLength = coverImage.size
|
||||
|
||||
val fileName = generateFileName(prefix = "${request.id}-cover")
|
||||
val imagePath = s3Uploader.upload(
|
||||
inputStream = coverImage.inputStream,
|
||||
bucket = bucket,
|
||||
filePath = "audio_content_cover/${request.id}/$fileName",
|
||||
metadata = metadata
|
||||
)
|
||||
audioContent.coverImage = imagePath
|
||||
} else if (request.isDefaultCoverImage) {
|
||||
audioContent.coverImage = "profile/default_profile.png"
|
||||
}
|
||||
|
||||
if (request.isActive != null) {
|
||||
|
||||
@@ -89,11 +89,13 @@ class LiveRoomQueryRepositoryImpl(
|
||||
.and(liveRoom.isActive.isTrue)
|
||||
.and(liveRoom.member.isNotNull)
|
||||
|
||||
if (!isAdult) {
|
||||
val isAdultRestricted = !isAdult || memberId == 17L || memberId == 16L
|
||||
if (isAdultRestricted) {
|
||||
where = where.and(liveRoom.isAdult.isFalse)
|
||||
}
|
||||
|
||||
if (isCreator && memberId != null) {
|
||||
val hasMemberId = memberId != null
|
||||
if (isCreator && hasMemberId) {
|
||||
where = where.and(
|
||||
liveRoom.isAvailableJoinCreator.isTrue
|
||||
.or(liveRoom.member.id.eq(memberId))
|
||||
@@ -106,7 +108,7 @@ class LiveRoomQueryRepositoryImpl(
|
||||
Gender.FEMALE -> liveRoom.genderRestriction.`in`(GenderRestriction.ALL, GenderRestriction.FEMALE_ONLY)
|
||||
Gender.NONE -> liveRoom.genderRestriction.isNotNull
|
||||
}
|
||||
where = if (memberId != null) {
|
||||
where = if (hasMemberId) {
|
||||
where.and(genderCondition.or(liveRoom.member.id.eq(memberId)))
|
||||
} else {
|
||||
where.and(genderCondition)
|
||||
@@ -118,7 +120,7 @@ class LiveRoomQueryRepositoryImpl(
|
||||
.innerJoin(liveRoom.member, member)
|
||||
.leftJoin(quarterLiveRankings).on(liveRoom.id.eq(quarterLiveRankings.roomId))
|
||||
|
||||
if (memberId != null) {
|
||||
if (hasMemberId) {
|
||||
val blockMemberCondition = blockMember.member.id.eq(member.id)
|
||||
.and(blockMember.blockedMember.id.eq(memberId))
|
||||
.and(blockMember.isActive.isTrue)
|
||||
@@ -158,7 +160,8 @@ class LiveRoomQueryRepositoryImpl(
|
||||
.and(liveRoom.isActive.isTrue)
|
||||
.and(liveRoom.member.isNotNull)
|
||||
|
||||
if (!isAdult) {
|
||||
val isAdultRestricted = !isAdult || memberId == 17L || memberId == 16L
|
||||
if (isAdultRestricted) {
|
||||
where = where.and(liveRoom.isAdult.isFalse)
|
||||
}
|
||||
|
||||
@@ -223,7 +226,8 @@ class LiveRoomQueryRepositoryImpl(
|
||||
.and(liveRoom.isActive.isTrue)
|
||||
.and(liveRoom.member.isNotNull)
|
||||
|
||||
if (!isAdult) {
|
||||
val isAdultRestricted = !isAdult || memberId == 17L || memberId == 16L
|
||||
if (isAdultRestricted) {
|
||||
where = where.and(liveRoom.isAdult.isFalse)
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ class LiveRoomService(
|
||||
timezone,
|
||||
memberId = member?.id,
|
||||
isCreator = member?.role == MemberRole.CREATOR,
|
||||
isAdult = member?.auth != null && isAdultContentVisible,
|
||||
isAdult = true,
|
||||
effectiveGender = effectiveGender
|
||||
)
|
||||
} else if (dateString != null) {
|
||||
|
||||
Reference in New Issue
Block a user