feat: 메인 홈
- API 추가
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package kr.co.vividnext.sodalive.content
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.querydsl.core.annotations.QueryProjection
|
||||
|
||||
data class AudioContentMainItem @QueryProjection constructor(
|
||||
@JsonProperty("contentId") val contentId: Long,
|
||||
@JsonProperty("creatorId") val creatorId: Long,
|
||||
@JsonProperty("title") val title: String,
|
||||
@JsonProperty("coverImageUrl") val coverImageUrl: String,
|
||||
@JsonProperty("creatorNickname") val creatorNickname: String,
|
||||
@JsonProperty("isPointAvailable") val isPointAvailable: Boolean
|
||||
)
|
@@ -176,6 +176,23 @@ interface AudioContentQueryRepository {
|
||||
fun findContentHashTagByContentIdAndIsActive(contentId: Long, isActive: Boolean): List<AudioContentHashTag>
|
||||
|
||||
fun findContentIdAndHashTagId(contentId: Long, hashTagId: Int): AudioContentHashTag?
|
||||
|
||||
fun getLatestContentByTheme(
|
||||
theme: List<String>,
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean
|
||||
): List<AudioContentMainItem>
|
||||
|
||||
fun findContentByCurationId(
|
||||
curationId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<GetAudioContentMainItem>
|
||||
}
|
||||
|
||||
@Repository
|
||||
@@ -1281,4 +1298,126 @@ class AudioContentQueryRepositoryImpl(
|
||||
.orderBy(audioContentHashTag.id.asc())
|
||||
.fetchFirst()
|
||||
}
|
||||
|
||||
override fun getLatestContentByTheme(
|
||||
theme: List<String>,
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long,
|
||||
isFree: Boolean,
|
||||
isAdult: Boolean
|
||||
): List<AudioContentMainItem> {
|
||||
var where = audioContent.isActive.isTrue
|
||||
.and(audioContent.duration.isNotNull)
|
||||
.and(
|
||||
audioContent.releaseDate.isNull
|
||||
.or(audioContent.releaseDate.loe(LocalDateTime.now()))
|
||||
)
|
||||
.and(blockMember.id.isNull)
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
} else {
|
||||
if (contentType != ContentType.ALL) {
|
||||
where = where.and(
|
||||
audioContent.member.isNull.or(
|
||||
audioContent.member.auth.gender.eq(
|
||||
if (contentType == ContentType.MALE) {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (theme.isNotEmpty()) {
|
||||
where = where.and(audioContentTheme.theme.`in`(theme))
|
||||
}
|
||||
|
||||
where = if (isFree) {
|
||||
where.and(audioContent.price.loe(0))
|
||||
} else {
|
||||
where.and(audioContent.price.gt(0))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QAudioContentMainItem(
|
||||
audioContent.id,
|
||||
member.id,
|
||||
audioContent.title,
|
||||
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||
member.nickname,
|
||||
audioContent.isPointAvailable
|
||||
)
|
||||
)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun findContentByCurationId(
|
||||
curationId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<GetAudioContentMainItem> {
|
||||
var where = audioContentCuration.isActive.isTrue
|
||||
.and(audioContentCurationItem.isActive.isTrue)
|
||||
.and(audioContent.isActive.isTrue)
|
||||
.and(audioContent.member.isNotNull)
|
||||
.and(audioContent.duration.isNotNull)
|
||||
.and(audioContent.member.isActive.isTrue)
|
||||
.and(audioContentCuration.id.eq(curationId))
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
} else {
|
||||
if (contentType != ContentType.ALL) {
|
||||
where = where.and(
|
||||
audioContent.member.isNull.or(
|
||||
audioContent.member.auth.gender.eq(
|
||||
if (contentType == ContentType.MALE) {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetAudioContentMainItem(
|
||||
audioContent.id,
|
||||
audioContent.coverImage.prepend("/").prepend(imageHost),
|
||||
audioContent.title,
|
||||
member.id,
|
||||
member.profileImage.prepend("/").prepend(imageHost),
|
||||
member.nickname,
|
||||
audioContent.price,
|
||||
audioContent.duration,
|
||||
audioContent.isPointAvailable
|
||||
)
|
||||
)
|
||||
.from(audioContentCurationItem)
|
||||
.innerJoin(audioContentCurationItem.content, audioContent)
|
||||
.innerJoin(audioContentCurationItem.curation, audioContentCuration)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.where(where)
|
||||
.orderBy(audioContentCurationItem.orders.asc())
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
}
|
||||
|
@@ -938,4 +938,22 @@ class AudioContentService(
|
||||
|
||||
return GenerateUrlResponse(contentUrl)
|
||||
}
|
||||
|
||||
fun getLatestContentByTheme(
|
||||
theme: List<String>,
|
||||
contentType: ContentType,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20,
|
||||
isFree: Boolean = false,
|
||||
isAdult: Boolean = false
|
||||
): List<AudioContentMainItem> {
|
||||
return repository.getLatestContentByTheme(
|
||||
theme = theme,
|
||||
contentType = contentType,
|
||||
offset = offset,
|
||||
limit = limit,
|
||||
isFree = isFree,
|
||||
isAdult = isAdult
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,21 @@
|
||||
package kr.co.vividnext.sodalive.content.main.curation
|
||||
|
||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
||||
import kr.co.vividnext.sodalive.content.ContentType
|
||||
import kr.co.vividnext.sodalive.content.SortType
|
||||
import kr.co.vividnext.sodalive.content.main.tab.GetContentCurationResponse
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.block.BlockMemberRepository
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.cache.annotation.Cacheable
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
class AudioContentCurationService(
|
||||
private val repository: AudioContentCurationQueryRepository,
|
||||
private val contentRepository: AudioContentRepository,
|
||||
private val blockMemberRepository: BlockMemberRepository,
|
||||
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
@@ -46,4 +51,36 @@ class AudioContentCurationService(
|
||||
items = audioContentList
|
||||
)
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable(
|
||||
cacheNames = ["cache_ttl_3_days"],
|
||||
key = "'getContentCurationList:' + ':' +" +
|
||||
"#isAdult + ':' + #tabId + ':' + #contentType + ':' + (#memberId ?: 'guest')"
|
||||
)
|
||||
fun getContentCurationList(
|
||||
tabId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
memberId: Long?
|
||||
): List<GetContentCurationResponse> {
|
||||
return repository.findByContentMainTabId(tabId = tabId, isAdult = isAdult)
|
||||
.map {
|
||||
GetContentCurationResponse(
|
||||
title = it.title,
|
||||
items = contentRepository.findContentByCurationId(
|
||||
curationId = it.id!!,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType
|
||||
).filter { item ->
|
||||
if (memberId != null) {
|
||||
!blockMemberRepository.isBlocked(blockedMemberId = memberId, memberId = item.creatorId)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
.filter { it.items.isNotEmpty() }
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,6 @@ class AudioContentMainTabSeriesController(private val service: AudioContentMainT
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getOriginalAudioDramaList(
|
||||
memberId = member.id!!,
|
||||
isAdult = member.auth != null && (isAdultContentVisible ?: true),
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
offset = pageable.offset,
|
||||
|
@@ -41,7 +41,6 @@ class AudioContentMainTabSeriesService(
|
||||
)
|
||||
|
||||
val originalAudioDrama = seriesService.getOriginalAudioDramaList(
|
||||
memberId = memberId,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
offset = 0,
|
||||
@@ -158,15 +157,13 @@ class AudioContentMainTabSeriesService(
|
||||
}
|
||||
|
||||
fun getOriginalAudioDramaList(
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): GetSeriesListResponse {
|
||||
val totalCount = seriesService.getOriginalAudioDramaTotalCount(memberId, isAdult, contentType)
|
||||
val totalCount = seriesService.getOriginalAudioDramaTotalCount(isAdult, contentType)
|
||||
val items = seriesService.getOriginalAudioDramaList(
|
||||
memberId = memberId,
|
||||
isAdult = isAdult,
|
||||
contentType = contentType,
|
||||
offset = offset,
|
||||
|
@@ -19,7 +19,6 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
@GetMapping
|
||||
fun getSeriesList(
|
||||
@RequestParam creatorId: Long,
|
||||
@RequestParam("sortType", required = false) sortType: SeriesSortType? = SeriesSortType.NEWEST,
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@@ -30,7 +29,6 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
ApiResponse.ok(
|
||||
service.getSeriesList(
|
||||
creatorId = creatorId,
|
||||
sortType = sortType ?: SeriesSortType.NEWEST,
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
member = member,
|
||||
|
@@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.content.series.content.QGetSeriesContentMinMaxPr
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeries.series
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeriesContent.seriesContent
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesPublishedDaysOfWeek
|
||||
import kr.co.vividnext.sodalive.creator.admin.content.series.keyword.QSeriesKeyword.seriesKeyword
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
@@ -37,16 +38,22 @@ interface ContentSeriesQueryRepository {
|
||||
fun getSeriesContentMinMaxPrice(seriesId: Long): GetSeriesContentMinMaxPriceResponse
|
||||
fun getRecommendSeriesList(isAuth: Boolean, contentType: ContentType, limit: Long): List<Series>
|
||||
fun getOriginalAudioDramaList(
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<Series>
|
||||
|
||||
fun getOriginalAudioDramaTotalCount(memberId: Long, isAdult: Boolean, contentType: ContentType): Int
|
||||
fun getOriginalAudioDramaTotalCount(isAdult: Boolean, contentType: ContentType): Int
|
||||
fun getGenreList(isAdult: Boolean, memberId: Long, contentType: ContentType): List<GetSeriesGenreListResponse>
|
||||
fun findByCurationId(curationId: Long, memberId: Long, isAdult: Boolean, contentType: ContentType): List<Series>
|
||||
fun getDayOfWeekSeriesList(
|
||||
dayOfWeek: SeriesPublishedDaysOfWeek,
|
||||
contentType: ContentType,
|
||||
isAdult: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series>
|
||||
}
|
||||
|
||||
class ContentSeriesQueryRepositoryImpl(
|
||||
@@ -207,19 +214,13 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
}
|
||||
|
||||
override fun getOriginalAudioDramaList(
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
val blockMemberCondition = blockMember.member.id.eq(member.id)
|
||||
.and(blockMember.isActive.isTrue)
|
||||
.and(blockMember.blockedMember.id.eq(memberId))
|
||||
|
||||
var where = series.isOriginal.isTrue
|
||||
.and(series.isActive.isTrue)
|
||||
.and(blockMember.id.isNull)
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(series.isAdult.isFalse)
|
||||
@@ -242,7 +243,6 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
return queryFactory
|
||||
.selectFrom(series)
|
||||
.innerJoin(series.member, member)
|
||||
.leftJoin(blockMember).on(blockMemberCondition)
|
||||
.where(where)
|
||||
.orderBy(series.id.desc())
|
||||
.offset(offset)
|
||||
@@ -250,14 +250,9 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun getOriginalAudioDramaTotalCount(memberId: Long, isAdult: Boolean, contentType: ContentType): Int {
|
||||
val blockMemberCondition = blockMember.member.id.eq(member.id)
|
||||
.and(blockMember.isActive.isTrue)
|
||||
.and(blockMember.blockedMember.id.eq(memberId))
|
||||
|
||||
override fun getOriginalAudioDramaTotalCount(isAdult: Boolean, contentType: ContentType): Int {
|
||||
var where = series.isOriginal.isTrue
|
||||
.and(series.isActive.isTrue)
|
||||
.and(blockMember.id.isNull)
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(series.isAdult.isFalse)
|
||||
@@ -281,7 +276,6 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
.select(series.id)
|
||||
.from(series)
|
||||
.innerJoin(series.member, member)
|
||||
.leftJoin(blockMember).on(blockMemberCondition)
|
||||
.where(where)
|
||||
.fetch()
|
||||
.size
|
||||
@@ -385,4 +379,44 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
.orderBy(audioContentCurationItem.orders.asc())
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun getDayOfWeekSeriesList(
|
||||
dayOfWeek: SeriesPublishedDaysOfWeek,
|
||||
contentType: ContentType,
|
||||
isAdult: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
var where = series.isActive.isTrue
|
||||
.and(series.publishedDaysOfWeek.contains(dayOfWeek))
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(series.isAdult.isFalse)
|
||||
} else {
|
||||
if (contentType != ContentType.ALL) {
|
||||
where = where.and(
|
||||
series.member.isNull.or(
|
||||
series.member.auth.gender.eq(
|
||||
if (contentType == ContentType.MALE) {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.selectFrom(series)
|
||||
.innerJoin(series.member, member)
|
||||
.innerJoin(series.contentList, seriesContent)
|
||||
.innerJoin(seriesContent.content, audioContent)
|
||||
.where(where)
|
||||
.orderBy(seriesContent.content.createdAt.desc())
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
}
|
||||
|
@@ -30,18 +30,17 @@ class ContentSeriesService(
|
||||
@Value("\${cloud.aws.cloud-front.host}")
|
||||
private val coverImageHost: String
|
||||
) {
|
||||
fun getOriginalAudioDramaTotalCount(memberId: Long, isAdult: Boolean, contentType: ContentType): Int {
|
||||
return repository.getOriginalAudioDramaTotalCount(memberId, isAdult, contentType)
|
||||
fun getOriginalAudioDramaTotalCount(isAdult: Boolean, contentType: ContentType): Int {
|
||||
return repository.getOriginalAudioDramaTotalCount(isAdult, contentType)
|
||||
}
|
||||
|
||||
fun getOriginalAudioDramaList(
|
||||
memberId: Long,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<GetSeriesListResponse.SeriesListItem> {
|
||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(memberId, isAdult, contentType, offset, limit)
|
||||
val originalAudioDramaList = repository.getOriginalAudioDramaList(isAdult, contentType, offset, limit)
|
||||
return seriesToSeriesListItem(originalAudioDramaList, isAdult, contentType)
|
||||
}
|
||||
|
||||
@@ -54,7 +53,6 @@ class ContentSeriesService(
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
sortType: SeriesSortType = SeriesSortType.NEWEST,
|
||||
offset: Long = 0,
|
||||
limit: Long = 10
|
||||
): GetSeriesListResponse {
|
||||
@@ -224,6 +222,36 @@ class ContentSeriesService(
|
||||
return seriesToSeriesListItem(seriesList, isAdult, contentType)
|
||||
}
|
||||
|
||||
fun getDayOfWeekSeriesList(
|
||||
memberId: Long?,
|
||||
isAdult: Boolean,
|
||||
contentType: ContentType,
|
||||
dayOfWeek: SeriesPublishedDaysOfWeek,
|
||||
offset: Long = 0,
|
||||
limit: Long = 10
|
||||
): List<GetSeriesListResponse.SeriesListItem> {
|
||||
var seriesList = repository.getDayOfWeekSeriesList(
|
||||
dayOfWeek = dayOfWeek,
|
||||
contentType = contentType,
|
||||
isAdult = isAdult,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
)
|
||||
|
||||
seriesList = if (memberId != null) {
|
||||
seriesList.filter {
|
||||
!blockMemberRepository.isBlocked(
|
||||
blockedMemberId = memberId,
|
||||
memberId = it.member!!.id!!
|
||||
)
|
||||
}
|
||||
} else {
|
||||
seriesList
|
||||
}
|
||||
|
||||
return seriesToSeriesListItem(seriesList, isAdult, contentType)
|
||||
}
|
||||
|
||||
private fun seriesToSeriesListItem(
|
||||
seriesList: List<Series>,
|
||||
isAdult: Boolean,
|
||||
|
@@ -19,6 +19,19 @@ class AudioContentThemeService(
|
||||
return queryRepository.getActiveThemes()
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getActiveThemeOfContent(
|
||||
isAdult: Boolean = false,
|
||||
isFree: Boolean = false,
|
||||
contentType: ContentType
|
||||
): List<String> {
|
||||
return queryRepository.getActiveThemeOfContent(
|
||||
isAdult = isAdult,
|
||||
isFree = isFree,
|
||||
contentType = contentType
|
||||
)
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
fun getContentByTheme(
|
||||
themeId: Long,
|
||||
|
Reference in New Issue
Block a user