完善计划任务日志功能

This commit is contained in:
dushixiang
2021-03-04 23:39:33 +08:00
parent 1b8ecefcfe
commit 2d06cd373f
14 changed files with 403 additions and 144 deletions

30
pkg/model/job_log.go Normal file
View File

@ -0,0 +1,30 @@
package model
import (
"next-terminal/pkg/global"
"next-terminal/pkg/utils"
)
type JobLog struct {
ID string `json:"id"`
Timestamp utils.JsonTime `json:"timestamp"`
JobId string `json:"jobId"`
Message string `json:"message"`
}
func (r *JobLog) TableName() string {
return "job_logs"
}
func CreateNewJobLog(o *JobLog) error {
return global.DB.Create(o).Error
}
func FindJobLogs(jobId string) (o []JobLog, err error) {
err = global.DB.Where("job_id = ?", jobId).Order("timestamp asc").Find(&o).Error
return
}
func DeleteJobLogByJobId(jobId string) error {
return global.DB.Where("job_id = ?", jobId).Delete(JobLog{}).Error
}