앱 - 배역 상세 API, 지원 리스트 API
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package kr.co.vividnext.sodalive.audition.role
|
||||
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
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.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/audition/role")
|
||||
class AuditionRoleController(private val service: AuditionRoleService) {
|
||||
@GetMapping("/{id}")
|
||||
fun getAuditionRoleDetail(
|
||||
@PathVariable id: Long,
|
||||
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
|
||||
) = run {
|
||||
if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
ApiResponse.ok(
|
||||
service.getAuditionRoleDetail(
|
||||
auditionRoleId = id,
|
||||
memberId = member.id!!
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@ interface AuditionRoleRepository : JpaRepository<AuditionRole, Long>, AuditionRo
|
||||
|
||||
interface AuditionRoleQueryRepository {
|
||||
fun getAuditionRoleListByAuditionId(auditionId: Long): List<GetAuditionRoleListData>
|
||||
fun getAuditionRoleDetail(auditionRoleId: Long): GetAuditionRoleDetailData?
|
||||
}
|
||||
|
||||
class AuditionRoleQueryRepositoryImpl(
|
||||
@@ -40,4 +41,25 @@ class AuditionRoleQueryRepositoryImpl(
|
||||
)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
override fun getAuditionRoleDetail(auditionRoleId: Long): GetAuditionRoleDetailData? {
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetAuditionRoleDetailData(
|
||||
auditionRole.id,
|
||||
auditionRole.name,
|
||||
auditionRole.imagePath.prepend("/").prepend(cloudfrontHost),
|
||||
auditionRole.information,
|
||||
audition.originalWorkUrl,
|
||||
auditionRole.auditionScriptUrl
|
||||
)
|
||||
)
|
||||
.from(auditionRole)
|
||||
.innerJoin(auditionRole.audition, audition)
|
||||
.where(
|
||||
auditionRole.id.eq(auditionRoleId),
|
||||
auditionRole.isActive.isTrue
|
||||
)
|
||||
.fetchFirst()
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package kr.co.vividnext.sodalive.audition.role
|
||||
|
||||
import kr.co.vividnext.sodalive.audition.applicant.AuditionApplicantRepository
|
||||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class AuditionRoleService(
|
||||
private val repository: AuditionRoleRepository,
|
||||
private val applicantRepository: AuditionApplicantRepository
|
||||
) {
|
||||
fun getAuditionRoleDetail(auditionRoleId: Long, memberId: Long): GetAuditionRoleDetailResponse {
|
||||
val roleDetailData = repository.getAuditionRoleDetail(auditionRoleId = auditionRoleId)
|
||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||
|
||||
val isAlreadyApplicant = applicantRepository.isAlreadyApplicant(
|
||||
auditionRoleId = auditionRoleId,
|
||||
memberId = memberId
|
||||
)
|
||||
|
||||
return roleDetailData.toDetailResponse(isAlreadyApplicant = isAlreadyApplicant)
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package kr.co.vividnext.sodalive.audition.role
|
||||
|
||||
import com.querydsl.core.annotations.QueryProjection
|
||||
|
||||
data class GetAuditionRoleDetailResponse(
|
||||
val auditionRoleId: Long,
|
||||
val name: String,
|
||||
val imageUrl: String,
|
||||
val information: String,
|
||||
val originalWorkUrl: String,
|
||||
val auditionScriptUrl: String,
|
||||
val isAlreadyApplicant: Boolean = false
|
||||
)
|
||||
|
||||
data class GetAuditionRoleDetailData @QueryProjection constructor(
|
||||
val auditionRoleId: Long,
|
||||
val name: String,
|
||||
val imageUrl: String,
|
||||
val information: String,
|
||||
val originalWorkUrl: String,
|
||||
val auditionScriptUrl: String
|
||||
) {
|
||||
fun toDetailResponse(isAlreadyApplicant: Boolean) = GetAuditionRoleDetailResponse(
|
||||
auditionRoleId = auditionRoleId,
|
||||
name = name,
|
||||
imageUrl = imageUrl,
|
||||
information = information,
|
||||
originalWorkUrl = originalWorkUrl,
|
||||
auditionScriptUrl = auditionScriptUrl,
|
||||
isAlreadyApplicant = isAlreadyApplicant
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user