You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gojobs/model.go

29 lines
786 B

2 years ago
package gojobs
import (
"context"
"go.dtapp.net/gojobs/jobs_gorm_model"
2 years ago
"go.dtapp.net/gotime"
2 years ago
)
// 创建模型
func (c *Client) autoMigrateTask(ctx context.Context) {
2 years ago
err := c.gormClient.Db.AutoMigrate(&jobs_gorm_model.Task{})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("创建模型:%s", err)
2 years ago
}
}
2 years ago
// 创建模型
func (c *Client) autoMigrateTaskLog(ctx context.Context) {
err := c.gormClient.Db.AutoMigrate(&jobs_gorm_model.TaskLog{})
2 years ago
if err != nil {
2 years ago
c.zapLog.WithTraceId(ctx).Sugar().Errorf("创建模型:%s", err)
2 years ago
}
}
2 years ago
// TaskLogDelete 删除
func (c *Client) TaskLogDelete(ctx context.Context, hour int64) error {
return c.gormClient.Db.Where("log_time < ?", gotime.Current().BeforeHour(hour).Format()).Delete(&jobs_gorm_model.TaskLog{}).Error
}