// Code generated by goctl. DO NOT EDIT.

package models

import (
	"context"
	"database/sql"
	"gorm.io/gorm"
	"strings"
	"time"

	"github.com/zeromicro/go-zero/core/stores/builder"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"github.com/zeromicro/go-zero/core/stringx"
)

var (
	taskFieldNames          = builder.RawFieldNames(&Task{})
	taskRows                = strings.Join(taskFieldNames, ",")
	taskRowsExpectAutoSet   = strings.Join(stringx.Remove(taskFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
	taskRowsWithPlaceHolder = strings.Join(stringx.Remove(taskFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
)

type (
	taskModel interface {
		Insert(ctx context.Context, data *Task) (sql.Result, error)
		FindOne(ctx context.Context, id int64) (*Task, error)
		Update(ctx context.Context, data *Task) error
		Delete(ctx context.Context, id int64) error
	}

	defaultTaskModel struct {
		conn  sqlx.SqlConn
		table string
	}

	Task struct {
		Id              int64          `db:"id"`             // id
		Name            string         `db:"name"`           // 作业名称
		Description     string         `db:"description"`    // 作业描述
		Status          string         `db:"status"`         // 作业状态
		Strategy        int64          `db:"strategy"`       // 策略
		SynergyStatus   int64          `db:"synergy_status"` // 协同状态（0-未协同、1-已协同）
		CommitTime      time.Time      `db:"commit_time"`    // 提交时间
		StartTime       *time.Time     `db:"start_time"`     // 开始时间
		EndTime         *time.Time     `db:"end_time"`       // 结束运行时间
		RunningTime     int64          `db:"running_time"`   // 已运行时间（单位秒）
		YamlString      string         `db:"yaml_string"`
		Result          string         `db:"result"` // 作业结果
		DeletedAt       gorm.DeletedAt `gorm:"index"`
		NsID            string         `db:"ns_id"`
		AdapterTypeDict string         `db:"adapter_type_dict"` //任务类型（对应字典表的值）
		TaskTypeDict    string         `db:"task_type_dict"`
	}
)

func newTaskModel(conn sqlx.SqlConn) *defaultTaskModel {
	return &defaultTaskModel{
		conn:  conn,
		table: "`task`",
	}
}

func (m *defaultTaskModel) tableName() string {
	return m.table
}
