오디션 투표 - 횟수 계산 방식 수정

- 오디션 지원자별 하루 10개 -> 전체 투표 횟수 하루 10개
This commit is contained in:
Klaus 2025-01-03 13:00:02 +09:00
parent 64d9f3e362
commit 1ddd40948e
2 changed files with 4 additions and 8 deletions

View File

@ -9,9 +9,8 @@ import java.time.LocalDateTime
interface AuditionVoteRepository : JpaRepository<AuditionVote, Long>, AuditionVoteQueryRepository
interface AuditionVoteQueryRepository {
fun countByMemberIdAndApplicantIdAndVoteDateRange(
fun countByMemberIdAndVoteDateRange(
memberId: Long,
applicantId: Long,
startDate: LocalDateTime,
endDate: LocalDateTime
): Int
@ -20,9 +19,8 @@ interface AuditionVoteQueryRepository {
class AuditionVoteQueryRepositoryImpl(
private val queryFactory: JPAQueryFactory
) : AuditionVoteQueryRepository {
override fun countByMemberIdAndApplicantIdAndVoteDateRange(
override fun countByMemberIdAndVoteDateRange(
memberId: Long,
applicantId: Long,
startDate: LocalDateTime,
endDate: LocalDateTime
): Int {
@ -31,7 +29,6 @@ class AuditionVoteQueryRepositoryImpl(
.from(auditionVote)
.where(
auditionVote.member.id.eq(memberId)
.and(auditionVote.applicant.id.eq(applicantId))
.and(auditionVote.createdAt.between(startDate, endDate))
)
.fetch()

View File

@ -36,15 +36,14 @@ class AuditionVoteService(
val startDate = startOfDayClient.withZoneSameInstant(ZoneOffset.UTC).toLocalDateTime()
val endDate = endOfDayClient.withZoneSameInstant(ZoneOffset.UTC).toLocalDateTime()
val voteCount = repository.countByMemberIdAndApplicantIdAndVoteDateRange(
val voteCount = repository.countByMemberIdAndVoteDateRange(
memberId = member.id!!,
applicantId = applicantId,
startDate = startDate,
endDate = endDate
)
if (voteCount > 10) {
throw SodaException("오늘 해당 지원자에게 할 수 있는 최대 투표수를 초과하였습니다.\n내일 다시 투표해 주세요.")
throw SodaException("오늘 응원은 여기까지!\n하루 최대 10회까지 응원이 가능합니다.\n내일 다시 이용해주세요.")
}
if (voteCount > 0) {