db

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceStatusInit  = "INIT"  //初始
	InstanceStatusBase  = "BASE"  // base 环境已完成
	InstanceStatusSvc   = "SVC"   // service 环境已完成
	InstanceStatusALB   = "ALB"   // 后端挂载alb
	InstanceStatusUNALB = "UNALB" // 后端挂载alb
	InstanceStatusFail  = "FAIL"  // 异常、失败
)
View Source
const (
	BatchSize = 5
)

Variables

This section is empty.

Functions

func BatchCreate

func BatchCreate(values interface{}, db *gorm.DB) error

func Create

func Create(model interface{}, db *gorm.DB) error

Create insert the value into database

func Delete added in v0.3.0

func Delete(model interface{}, db *gorm.DB) (int64, error)

Delete delete

func Get

func Get(id int64, out interface{}) error

Get find first record that match given conditions, order by primary key

func Gets

func Gets(ids []int64, out interface{}) error

Gets find records that match given conditions

func Query

func Query(where map[string]interface{}, page int, pageSize int, models interface{}, order string, fields []string, withCount bool) (count int64, err error)

Query records

func QueryAll

func QueryAll(where map[string]interface{}, models interface{}, order string, fields []string) (err error)

QueryAll records

func QueryFirst

func QueryFirst(where map[string]interface{}, model interface{}) (err error)

func QueryLast

func QueryLast(where map[string]interface{}, model interface{}) (err error)

func QueryLimit

func QueryLimit(where map[string]interface{}, models interface{}, order string, fields []string, limitCnt int) (err error)

func Save

func Save(model interface{}, db *gorm.DB) error

Save update value in database, if the value doesn't have primary key, will insert it

func Updates

func Updates(model interface{}, where map[string]interface{}, updates map[string]interface{}, db *gorm.DB) (int64, error)

func UpdatesByIds

func UpdatesByIds(model interface{}, ids []int64, updates map[string]interface{}, db *gorm.DB) error

UpdatesByIds update attributes with callbacks

Types

type Instance

type Instance struct {
	Id               int64                `gorm:"column:id" json:"id"`
	TaskId           int64                `gorm:"column:task_id" json:"task_id"`
	InstanceId       string               `gorm:"column:instance_id" json:"instance_id"`
	ServiceClusterId int64                `gorm:"column:service_cluster_id" json:"service_cluster_id"`
	InstanceStatus   types.InstanceStatus `gorm:"column:instance_status" json:"instance_status"`
	IpInner          string               `gorm:"column:ip_inner"  json:"ip_inner"`
	IpOuter          string               `gorm:"column:ip_outer" json:"ip_outer"`
	Msg              string               `gorm:"column:msg" json:"msg"`
	CreateAt         *time.Time           `gorm:"column:create_at" json:"create_at"`
	UpdateAt         *time.Time           `gorm:"column:update_at" json:"update_at"`
}

Instance 内实例信息

func (*Instance) TableName

func (t *Instance) TableName() string

type InstrRecord

type InstrRecord struct {
	Id          int64      `gorm:"column:id" json:"id"`
	TaskId      int64      `gorm:"column:task_id" json:"task_id"`
	InstrStatus string     `gorm:"column:instr_status" json:"instr_status"`
	Msg         string     `gorm:"column:msg" json:"msg"`
	InstrId     int64      `gorm:"column:instr_id" json:"instr_id"`
	CreateAt    *time.Time `gorm:"column:create_at" json:"create_at"`
	UpdateAt    *time.Time `gorm:"column:update_at" json:"update_at"`
}

func (*InstrRecord) TableName

func (t *InstrRecord) TableName() string

type Instruction

type Instruction struct {
	Id          int64        `gorm:"column:id" json:"id"`
	Cmd         string       `gorm:"column:cmd" json:"cmd"`
	Params      string       `gorm:"column:params" json:"params"`
	InstrAction types.Action `gorm:"column:instr_action" json:"instr_action"`
	TmplId      int64        `gorm:"column:tmpl_id" json:"tmpl_id"`
	IsDeleted   int8         `gorm:"column:is_deleted" json:"is_deleted"`
	CreateAt    *time.Time   `gorm:"column:create_at" json:"create_at"`
	UpdateAt    *time.Time   `gorm:"column:update_at" json:"update_at"`
}

func (*Instruction) TableName

func (t *Instruction) TableName() string

type Integration added in v0.3.0

type Integration struct {
	Id       int64      `json:"id" gorm:"id"`
	Host     string     `json:"host" gorm:"host"`
	Account  string     `json:"account" gorm:"account"`
	Password string     `json:"-" gorm:"password"`
	Type     string     `json:"type" gorm:"type"`
	CreateAt *time.Time `json:"create_at" gorm:"create_at"`
	UpdateAt *time.Time `json:"update_at" gorm:"update_at"`
	CreateBy string     `json:"create_by" gorm:"create_by"`
	UpdateBy string     `json:"update_by" gorm:"update_by"`
}

func (*Integration) TableName added in v0.3.0

func (t *Integration) TableName() string

type RelationTaskId

type RelationTaskId struct {
	BridgxTaskId  int64 `json:"bridgx_task_id"`
	NodeactTaskId int64 `json:"nodeact_task_id"`
}

type ScheduleTemplate

type ScheduleTemplate struct {
	Id                 int64                 `gorm:"primaryKey;column:id" json:"id"`
	TmplName           string                `gorm:"column:tmpl_name" json:"tmpl_name"`
	ServiceName        string                `gorm:"column:service_name" json:"service_name"`
	ServiceClusterId   int64                 `gorm:"column:service_cluster_id" json:"service_cluster_id"`
	BridgxClusname     string                `gorm:"column:bridgx_clusname" json:"bridgx_clusname"` // bridgx 的 cluster name
	DeployMode         string                `gorm:"column:deploy_mode" json:"deploy_mode"`
	Description        string                `gorm:"column:description" json:"description"`
	TmplAttrs          string                `gorm:"column:tmpl_attrs" json:"tmpl_attrs"`
	InstrGroup         string                `gorm:"column:instr_group" json:"instr_group"`
	ScheduleType       constant.ScheduleType `gorm:"column:schedule_type" json:"schedule_type"`
	ReverseSchedTmplId int64                 `gorm:"column:reverse_sched_tmpl_id" json:"reverse_sched_tmpl_id"`
	IsDeleted          soft_delete.DeletedAt `gorm:"softDelete:flag;column:is_deleted" json:"is_deleted"`
	CreateAt           *time.Time            `gorm:"column:create_at" json:"create_at"`
	UpdateAt           *time.Time            `gorm:"column:update_at" json:"update_at"`
}

func (*ScheduleTemplate) TableName

func (t *ScheduleTemplate) TableName() string

type Service

type Service struct {
	Id          int64                 `gorm:"column:id" json:"id"`
	ServiceName string                `gorm:"column:service_name" json:"service_name"`
	Description string                `gorm:"column:description" json:"description"`
	Language    string                `gorm:"column:language" json:"language"`
	Domain      string                `gorm:"column:domain" json:"domain"`
	Port        string                `gorm:"column:port" json:"port"`
	GitRepo     string                `gorm:"column:git_repo" json:"git_repo"`
	IsDeleted   soft_delete.DeletedAt `gorm:"softDelete:flag;column:is_deleted" json:"is_deleted"`
	CreateAt    *time.Time            `gorm:"column:create_at" json:"create_at"` // 加 * 是为类触 mysql NOT NULL DEFAULT CURRENT_TIMESTAMP 属性
	UpdateAt    *time.Time            `gorm:"column:update_at" json:"update_at"`
}

func (*Service) TableName

func (t *Service) TableName() string

type ServiceCluster

type ServiceCluster struct {
	Id            int64      `gorm:"primaryKey;column:id" json:"id"`
	ServiceName   string     `gorm:"column:service_name" json:"service_name"`
	ClusterName   string     `gorm:"column:cluster_name" json:"cluster_name"`
	BridgxCluster string     `gorm:"bridgx_cluster" json:"bridgx_cluster"`
	AutoDecision  string     `gorm:"column:auto_decision" json:"auto_decision"`
	CreateAt      *time.Time `gorm:"column:create_at" json:"create_at"`
	UpdateAt      *time.Time `gorm:"column:update_at" json:"update_at"`
}

func (*ServiceCluster) TableName

func (t *ServiceCluster) TableName() string

type Task

type Task struct {
	Id             int64      `gorm:"column:id" json:"id"`
	SchedTmplId    int64      `gorm:"column:sched_tmpl_id" json:"sched_tmpl_id"`
	Operator       string     `gorm:"column:operator" json:"operator"`
	RelationTaskId string     `gorm:"column:relation_task_id" json:"relation_task_id"`
	TaskStatus     string     `gorm:"column:task_status" json:"task_status"`
	TaskStep       string     `gorm:"column:task_step" json:"task_step"`
	InstCnt        int64      `gorm:"column:inst_cnt" json:"inst_cnt"`    // 本次任务操作的实例数量
	ExecType       string     `gorm:"column:exec_type" json:"exec_type'"` // 执行方式 manual | auto
	Msg            string     `gorm:"column:msg" json:"msg"`
	TaskInfo       string     `gorm:"column:task_info" json:"task_info"`
	BeginAt        time.Time  `gorm:"column:begin_at" json:"begin_at"`
	FinishAt       *time.Time `gorm:"column:finish_at" json:"finish_at"`
	CreateAt       *time.Time `gorm:"column:create_at" json:"create_at"`
	UpdateAt       *time.Time `gorm:"column:update_at" json:"update_at"`
}

func (*Task) TableName

func (t *Task) TableName() string

Jump to

Keyboard shortcuts

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