| package com.zy.system.timer; | 
|   | 
| import com.zy.system.service.ConfigService; | 
| import lombok.Data; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.scheduling.annotation.Scheduled; | 
| import org.springframework.stereotype.Component; | 
|   | 
| /** | 
|  * 定时任务读取配置信息 | 
|  */ | 
| @Component | 
| @Slf4j | 
| @Data | 
| public class LoadingConfigTimer { | 
|   | 
|     /** | 
|      * token有效期时间 | 
|      */ | 
|     private Integer tokenExpire = 1000 * 30 * 60; | 
|     /** | 
|      * token数量限制 | 
|      */ | 
|     private Integer tokenNumber = 1; | 
|     /** | 
|      * 删除天数 | 
|      */ | 
|     private Integer logDeleteDays = 360; | 
|   | 
|   | 
|   | 
|     @Autowired | 
|     private ConfigService configService; | 
|   | 
|     @Scheduled(cron = "0/2 * * * * ? ") | 
|     public void timer() { | 
|         tokenExpire = configService.getVal("tokenExpire", Integer.class, tokenExpire); | 
|         tokenNumber = configService.getVal("tokenNumber", Integer.class, tokenNumber); | 
|         logDeleteDays = configService.getVal("logDeleteDays", Integer.class, logDeleteDays); | 
|   | 
|     } | 
|   | 
| } |