Skip to content

Commit

Permalink
[Fix/#406] 매일 받기 설정한 구독 조회되지 않는 문제 해결 (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 authored Sep 18, 2024
1 parent 604e254 commit 62951f4
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.few.batch.service.article.reader
import com.few.batch.data.common.code.BatchDayCode
import com.few.batch.service.article.dto.WorkBookSubscriberItem
import jooq.jooq_dsl.tables.Subscription.SUBSCRIPTION
import jooq.jooq_dsl.tables.records.SubscriptionRecord
import org.jooq.Condition
import org.jooq.DSLContext
import org.jooq.TableField
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional
import java.time.DayOfWeek
Expand All @@ -23,9 +26,9 @@ class WorkBookSubscriberReader(
val date = LocalDate.now(ZoneId.of("Asia/Seoul"))
val sendDay =
if ((date.dayOfWeek == DayOfWeek.SATURDAY) || (date.dayOfWeek == DayOfWeek.SUNDAY)) {
BatchDayCode.MON_TUE_WED_THU_FRI_SAT_SUN.code
BatchDayCode.MON_TUE_WED_THU_FRI_SAT_SUN
} else {
BatchDayCode.MON_TUE_WED_THU_FRI.code
BatchDayCode.MON_TUE_WED_THU_FRI
}

return dslContext.select(
Expand All @@ -35,9 +38,17 @@ class WorkBookSubscriberReader(
)
.from(SUBSCRIPTION)
.where(SUBSCRIPTION.SEND_TIME.eq(time))
.and(SUBSCRIPTION.SEND_DAY.eq(sendDay))
.and(sendDayCondition(SUBSCRIPTION.SEND_DAY, sendDay))
.and(SUBSCRIPTION.TARGET_MEMBER_ID.isNull)
.and(SUBSCRIPTION.DELETED_AT.isNull)
.fetchInto(WorkBookSubscriberItem::class.java)
}

private fun sendDayCondition(sendDayField: TableField<SubscriptionRecord, String>, sendDayCode: BatchDayCode): Condition {
return if (sendDayCode == BatchDayCode.MON_TUE_WED_THU_FRI_SAT_SUN) {
sendDayField.eq(BatchDayCode.MON_TUE_WED_THU_FRI.code).or(sendDayField.eq(BatchDayCode.MON_TUE_WED_THU_FRI_SAT_SUN.code))
} else {
sendDayField.eq(sendDayCode.code)
}
}
}

0 comments on commit 62951f4

Please sign in to comment.