model

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func InitDb

func InitDb() error

func MigrateDb

func MigrateDb() error

Types

type CustomTime

type CustomTime struct {
	time.Time
}

func (*CustomTime) MarshalJSON

func (ct *CustomTime) MarshalJSON() ([]byte, error)

func (*CustomTime) Scan

func (ct *CustomTime) Scan(value interface{}) error

Scan 实现 Scanner 接口,将数据库中的时间值转换为 CustomTime

func (*CustomTime) UnmarshalJSON

func (ct *CustomTime) UnmarshalJSON(b []byte) error

UnmarshalJSON 解析 JSON 数据到 CustomTime

func (*CustomTime) Value

func (ct *CustomTime) Value() (driver.Value, error)

Value 实现 Valuer 接口,将 CustomTime 转换为 time.Time

type DataSource

type DataSource struct {
	Model
	Name string          `json:"name" gorm:"size:255"`
	Type string          `json:"type" gorm:"size:255"`
	Data _type.KeyValues `json:"data" gorm:"type:text;serializer:encryption"`
}

type EncryptionSerializer

type EncryptionSerializer struct {
}

EncryptionSerializer 加解密序列化器

func (EncryptionSerializer) Scan

func (e EncryptionSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)

Scan 实现 Scan 方法

func (EncryptionSerializer) Value

func (e EncryptionSerializer) Value(_ context.Context, _ *schema.Field, _ reflect.Value, fieldValue interface{}) (interface{}, error)

Value 实现 Value 方法

type File

type File struct {
	Model
	Name   string `json:"name"`
	Path   string `json:"path"`
	Size   int64  `json:"size"`
	ExName string `json:"ex_name"`
}

type Model

type Model struct {
	ID        string      `gorm:"size:36;primarykey" json:"id"`
	UpdatedAt *CustomTime `json:"updated_at"`
	CreatedAt *CustomTime `json:"created_at"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(_ *gorm.DB) (err error)

type Task

type Task struct {
	Model
	DeletedAt       gorm.DeletedAt  `gorm:"index"`
	Name            string          `json:"mission_name" gorm:"size:255"`
	Cron            string          `json:"cron" gorm:"size:40"`
	Data            *_type.TaskData `json:"data" gorm:"type:json"`
	Status          int             `json:"status" gorm:"default:0;size:2"` // 0:暂存 1:调度中 2:错误
	LastRunTime     *CustomTime     `json:"last_run_time"`
	LastSuccessTime *CustomTime     `json:"last_success_time"`
	LastEndTime     *CustomTime     `json:"last_end_time"`
	ErrMsg          string          `json:"err_msg"`
	IsRunning       bool
	EntryID         *int // cron.EntryID
}

type TaskRecord

type TaskRecord struct {
	Model
	CreatedAt *CustomTime
	RunBy     string          `json:"run_by"`
	TaskID    string          `json:"task_id"`
	Task      Task            `json:"task"`
	Status    int             `json:"status"` //0运行中;1运行成功;2运行失败
	StartTime *CustomTime     `json:"start_time"`
	EndTime   *CustomTime     `json:"end_time"`
	Message   string          `json:"message"`
	Data      *_type.TaskData `json:"data" gorm:"type:json"`
}

type TaskRecordFile

type TaskRecordFile struct {
	Model
	TaskRecordID string `json:"task_record_id"`
	FileID       string `json:"file_id"`
	File         File
}

type Variable

type Variable struct {
	Model
	Name         string           `json:"name" gorm:"size:255"`
	Type         string           `json:"type" gorm:"size:255"`
	Description  string           `json:"description" gorm:"size:255"`
	DataSourceID *string          `json:"datasource_id" gorm:"size:36"`
	DataSource   *DataSource      `json:"datasource"`
	Value        *_type.KeyValues `json:"value" gorm:"type:json"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL