| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package models
- import (
- "IotAdmin/common/models"
- "gorm.io/gorm"
- )
- // SysJob 定时任务实体
- type SysJob struct {
- JobId int `json:"jobId" gorm:"type:bigint(20);primaryKey;autoIncrement;comment:编码"`
- JobName string `json:"jobName" gorm:"type:varchar(255);comment:名称"`
- JobGroup string `json:"jobGroup" gorm:"type:varchar(255);comment:任务分组"`
- JobType int `json:"jobType" gorm:"type:tinyint(4);comment:调用类型"`
- CronExpression string `json:"cronExpression" gorm:"type:varchar(255);comment:Cron表达式"`
- InvokeTarget string `json:"invokeTarget" gorm:"type:varchar(255);comment:调用目标"`
- Args string `json:"args" gorm:"type:varchar(255);comment:目标参数"`
- ExecCount int `json:"execCount" gorm:"type:bigint(20);comment:执行次数"`
- FailCount int `json:"failCount" gorm:"type:bigint(20);comment:失败次数"`
- LastExecTime int64 `json:"lastExecTime" gorm:"type:bigint(20);comment:上次执行时间"`
- NextExecTime int64 `json:"nextExecTime" gorm:"type:bigint(20);comment:下次执行时间"`
- MisfirePolicy int `json:"misfirePolicy" gorm:"type:bigint(20);comment:执行策略"`
- Concurrent int `json:"concurrent" gorm:"type:tinyint(4);comment:是否并发"`
- Status int `json:"status" gorm:"type:tinyint(4);comment:状态"`
- EntryId int `json:"entryId" gorm:"type:smallint(6);comment:EntryId"`
- models.ControlBy
- models.ModelTime
- }
- func (*SysJob) TableName() string {
- return "sys_job"
- }
- func (e *SysJob) Generate() models.ActiveRecord {
- o := *e
- return &o
- }
- func (e *SysJob) GetId() interface{} {
- return e.JobId
- }
- func (e *SysJob) Get(tx *gorm.DB, job *SysJob) (err error) {
- return tx.Model(e).First(job, e.JobId).Error
- }
- func (e *SysJob) GetList(tx *gorm.DB, list interface{}) (err error) {
- return tx.Table(e.TableName()).Where("status = ?", 2).Find(list).Error
- }
- // Update 更新SysJob
- func (e *SysJob) Update(tx *gorm.DB, id interface{}) (err error) {
- return tx.Table(e.TableName()).Where(id).Updates(&e).Error
- }
- func (e *SysJob) RemoveAllEntryID(tx *gorm.DB) (update SysJob, err error) {
- if err = tx.Table(e.TableName()).Where("entry_id > ?", 0).Update("entry_id", 0).Error; err != nil {
- return
- }
- return
- }
|