Compare commits
No commits in common. "443818efb5d3845fbd4d4cbea394d5c63b391e03" and "3ea6b5824bea1c8c853cc8fba89bf3a8bb33902f" have entirely different histories.
443818efb5
...
3ea6b5824b
|
@ -196,26 +196,4 @@ class AudioContentController(private val service: AudioContentService) {
|
||||||
fun releaseContent() = run {
|
fun releaseContent() = run {
|
||||||
ApiResponse.ok(service.releaseContent())
|
ApiResponse.ok(service.releaseContent())
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/pin-to-the-top/{id}")
|
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
|
||||||
fun pinToTheTop(
|
|
||||||
@PathVariable id: Long,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(service.pinToTheTop(contentId = id, member = member))
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/unpin-at-the-top/{id}")
|
|
||||||
@PreAuthorize("hasRole('CREATOR')")
|
|
||||||
fun unpinAtTheTop(
|
|
||||||
@PathVariable id: Long,
|
|
||||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
|
||||||
) = run {
|
|
||||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
|
||||||
|
|
||||||
ApiResponse.ok(service.unpinAtTheTop(contentId = id, member = member))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@ import kr.co.vividnext.sodalive.content.like.PutAudioContentLikeResponse
|
||||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentRanking
|
import kr.co.vividnext.sodalive.content.main.GetAudioContentRanking
|
||||||
import kr.co.vividnext.sodalive.content.order.OrderRepository
|
import kr.co.vividnext.sodalive.content.order.OrderRepository
|
||||||
import kr.co.vividnext.sodalive.content.order.OrderType
|
import kr.co.vividnext.sodalive.content.order.OrderType
|
||||||
import kr.co.vividnext.sodalive.content.pin.PinContent
|
|
||||||
import kr.co.vividnext.sodalive.content.pin.PinContentRepository
|
|
||||||
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeQueryRepository
|
import kr.co.vividnext.sodalive.content.theme.AudioContentThemeQueryRepository
|
||||||
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
|
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
|
||||||
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
|
||||||
|
@ -51,7 +49,6 @@ class AudioContentService(
|
||||||
private val playbackTrackingRepository: PlaybackTrackingRepository,
|
private val playbackTrackingRepository: PlaybackTrackingRepository,
|
||||||
private val commentRepository: AudioContentCommentRepository,
|
private val commentRepository: AudioContentCommentRepository,
|
||||||
private val audioContentLikeRepository: AudioContentLikeRepository,
|
private val audioContentLikeRepository: AudioContentLikeRepository,
|
||||||
private val pinContentRepository: PinContentRepository,
|
|
||||||
|
|
||||||
private val s3Uploader: S3Uploader,
|
private val s3Uploader: S3Uploader,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
|
@ -554,25 +551,6 @@ class AudioContentService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val pinContent = pinContentRepository.findByContentIdAndMemberId(
|
|
||||||
contentId = id,
|
|
||||||
memberId = member.id!!,
|
|
||||||
active = true
|
|
||||||
)
|
|
||||||
|
|
||||||
val isPin = if (member.id!! == audioContent.member!!.id!!) {
|
|
||||||
pinContent != null
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
val pinContentListCount = pinContentRepository.getPinContentList(memberId = member.id!!).size
|
|
||||||
val isAvailablePin = if (member.id!! == audioContent.member!!.id!!) {
|
|
||||||
pinContentListCount < 3
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetAudioContentDetailResponse(
|
return GetAudioContentDetailResponse(
|
||||||
contentId = audioContent.id!!,
|
contentId = audioContent.id!!,
|
||||||
title = audioContent.title,
|
title = audioContent.title,
|
||||||
|
@ -598,8 +576,6 @@ class AudioContentService(
|
||||||
likeCount = likeCount,
|
likeCount = likeCount,
|
||||||
commentList = commentList,
|
commentList = commentList,
|
||||||
commentCount = commentCount,
|
commentCount = commentCount,
|
||||||
isPin = isPin,
|
|
||||||
isAvailablePin = isAvailablePin,
|
|
||||||
creator = AudioContentCreator(
|
creator = AudioContentCreator(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
nickname = creator.nickname,
|
nickname = creator.nickname,
|
||||||
|
@ -720,31 +696,4 @@ class AudioContentService(
|
||||||
fun getContentRankingSortTypeList(): List<String> {
|
fun getContentRankingSortTypeList(): List<String> {
|
||||||
return listOf("매출", "댓글", "좋아요")
|
return listOf("매출", "댓글", "좋아요")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun pinToTheTop(contentId: Long, member: Member) {
|
|
||||||
val audioContent = repository.findByIdAndCreatorId(contentId = contentId, creatorId = member.id!!)
|
|
||||||
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
|
||||||
|
|
||||||
val pinContentList = pinContentRepository.getPinContentList(memberId = member.id!!)
|
|
||||||
val pinContent = if (pinContentList.size >= 3) {
|
|
||||||
pinContentList[0]
|
|
||||||
} else {
|
|
||||||
PinContent()
|
|
||||||
}
|
|
||||||
|
|
||||||
pinContent.member = member
|
|
||||||
pinContent.content = audioContent
|
|
||||||
pinContentRepository.save(pinContent)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
fun unpinAtTheTop(contentId: Long, member: Member) {
|
|
||||||
val pinContent = pinContentRepository.findByContentIdAndMemberId(
|
|
||||||
contentId = contentId,
|
|
||||||
memberId = member.id!!
|
|
||||||
) ?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
|
|
||||||
|
|
||||||
pinContent.isActive = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ data class GetAudioContentDetailResponse(
|
||||||
val likeCount: Int,
|
val likeCount: Int,
|
||||||
val commentList: List<GetAudioContentCommentListItem>,
|
val commentList: List<GetAudioContentCommentListItem>,
|
||||||
val commentCount: Int,
|
val commentCount: Int,
|
||||||
val isPin: Boolean,
|
|
||||||
val isAvailablePin: Boolean,
|
|
||||||
val creator: AudioContentCreator
|
val creator: AudioContentCreator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.content.pin
|
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.common.BaseEntity
|
|
||||||
import kr.co.vividnext.sodalive.content.AudioContent
|
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
|
||||||
import javax.persistence.Entity
|
|
||||||
import javax.persistence.FetchType
|
|
||||||
import javax.persistence.JoinColumn
|
|
||||||
import javax.persistence.ManyToOne
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
data class PinContent(var isActive: Boolean = true) : BaseEntity() {
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "member_id", nullable = false)
|
|
||||||
var member: Member? = null
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "content_id", nullable = false)
|
|
||||||
var content: AudioContent? = null
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.content.pin
|
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
|
||||||
import kr.co.vividnext.sodalive.content.pin.QPinContent.pinContent
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
|
||||||
|
|
||||||
interface PinContentRepository : JpaRepository<PinContent, Long>, PinContentQueryRepository
|
|
||||||
|
|
||||||
interface PinContentQueryRepository {
|
|
||||||
fun getPinContentList(memberId: Long): List<PinContent>
|
|
||||||
|
|
||||||
fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean? = null): PinContent?
|
|
||||||
}
|
|
||||||
|
|
||||||
class PinContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) : PinContentQueryRepository {
|
|
||||||
override fun getPinContentList(memberId: Long): List<PinContent> {
|
|
||||||
return queryFactory
|
|
||||||
.selectFrom(pinContent)
|
|
||||||
.where(pinContent.member.id.eq(memberId))
|
|
||||||
.orderBy(pinContent.updatedAt.asc())
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun findByContentIdAndMemberId(contentId: Long, memberId: Long, active: Boolean?): PinContent? {
|
|
||||||
var where = pinContent.content.id.eq(contentId)
|
|
||||||
.and(pinContent.member.id.eq(memberId))
|
|
||||||
|
|
||||||
if (active != null) {
|
|
||||||
where = where
|
|
||||||
.and(pinContent.isActive.eq(active))
|
|
||||||
}
|
|
||||||
|
|
||||||
return queryFactory
|
|
||||||
.selectFrom(pinContent)
|
|
||||||
.where(where)
|
|
||||||
.fetchFirst()
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue