feat(series): 오직 보이스온에서만(오리지널) 제공하는 콘텐츠도 조회할 수 있도록 isOriginal 파라미터 추가
This commit is contained in:
@@ -18,7 +18,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||
class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
@GetMapping
|
||||
fun getSeriesList(
|
||||
@RequestParam creatorId: Long,
|
||||
@RequestParam(required = false) creatorId: Long?,
|
||||
@RequestParam(name = "isOriginal", required = false) isOriginal: Boolean? = null,
|
||||
@RequestParam("isAdultContentVisible", required = false) isAdultContentVisible: Boolean? = null,
|
||||
@RequestParam("contentType", required = false) contentType: ContentType? = null,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?,
|
||||
@@ -29,6 +30,7 @@ class ContentSeriesController(private val service: ContentSeriesService) {
|
||||
ApiResponse.ok(
|
||||
service.getSeriesList(
|
||||
creatorId = creatorId,
|
||||
isOriginal = isOriginal ?: false,
|
||||
isAdultContentVisible = isAdultContentVisible ?: true,
|
||||
contentType = contentType ?: ContentType.ALL,
|
||||
member = member,
|
||||
|
||||
@@ -23,12 +23,13 @@ import org.springframework.data.jpa.repository.JpaRepository
|
||||
interface ContentSeriesRepository : JpaRepository<Series, Long>, ContentSeriesQueryRepository
|
||||
|
||||
interface ContentSeriesQueryRepository {
|
||||
fun getSeriesTotalCount(creatorId: Long, isAuth: Boolean, contentType: ContentType): Int
|
||||
fun getSeriesTotalCount(creatorId: Long?, isAuth: Boolean, contentType: ContentType, isOriginal: Boolean): Int
|
||||
fun getSeriesList(
|
||||
imageHost: String,
|
||||
creatorId: Long,
|
||||
creatorId: Long?,
|
||||
isAuth: Boolean,
|
||||
contentType: ContentType,
|
||||
isOriginal: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series>
|
||||
@@ -59,9 +60,16 @@ interface ContentSeriesQueryRepository {
|
||||
class ContentSeriesQueryRepositoryImpl(
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : ContentSeriesQueryRepository {
|
||||
override fun getSeriesTotalCount(creatorId: Long, isAuth: Boolean, contentType: ContentType): Int {
|
||||
var where = series.member.id.eq(creatorId)
|
||||
.and(series.isActive.isTrue)
|
||||
override fun getSeriesTotalCount(creatorId: Long?, isAuth: Boolean, contentType: ContentType, isOriginal: Boolean): Int {
|
||||
var where = series.isActive.isTrue
|
||||
|
||||
if (creatorId != null) {
|
||||
where = where.and(series.member.id.eq(creatorId))
|
||||
}
|
||||
|
||||
if (isOriginal) {
|
||||
where = where.and(series.isOriginal.isTrue)
|
||||
}
|
||||
|
||||
if (!isAuth) {
|
||||
where = where.and(series.isAdult.isFalse)
|
||||
@@ -92,14 +100,21 @@ class ContentSeriesQueryRepositoryImpl(
|
||||
|
||||
override fun getSeriesList(
|
||||
imageHost: String,
|
||||
creatorId: Long,
|
||||
creatorId: Long?,
|
||||
isAuth: Boolean,
|
||||
contentType: ContentType,
|
||||
isOriginal: Boolean,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<Series> {
|
||||
var where = series.member.id.eq(creatorId)
|
||||
.and(series.isActive.isTrue)
|
||||
var where = series.isActive.isTrue
|
||||
|
||||
if (creatorId != null) {
|
||||
where = where.and(series.member.id.eq(creatorId))
|
||||
}
|
||||
if (isOriginal) {
|
||||
where = where.and(series.isOriginal.isTrue)
|
||||
}
|
||||
|
||||
if (!isAuth) {
|
||||
where = where.and(series.isAdult.isFalse)
|
||||
|
||||
@@ -49,7 +49,8 @@ class ContentSeriesService(
|
||||
}
|
||||
|
||||
fun getSeriesList(
|
||||
creatorId: Long,
|
||||
creatorId: Long?,
|
||||
isOriginal: Boolean = false,
|
||||
isAdultContentVisible: Boolean,
|
||||
contentType: ContentType,
|
||||
member: Member,
|
||||
@@ -61,13 +62,16 @@ class ContentSeriesService(
|
||||
val totalCount = repository.getSeriesTotalCount(
|
||||
creatorId = creatorId,
|
||||
isAuth = isAuth,
|
||||
contentType = contentType
|
||||
contentType = contentType,
|
||||
isOriginal = isOriginal
|
||||
)
|
||||
|
||||
val rawItems = repository.getSeriesList(
|
||||
imageHost = coverImageHost,
|
||||
creatorId = creatorId,
|
||||
isAuth = isAuth,
|
||||
contentType = contentType,
|
||||
isOriginal = isOriginal,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
).filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!) }
|
||||
|
||||
Reference in New Issue
Block a user