Merge branch 'refs/heads/feat-cid-run-list' into release

This commit is contained in:
junleea 2025-09-28 20:41:24 +08:00
commit 1a2661bf41
2 changed files with 24 additions and 6 deletions

View File

@ -3,16 +3,19 @@ package dao
import (
"fmt"
"gorm.io/gorm"
"time"
)
type CID struct {
gorm.Model
Auth_id int `gorm:"column:auth_id"`
Name string `gorm:"column:name"`
Url string `gorm:"column:url"`
Time int `gorm:"column:time"` // 定时任务单位秒大于0表示定时任务
Script string `gorm:"column:script"`
Token string `gorm:"column:token"` // 用于外部回调
Auth_id int `gorm:"column:auth_id"`
Name string `gorm:"column:name"`
Url string `gorm:"column:url"`
Time int `gorm:"column:time"` // 定时任务单位秒大于0表示定时任务
LastSuccess time.Time `gorm:"column:last_success" json:"last_success"`
LastFail time.Time `gorm:"column:last_fail" json:"last_fail"`
Script string `gorm:"column:script"`
Token string `gorm:"column:token"` // 用于外部回调
}
type CIDRunLog struct {
@ -121,3 +124,13 @@ func FindCIDByCID(id uint) CID {
DB.Where("id = ? ", id).First(&cid)
return cid
}
func UpdateLastSuccessByID(id int, time time.Time) error {
res := DB.Where("id = ?", id).Update("last_success", time)
return res.Error
}
func UpdateLastFailByID(id int, time time.Time) error {
res := DB.Where("id = ?", id).Update("last_fail", time)
return res.Error
}

View File

@ -310,6 +310,11 @@ echo "end"`
elapsed := time.Since(start)
//fmt.Println("bash content:", scriptContent)
dao.CreateRunLog(id, authID, scriptContent, out.String(), err3_info, elapsed.Seconds()) //添加执行日志
if err3 != nil {
dao.UpdateLastFailByID(id, time.Now())
} else {
dao.UpdateLastSuccessByID(id, time.Now())
}
//移除正在运行
proto.CID_RunningMutex.Lock()
user_running_list = proto.CID_Running_Map[authID]