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