새로운 콘텐츠 전체보기 API 추가
This commit is contained in:
parent
468add0819
commit
fd460f2d3e
|
@ -56,6 +56,16 @@ interface AudioContentQueryRepository {
|
|||
limit: Long = 20
|
||||
): List<GetAudioContentMainItem>
|
||||
|
||||
fun findByThemeFor2Weeks(
|
||||
cloudfrontHost: String,
|
||||
theme: String = "",
|
||||
isAdult: Boolean = false,
|
||||
offset: Long = 0,
|
||||
limit: Long = 20
|
||||
): List<GetAudioContentMainItem>
|
||||
|
||||
fun totalCountNewContentFor2Weeks(theme: String, isAdult: Boolean): Int
|
||||
|
||||
fun getNewContentUploadCreatorList(
|
||||
cloudfrontHost: String,
|
||||
isAdult: Boolean = false
|
||||
|
@ -251,6 +261,68 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory)
|
|||
.fetch()
|
||||
}
|
||||
|
||||
override fun totalCountNewContentFor2Weeks(theme: String, isAdult: Boolean): Int {
|
||||
var where = audioContent.isActive.isTrue
|
||||
.and(audioContent.createdAt.loe(LocalDateTime.now()))
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
}
|
||||
|
||||
if (theme.isNotBlank()) {
|
||||
where = where.and(audioContentTheme.theme.eq(theme))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(audioContent.id)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.where(where)
|
||||
.fetch()
|
||||
.size
|
||||
}
|
||||
|
||||
override fun findByThemeFor2Weeks(
|
||||
cloudfrontHost: String,
|
||||
theme: String,
|
||||
isAdult: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<GetAudioContentMainItem> {
|
||||
var where = audioContent.isActive.isTrue
|
||||
.and(audioContent.createdAt.loe(LocalDateTime.now()))
|
||||
|
||||
if (!isAdult) {
|
||||
where = where.and(audioContent.isAdult.isFalse)
|
||||
}
|
||||
|
||||
if (theme.isNotBlank()) {
|
||||
where = where.and(audioContentTheme.theme.eq(theme))
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetAudioContentMainItem(
|
||||
audioContent.id,
|
||||
audioContent.coverImage.prepend("/").prepend(cloudfrontHost),
|
||||
audioContent.title,
|
||||
audioContent.isAdult,
|
||||
member.id,
|
||||
member.profileImage.prepend("/").prepend(cloudfrontHost),
|
||||
member.nickname
|
||||
)
|
||||
)
|
||||
.from(audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.innerJoin(audioContent.theme, audioContentTheme)
|
||||
.where(where)
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.orderBy(audioContent.createdAt.desc())
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun getNewContentUploadCreatorList(
|
||||
cloudfrontHost: String,
|
||||
isAdult: Boolean
|
||||
|
|
|
@ -33,4 +33,15 @@ class AudioContentMainController(private val service: AudioContentMainService) {
|
|||
|
||||
ApiResponse.ok(service.getNewContentByTheme(theme, member, pageable))
|
||||
}
|
||||
|
||||
@GetMapping("/new/all")
|
||||
fun getNewContentAllByTheme(
|
||||
@RequestParam("theme") theme: String,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
pageable: Pageable
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(service.getNewContentFor2WeeksByTheme(theme, member, pageable))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,4 +148,17 @@ class AudioContentMainService(
|
|||
.filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) }
|
||||
.toList()
|
||||
}
|
||||
|
||||
fun getNewContentFor2WeeksByTheme(theme: String, member: Member, pageable: Pageable): GetNewContentAllResponse {
|
||||
val totalCount = repository.totalCountNewContentFor2Weeks(theme, isAdult = member.auth != null)
|
||||
val items = repository.findByThemeFor2Weeks(
|
||||
cloudfrontHost = imageHost,
|
||||
theme = theme,
|
||||
isAdult = member.auth != null,
|
||||
offset = pageable.offset,
|
||||
limit = pageable.pageSize.toLong()
|
||||
)
|
||||
|
||||
return GetNewContentAllResponse(totalCount, items)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.content.main
|
||||
|
||||
data class GetNewContentAllResponse(
|
||||
val totalCount: Int,
|
||||
val items: List<GetAudioContentMainItem>
|
||||
)
|
Loading…
Reference in New Issue