Compare commits
2 Commits
df3f045209
...
40c0b72450
Author | SHA1 | Date |
---|---|---|
|
40c0b72450 | |
|
e0c9a2cea7 |
|
@ -1,6 +1,7 @@
|
||||||
package kr.co.vividnext.sodalive.admin.content.banner
|
package kr.co.vividnext.sodalive.admin.content.banner
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
|
import kr.co.vividnext.sodalive.admin.content.series.AdminContentSeriesRepository
|
||||||
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
|
||||||
import kr.co.vividnext.sodalive.common.SodaException
|
import kr.co.vividnext.sodalive.common.SodaException
|
||||||
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBanner
|
import kr.co.vividnext.sodalive.content.main.banner.AudioContentBanner
|
||||||
|
@ -19,6 +20,7 @@ class AdminContentBannerService(
|
||||||
private val s3Uploader: S3Uploader,
|
private val s3Uploader: S3Uploader,
|
||||||
private val repository: AdminContentBannerRepository,
|
private val repository: AdminContentBannerRepository,
|
||||||
private val memberRepository: MemberRepository,
|
private val memberRepository: MemberRepository,
|
||||||
|
private val seriesRepository: AdminContentSeriesRepository,
|
||||||
private val eventRepository: EventRepository,
|
private val eventRepository: EventRepository,
|
||||||
private val objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
|
|
||||||
|
@ -32,6 +34,10 @@ class AdminContentBannerService(
|
||||||
throw SodaException("크리에이터를 선택하세요.")
|
throw SodaException("크리에이터를 선택하세요.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.type == AudioContentBannerType.SERIES && request.seriesId == null) {
|
||||||
|
throw SodaException("시리즈를 선택하세요.")
|
||||||
|
}
|
||||||
|
|
||||||
if (request.type == AudioContentBannerType.LINK && request.link == null) {
|
if (request.type == AudioContentBannerType.LINK && request.link == null) {
|
||||||
throw SodaException("링크 url을 입력하세요.")
|
throw SodaException("링크 url을 입력하세요.")
|
||||||
}
|
}
|
||||||
|
@ -52,11 +58,18 @@ class AdminContentBannerService(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val series = if (request.seriesId != null && request.seriesId > 0) {
|
||||||
|
seriesRepository.findByIdOrNull(request.seriesId)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
val audioContentBanner = AudioContentBanner(type = request.type)
|
val audioContentBanner = AudioContentBanner(type = request.type)
|
||||||
audioContentBanner.link = request.link
|
audioContentBanner.link = request.link
|
||||||
audioContentBanner.isAdult = request.isAdult
|
audioContentBanner.isAdult = request.isAdult
|
||||||
audioContentBanner.event = event
|
audioContentBanner.event = event
|
||||||
audioContentBanner.creator = creator
|
audioContentBanner.creator = creator
|
||||||
|
audioContentBanner.series = series
|
||||||
repository.save(audioContentBanner)
|
repository.save(audioContentBanner)
|
||||||
|
|
||||||
val fileName = generateFileName()
|
val fileName = generateFileName()
|
||||||
|
@ -96,8 +109,21 @@ class AdminContentBannerService(
|
||||||
audioContentBanner.creator = null
|
audioContentBanner.creator = null
|
||||||
audioContentBanner.event = null
|
audioContentBanner.event = null
|
||||||
audioContentBanner.link = null
|
audioContentBanner.link = null
|
||||||
|
audioContentBanner.series = null
|
||||||
|
|
||||||
if (request.type == AudioContentBannerType.CREATOR) {
|
when (request.type) {
|
||||||
|
AudioContentBannerType.EVENT -> {
|
||||||
|
if (request.eventId != null) {
|
||||||
|
val event = eventRepository.findByIdOrNull(request.eventId)
|
||||||
|
?: throw SodaException("이벤트를 선택하세요.")
|
||||||
|
|
||||||
|
audioContentBanner.event = event
|
||||||
|
} else {
|
||||||
|
throw SodaException("이벤트를 선택하세요.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioContentBannerType.CREATOR -> {
|
||||||
if (request.creatorId != null) {
|
if (request.creatorId != null) {
|
||||||
val creator = memberRepository.findByIdOrNull(request.creatorId)
|
val creator = memberRepository.findByIdOrNull(request.creatorId)
|
||||||
?: throw SodaException("크리에이터를 선택하세요.")
|
?: throw SodaException("크리에이터를 선택하세요.")
|
||||||
|
@ -106,20 +132,25 @@ class AdminContentBannerService(
|
||||||
} else {
|
} else {
|
||||||
throw SodaException("크리에이터를 선택하세요.")
|
throw SodaException("크리에이터를 선택하세요.")
|
||||||
}
|
}
|
||||||
} else if (request.type == AudioContentBannerType.LINK) {
|
}
|
||||||
|
|
||||||
|
AudioContentBannerType.LINK -> {
|
||||||
if (request.link != null) {
|
if (request.link != null) {
|
||||||
audioContentBanner.link = request.link
|
audioContentBanner.link = request.link
|
||||||
} else {
|
} else {
|
||||||
throw SodaException("링크 url을 입력하세요.")
|
throw SodaException("링크 url을 입력하세요.")
|
||||||
}
|
}
|
||||||
} else if (request.type == AudioContentBannerType.EVENT) {
|
}
|
||||||
if (request.eventId != null) {
|
|
||||||
val event = eventRepository.findByIdOrNull(request.eventId)
|
|
||||||
?: throw SodaException("이벤트를 선택하세요.")
|
|
||||||
|
|
||||||
audioContentBanner.event = event
|
AudioContentBannerType.SERIES -> {
|
||||||
|
if (request.seriesId != null) {
|
||||||
|
val series = seriesRepository.findByIdOrNull(request.seriesId)
|
||||||
|
?: throw SodaException("시리즈를 선택하세요.")
|
||||||
|
|
||||||
|
audioContentBanner.series = series
|
||||||
} else {
|
} else {
|
||||||
throw SodaException("이벤트를 선택하세요.")
|
throw SodaException("시리즈를 선택하세요.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ data class CreateContentBannerRequest(
|
||||||
val type: AudioContentBannerType,
|
val type: AudioContentBannerType,
|
||||||
val eventId: Long?,
|
val eventId: Long?,
|
||||||
val creatorId: Long?,
|
val creatorId: Long?,
|
||||||
|
val seriesId: Long?,
|
||||||
val link: String?,
|
val link: String?,
|
||||||
val isAdult: Boolean
|
val isAdult: Boolean
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,6 +7,7 @@ data class UpdateContentBannerRequest(
|
||||||
val type: AudioContentBannerType?,
|
val type: AudioContentBannerType?,
|
||||||
val eventId: Long?,
|
val eventId: Long?,
|
||||||
val creatorId: Long?,
|
val creatorId: Long?,
|
||||||
|
val seriesId: Long?,
|
||||||
val link: String?,
|
val link: String?,
|
||||||
val isAdult: Boolean?,
|
val isAdult: Boolean?,
|
||||||
val isActive: Boolean?
|
val isActive: Boolean?
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.security.access.prepost.PreAuthorize
|
import org.springframework.security.access.prepost.PreAuthorize
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -13,4 +14,9 @@ import org.springframework.web.bind.annotation.RestController
|
||||||
class AdminContentSeriesController(private val service: AdminContentSeriesService) {
|
class AdminContentSeriesController(private val service: AdminContentSeriesService) {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
fun getSeriesList(pageable: Pageable) = ApiResponse.ok(service.getSeriesList(pageable))
|
fun getSeriesList(pageable: Pageable) = ApiResponse.ok(service.getSeriesList(pageable))
|
||||||
|
|
||||||
|
@GetMapping("/search")
|
||||||
|
fun searchSeriesList(
|
||||||
|
@RequestParam(value = "search_word") searchWord: String
|
||||||
|
) = ApiResponse.ok(service.searchSeriesList(searchWord))
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ interface AdminContentSeriesQueryRepository {
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<GetAdminSeriesListItem>
|
): List<GetAdminSeriesListItem>
|
||||||
|
|
||||||
|
fun searchSeriesList(searchWord: String): List<GetAdminSearchSeriesListItem>
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdminContentSeriesQueryRepositoryImpl(
|
class AdminContentSeriesQueryRepositoryImpl(
|
||||||
|
@ -31,6 +33,7 @@ class AdminContentSeriesQueryRepositoryImpl(
|
||||||
override fun getSeriesTotalCount(): Int {
|
override fun getSeriesTotalCount(): Int {
|
||||||
val where = series.isActive.isTrue
|
val where = series.isActive.isTrue
|
||||||
.and(series.member.isNotNull)
|
.and(series.member.isNotNull)
|
||||||
|
.and(series.member.isActive.isTrue)
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(series.id)
|
.select(series.id)
|
||||||
|
@ -43,6 +46,7 @@ class AdminContentSeriesQueryRepositoryImpl(
|
||||||
override fun getSeriesList(offset: Long, limit: Long): List<GetAdminSeriesListItem> {
|
override fun getSeriesList(offset: Long, limit: Long): List<GetAdminSeriesListItem> {
|
||||||
val where = series.isActive.isTrue
|
val where = series.isActive.isTrue
|
||||||
.and(series.member.isNotNull)
|
.and(series.member.isNotNull)
|
||||||
|
.and(series.member.isActive.isTrue)
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.select(
|
||||||
|
@ -73,4 +77,23 @@ class AdminContentSeriesQueryRepositoryImpl(
|
||||||
.orderBy(series.member.id.asc(), series.orders.asc())
|
.orderBy(series.member.id.asc(), series.orders.asc())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun searchSeriesList(searchWord: String): List<GetAdminSearchSeriesListItem> {
|
||||||
|
val where = series.isActive.isTrue
|
||||||
|
.and(series.member.isNotNull)
|
||||||
|
.and(series.member.isActive.isTrue)
|
||||||
|
|
||||||
|
return queryFactory
|
||||||
|
.select(
|
||||||
|
QGetAdminSearchSeriesListItem(
|
||||||
|
series.id,
|
||||||
|
series.title
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.from(series)
|
||||||
|
.innerJoin(series.member, member)
|
||||||
|
.where(where)
|
||||||
|
.orderBy(series.id.desc())
|
||||||
|
.fetch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,8 @@ class AdminContentSeriesService(private val repository: AdminContentSeriesReposi
|
||||||
|
|
||||||
return GetAdminSeriesListResponse(totalCount, items)
|
return GetAdminSeriesListResponse(totalCount, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun searchSeriesList(searchWord: String): List<GetAdminSearchSeriesListItem> {
|
||||||
|
return repository.searchSeriesList(searchWord)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,3 +18,8 @@ data class GetAdminSeriesListItem @QueryProjection constructor(
|
||||||
val state: String,
|
val state: String,
|
||||||
val isAdult: Boolean
|
val isAdult: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class GetAdminSearchSeriesListItem @QueryProjection constructor(
|
||||||
|
val id: Long,
|
||||||
|
val title: String
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue