test #366
@@ -27,6 +27,26 @@ class AudioContentThemeController(private val service: AudioContentThemeService)
|
|||||||
ApiResponse.ok(service.getThemes())
|
ApiResponse.ok(service.getThemes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/active")
|
||||||
|
fun getActiveThemes(
|
||||||
|
@RequestParam("isFree", required = false) isFree: Boolean? = null,
|
||||||
|
@RequestParam("isPointAvailableOnly", required = false) isPointAvailableOnly: Boolean? = null,
|
||||||
|
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||||
|
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||||
|
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||||
|
) = run {
|
||||||
|
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||||
|
|
||||||
|
ApiResponse.ok(
|
||||||
|
service.getActiveThemeOfContent(
|
||||||
|
isAdult = member.auth != null && (isAdultContentVisible ?: true),
|
||||||
|
isFree = isFree ?: false,
|
||||||
|
isPointAvailableOnly = isPointAvailableOnly ?: false,
|
||||||
|
contentType = contentType ?: ContentType.ALL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/{id}/content")
|
@GetMapping("/{id}/content")
|
||||||
fun getContentByTheme(
|
fun getContentByTheme(
|
||||||
@PathVariable id: Long,
|
@PathVariable id: Long,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class AudioContentThemeQueryRepository(
|
|||||||
fun getActiveThemeOfContent(
|
fun getActiveThemeOfContent(
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
isFree: Boolean = false,
|
isFree: Boolean = false,
|
||||||
|
isPointAvailableOnly: Boolean = false,
|
||||||
contentType: ContentType
|
contentType: ContentType
|
||||||
): List<String> {
|
): List<String> {
|
||||||
var where = audioContent.isActive.isTrue
|
var where = audioContent.isActive.isTrue
|
||||||
@@ -59,6 +60,10 @@ class AudioContentThemeQueryRepository(
|
|||||||
where = where.and(audioContent.price.loe(0))
|
where = where.and(audioContent.price.loe(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPointAvailableOnly) {
|
||||||
|
where = where.and(audioContent.isPointAvailable.isTrue)
|
||||||
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(audioContentTheme.theme)
|
.select(audioContentTheme.theme)
|
||||||
.from(audioContent)
|
.from(audioContent)
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ class AudioContentThemeService(
|
|||||||
fun getActiveThemeOfContent(
|
fun getActiveThemeOfContent(
|
||||||
isAdult: Boolean = false,
|
isAdult: Boolean = false,
|
||||||
isFree: Boolean = false,
|
isFree: Boolean = false,
|
||||||
|
isPointAvailableOnly: Boolean = false,
|
||||||
contentType: ContentType
|
contentType: ContentType
|
||||||
): List<String> {
|
): List<String> {
|
||||||
return queryRepository.getActiveThemeOfContent(
|
return queryRepository.getActiveThemeOfContent(
|
||||||
isAdult = isAdult,
|
isAdult = isAdult,
|
||||||
isFree = isFree,
|
isFree = isFree,
|
||||||
|
isPointAvailableOnly = isPointAvailableOnly,
|
||||||
contentType = contentType
|
contentType = contentType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user