크리에이터 관리자 API
- 시리즈 상세 API 추가
This commit is contained in:
		| @@ -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!!)) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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? | ||||
| ) | ||||
| @@ -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 -> "완결" | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user