스프링 스케줄러를 이용하여 콘텐츠 예약 오픈 설정

This commit is contained in:
2024-12-02 08:22:16 +09:00
parent 4097e5a133
commit 05592f94b9
6 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package kr.co.vividnext.sodalive.common.annotation
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Before
import org.springframework.stereotype.Component
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class SchedulerOnly
@Aspect
@Component
class SchedulerOnlyAspect {
@Before("@annotation(SchedulerOnly)")
fun checkSchedulerAccess() {
if (!isSchedulerThread()) {
throw IllegalStateException("잘못된 접근입니다.")
}
}
private fun isSchedulerThread(): Boolean {
// 스케줄러 스레드 여부를 판단하는 간단한 로직
return Thread.currentThread().name.contains("scheduler")
}
}