parent
96f571e0c4
commit
7a395a9906
|
@ -11,7 +11,7 @@ import javax.persistence.ManyToOne
|
||||||
data class AuditionApplicant(
|
data class AuditionApplicant(
|
||||||
val phoneNumber: String,
|
val phoneNumber: String,
|
||||||
var voicePath: String? = null,
|
var voicePath: String? = null,
|
||||||
val isActive: Boolean = true
|
var isActive: Boolean = true
|
||||||
) : BaseEntity() {
|
) : BaseEntity() {
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "role_id", nullable = false)
|
@JoinColumn(name = "role_id", nullable = false)
|
||||||
|
|
|
@ -20,6 +20,8 @@ interface AuditionApplicantQueryRepository {
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<GetAuditionRoleApplicantItem>
|
): List<GetAuditionRoleApplicantItem>
|
||||||
|
|
||||||
|
fun findActiveApplicantByMemberIdAndRoleId(memberId: Long, roleId: Long): AuditionApplicant?
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuditionApplicantQueryRepositoryImpl(
|
class AuditionApplicantQueryRepositoryImpl(
|
||||||
|
@ -90,4 +92,15 @@ class AuditionApplicantQueryRepositoryImpl(
|
||||||
.orderBy(orderBy)
|
.orderBy(orderBy)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun findActiveApplicantByMemberIdAndRoleId(memberId: Long, roleId: Long): AuditionApplicant? {
|
||||||
|
return queryFactory
|
||||||
|
.selectFrom(auditionApplicant)
|
||||||
|
.where(
|
||||||
|
auditionApplicant.isActive.isTrue
|
||||||
|
.and(auditionApplicant.member.id.eq(memberId))
|
||||||
|
.and(auditionApplicant.role.id.eq(roleId))
|
||||||
|
)
|
||||||
|
.fetchFirst()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,16 @@ class AuditionApplicantService(
|
||||||
val auditionRole = roleRepository.findByIdOrNull(id = request.roleId)
|
val auditionRole = roleRepository.findByIdOrNull(id = request.roleId)
|
||||||
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
?: throw SodaException("잘못된 요청입니다.\n다시 시도해 주세요.")
|
||||||
|
|
||||||
|
val existingApplicant = repository.findActiveApplicantByMemberIdAndRoleId(
|
||||||
|
memberId = member.id!!,
|
||||||
|
roleId = auditionRole.id!!
|
||||||
|
)
|
||||||
|
|
||||||
|
if (existingApplicant != null) {
|
||||||
|
existingApplicant.isActive = false
|
||||||
|
repository.save(existingApplicant)
|
||||||
|
}
|
||||||
|
|
||||||
val applicant = AuditionApplicant(phoneNumber = request.phoneNumber)
|
val applicant = AuditionApplicant(phoneNumber = request.phoneNumber)
|
||||||
applicant.role = auditionRole
|
applicant.role = auditionRole
|
||||||
applicant.member = member
|
applicant.member = member
|
||||||
|
|
Loading…
Reference in New Issue