Explorar el Código

feat:新增定时任务 删除jwt

songzhibin97 hace 3 años
padre
commit
d09aee0b82
Se han modificado 2 ficheros con 3 adiciones y 2 borrados
  1. 1 0
      server/config.yaml
  2. 2 2
      server/initialize/timer.go

+ 1 - 0
server/config.yaml

@@ -130,6 +130,7 @@ Timer:
     # interval: 时间间隔, 具体配置详看 time.ParseDuration() 中字符串表示 且不能为负数
     # 2160h = 24 * 30 * 3 -> 三个月
     { tableName: "sys_operation_records" , compareField: "created_at", interval: "2160h" },
+    { tableName: "jwt_blacklists" , compareField: "created_at", interval: "168h" }
     #{ tableName: "log2" , compareField: "created_at", interval: "2160h" }
   ]
 

+ 2 - 2
server/initialize/timer.go

@@ -10,7 +10,7 @@ import (
 
 func Timer() {
 	if global.GVA_CONFIG.Timer.Start {
-		for _, detail := range global.GVA_CONFIG.Timer.Detail {
+		for i := range global.GVA_CONFIG.Timer.Detail {
 			go func(detail config.Detail) {
 				global.GVA_Timer.AddTaskByFunc("ClearDB", global.GVA_CONFIG.Timer.Spec, func() {
 					err := utils.ClearTable(global.GVA_DB, detail.TableName, detail.CompareField, detail.Interval)
@@ -18,7 +18,7 @@ func Timer() {
 						fmt.Println("timer error:", err)
 					}
 				})
-			}(detail)
+			}(global.GVA_CONFIG.Timer.Detail[i])
 		}
 	}
 }