크리에이터 관리자 API

- 시리즈 상세 API 추가
This commit is contained in:
Klaus 2024-04-17 17:04:15 +09:00
parent 2a9eaead83
commit 50f02892e3
4 changed files with 72 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import org.springframework.lang.Nullable
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestMapping
@ -58,4 +59,14 @@ class CreatorAdminContentSeriesController(private val service: CreatorAdminConte
)
)
}
@GetMapping("/{id}")
fun getDetail(
@PathVariable id: Long,
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
ApiResponse.ok(service.getDetail(id = id, memberId = member.id!!))
}
}

View File

@ -171,4 +171,11 @@ class CreatorAdminContentSeriesService(
return GetCreatorAdminContentSeriesListResponse(totalCount, seriesList)
}
fun getDetail(id: Long, memberId: Long): GetCreatorAdminContentSeriesDetailResponse {
val series = repository.findByIdAndCreatorId(id = id, creatorId = memberId)
?: throw SodaException("잘못된 접근입니다.")
return series.toDetailResponse(imageHost = coverImageHost)
}
}

View File

@ -0,0 +1,15 @@
package kr.co.vividnext.sodalive.creator.admin.content.series
data class GetCreatorAdminContentSeriesDetailResponse(
val seriesId: Long,
val title: String,
val introduction: String,
val coverImage: String,
val publishedDaysOfWeek: String,
val genre: String,
val keywords: String,
val isAdult: Boolean,
val state: String,
val writer: String?,
val studio: String?
)

View File

@ -56,4 +56,43 @@ data class Series(
@OneToMany(mappedBy = "series", cascade = [CascadeType.ALL])
var keywordList: MutableList<SeriesKeyword> = mutableListOf()
fun toDetailResponse(imageHost: String): GetCreatorAdminContentSeriesDetailResponse {
return GetCreatorAdminContentSeriesDetailResponse(
seriesId = id!!,
title = title,
introduction = introduction,
coverImage = "$imageHost/$coverImage!!",
publishedDaysOfWeek = publishedDaysOfWeekText(),
genre = genre!!.genre,
keywords = keywordList.map { it.keyword!!.tag }.joinToString(" ") { it },
isAdult = isAdult,
state = stateSeriesText(),
writer = writer,
studio = studio
)
}
private fun publishedDaysOfWeekText(): String {
return publishedDaysOfWeek.toList().sortedBy { it.ordinal }.map {
when (it) {
SeriesPublishedDaysOfWeek.SUN -> ""
SeriesPublishedDaysOfWeek.MON -> ""
SeriesPublishedDaysOfWeek.TUE -> ""
SeriesPublishedDaysOfWeek.WED -> ""
SeriesPublishedDaysOfWeek.THU -> ""
SeriesPublishedDaysOfWeek.FRI -> ""
SeriesPublishedDaysOfWeek.SAT -> ""
SeriesPublishedDaysOfWeek.RANDOM -> "랜덤"
}
}.joinToString(", ") { it }
}
private fun stateSeriesText(): String {
return when (state) {
SeriesState.PROCEEDING -> "연재중"
SeriesState.SUSPEND -> "휴재중"
SeriesState.COMPLETE -> "완결"
}
}
}