새로운 콘텐츠 - 페이징 추가
This commit is contained in:
		| @@ -52,6 +52,7 @@ interface AudioContentQueryRepository { | ||||
|         cloudfrontHost: String, | ||||
|         theme: String = "", | ||||
|         isAdult: Boolean = false, | ||||
|         offset: Long = 0, | ||||
|         limit: Long = 20 | ||||
|     ): List<GetAudioContentMainItem> | ||||
|  | ||||
| @@ -215,6 +216,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|         cloudfrontHost: String, | ||||
|         theme: String, | ||||
|         isAdult: Boolean, | ||||
|         offset: Long, | ||||
|         limit: Long | ||||
|     ): List<GetAudioContentMainItem> { | ||||
|         var where = audioContent.isActive.isTrue | ||||
| @@ -243,6 +245,7 @@ class AudioContentQueryRepositoryImpl(private val queryFactory: JPAQueryFactory) | ||||
|             .innerJoin(audioContent.member, member) | ||||
|             .innerJoin(audioContent.theme, audioContentTheme) | ||||
|             .where(where) | ||||
|             .offset(offset) | ||||
|             .limit(limit) | ||||
|             .orderBy(audioContent.createdAt.desc()) | ||||
|             .fetch() | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.content.main | ||||
| import kr.co.vividnext.sodalive.common.ApiResponse | ||||
| import kr.co.vividnext.sodalive.common.SodaException | ||||
| import kr.co.vividnext.sodalive.member.Member | ||||
| import org.springframework.data.domain.Pageable | ||||
| import org.springframework.security.core.annotation.AuthenticationPrincipal | ||||
| import org.springframework.web.bind.annotation.GetMapping | ||||
| import org.springframework.web.bind.annotation.RequestMapping | ||||
| @@ -25,10 +26,11 @@ class AudioContentMainController(private val service: AudioContentMainService) { | ||||
|     @GetMapping("/new") | ||||
|     fun getNewContentByTheme( | ||||
|         @RequestParam("theme") theme: String, | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member? | ||||
|         @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?, | ||||
|         pageable: Pageable | ||||
|     ) = run { | ||||
|         if (member == null) throw SodaException("로그인 정보를 확인해주세요.") | ||||
|  | ||||
|         ApiResponse.ok(service.getNewContentByTheme(theme, member)) | ||||
|         ApiResponse.ok(service.getNewContentByTheme(theme, member, pageable)) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.event.EventItem | ||||
| 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.data.domain.Pageable | ||||
| import org.springframework.stereotype.Service | ||||
|  | ||||
| @Service | ||||
| @@ -135,11 +136,13 @@ class AudioContentMainService( | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     fun getNewContentByTheme(theme: String, member: Member): List<GetAudioContentMainItem> { | ||||
|     fun getNewContentByTheme(theme: String, member: Member, pageable: Pageable): List<GetAudioContentMainItem> { | ||||
|         return repository.findByTheme( | ||||
|             cloudfrontHost = imageHost, | ||||
|             theme = theme, | ||||
|             isAdult = member.auth != null | ||||
|             isAdult = member.auth != null, | ||||
|             offset = pageable.offset, | ||||
|             limit = pageable.pageSize.toLong() | ||||
|         ) | ||||
|             .asSequence() | ||||
|             .filter { !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.creatorId) } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user