🎨 新增兑换码功能,新增vip过期检测定时任务
This commit is contained in:
@@ -3,6 +3,11 @@ package test
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"git.echol.cn/loser/lckt/core"
|
||||
"git.echol.cn/loser/lckt/global"
|
||||
"git.echol.cn/loser/lckt/initialize"
|
||||
"git.echol.cn/loser/lckt/task"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
@@ -71,3 +76,29 @@ func sendCode(code string) {
|
||||
fmt.Println("请求失败,状态码:", resp.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTime(t *testing.T) {
|
||||
// 默认未过期,获取过期时间+30天
|
||||
// 将 existingTeacherVip.ExpireAt转为time.Time类型
|
||||
parse, err := time.Parse("2006-01-02", "2025-09-10")
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("转换过期时间出错", zap.Error(err))
|
||||
return
|
||||
}
|
||||
after := time.Now().After(parse)
|
||||
fmt.Println(after)
|
||||
}
|
||||
|
||||
func TestTask(t *testing.T) {
|
||||
global.GVA_VP = core.Viper() // 初始化Viper
|
||||
global.GVA_LOG = core.Zap() // 初始化zap日志库
|
||||
zap.ReplaceGlobals(global.GVA_LOG)
|
||||
global.GVA_DB = initialize.Gorm() // gorm连接数据库
|
||||
initialize.DBList()
|
||||
err := task.CheckVip(global.GVA_DB)
|
||||
if err != nil {
|
||||
fmt.Println("清理表失败", err.Error())
|
||||
} else {
|
||||
fmt.Println("清理表成功")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user