models

package
v0.0.0-...-4f4919f Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Redis    *zmRedis
	Mysql    *gorm.DB
	InfluxDB *zmInflux
)

Functions

func CreateDeploy

func CreateDeploy(uid int, param *req.DeploySetParam) (err error)

CreateDeploy 创建部署应用

func DelDeploy

func DelDeploy(uid, DeployID int) error

DelDeploy 删除部署应用

func DeployRelationServerIds

func DeployRelationServerIds(deployId int) []int

DeployRelationServerIds 根据应用ID

func GetSysConfig

func GetSysConfig(key string) string

根据Key获取配置

func Start

func Start()

Start 初始化数据

func UpdateDeploy

func UpdateDeploy(uid int, param *req.DeploySetParam) (err error)

UpdateDeploy 更新部署应用

Types

type CommonMap

type CommonMap map[string]interface{}

type Deploy

type Deploy struct {
	ID            int       `gorm:"primary_key;column:id;type:int(10) unsigned;not null" json:"id"`          // 应用唯一编号
	UId           int       `gorm:"index:IX_UID;column:uid;type:int(11);not null" json:"uid"`                // 创建用户UID
	Title         string    `gorm:"column:title;type:varchar(120);not null" json:"title"`                    // 应用名称
	DeployType    int8      `gorm:"column:deploy_type;type:tinyint(1);not null" json:"deploy_type"`          // 部署类型 0-本地 1-git 2-zip 3-docker
	WorkDir       string    `gorm:"column:work_dir;type:varchar(255);not null" json:"work_dir"`              // 工作目录
	BeforeCommand string    `gorm:"column:before_command;type:varchar(2000);not null" json:"before_command"` // 前置命令
	AfterCommand  string    `gorm:"column:after_command;type:varchar(2000);not null" json:"after_command"`   // 后置命令
	NowVersion    int       `gorm:"column:now_version;type:int(10) unsigned;not null" json:"now_version"`    // 当前版本
	OpenID        string    `gorm:"unique;column:open_id;type:char(32);not null" json:"open_id"`             // 应用开放编码(用于hook部署)
	CreateTime    time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
	UpdateTime    time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
}

Deploy 纸喵部署应用表

func DeployList

func DeployList(uid int, param *req.DeployListParam) (result []Deploy, totalRows int)

DeployList 部署应用列表

func (*Deploy) BatchCheck

func (m *Deploy) BatchCheck(ids []int) bool

BatchCheck 批量检测是否是当前用户应用

func (*Deploy) Count

func (m *Deploy) Count() (num int, err error)

Count 统计当前用户部署应用数量

func (*Deploy) CountDo

func (m *Deploy) CountDo() (num int, err error)

Count 统计当前用户调度应用部署次数

func (*Deploy) GetIdByOpenId

func (m *Deploy) GetIdByOpenId() bool

func (*Deploy) GetOpenId

func (m *Deploy) GetOpenId() bool

GetOpenId 获取openid

type DeployDetailInfo

type DeployDetailInfo struct {
	Deploy
	DeployGit    DeployGit    `json:"deploy_git"`
	DeployZip    DeployZip    `json:"deploy_zip"`
	DeployDocker DeployDocker `json:"deploy_docker"`
}

DeployDetailInfo 部署应用信息结构

func GetDeployDetailInfo

func GetDeployDetailInfo(uid, deployId int) (result DeployDetailInfo)

GetDeployDetailInfo 根据服应用ID获取部署应用任务信息

type DeployDocker

type DeployDocker struct {
	DeployID         int       `gorm:"primary_key;column:deploy_id;type:int(10) unsigned;not null" json:"deploy_id"`  // 部署应用编号
	DockerImage      string    `gorm:"column:docker_image;type:varchar(500);not null" json:"docker_image"`            // 资源地址(完整路径)
	UserName         string    `gorm:"column:user_name;type:varchar(255);not null" json:"user_name"`                  // 账号
	Password         string    `gorm:"column:password;type:varchar(255);not null" json:"password"`                    // 密码
	IsRuning         int8      `gorm:"column:is_runing;type:tinyint(1);not null" json:"is_runing"`                    // 是否启动 -1-不启动 1-启动
	ContainerName    string    `gorm:"column:container_name;type:varchar(255);not null" json:"container_name"`        // 容器名称
	ContainerVolumes string    `gorm:"column:container_volumes;type:varchar(1000);not null" json:"container_volumes"` // 地址映射 a:b a宿主机 b容器内
	ContainerPorts   string    `gorm:"column:container_ports;type:varchar(1000);not null" json:"container_ports"`     // 端口暴露 a:b a内部 b外部
	ContainerEnv     string    `gorm:"column:container_env;type:varchar(2000);not null" json:"container_env"`         // 环境变量注入
	CreateTime       time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
	UpdateTime       time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
}

DeployDocker 纸喵部署-docker

type DeployGit

type DeployGit struct {
	DeployID   int       `gorm:"primary_key;column:deploy_id;type:int(10) unsigned;not null" json:"deploy_id"` // 部署应用编号
	RemoteURL  string    `gorm:"column:remote_url;type:varchar(500);not null" json:"remote_url"`               // 资源地址
	DeployPath string    `gorm:"column:deploy_path;type:varchar(500);not null" json:"deploy_path"`             // 本地部署地址
	Branch     string    `gorm:"column:branch;type:varchar(100);not null" json:"branch"`                       // git分支
	DeployKeys string    `gorm:"column:deploy_keys;type:varchar(3000);not null" json:"deploy_keys"`            // 部署私钥
	UserName   string    `gorm:"column:user_name;type:varchar(255);not null" json:"user_name"`                 // 账号
	Password   string    `gorm:"column:password;type:varchar(255);not null" json:"password"`                   // 密码
	CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
}

DeployGit 纸喵部署-git

type DeployRelationServer

type DeployRelationServer struct {
	Server
	DeployServerRelation
}

DeployRelationServer 部署服务器信息

func DeployServerList

func DeployServerList(uid, deployId int) (result []DeployRelationServer, err error)

DeployServerList 可部署服务器列表

type DeployServerRelation

type DeployServerRelation struct {
	DeployID      int       `gorm:"primary_key;column:deploy_id;type:int(11);not null" json:"deploy_id"` // 部署服务id
	ServerID      int       `gorm:"primary_key;column:server_id;type:int(11);not null" json:"server_id"` // 服务器ID
	DeployVersion int       `gorm:"column:deploy_version;type:int(10) unsigned" json:"deploy_version"`   // 已部署版本
	CreateTime    time.Time `gorm:"column:create_time;type:datetime" json:"create_time"`
	UpdateTime    time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
}

DeployServerRelation 部署服务-server关联表

type DeployTaskInfo

type DeployTaskInfo struct {
	Deploy
	DeployGit    DeployGit    `json:"deploy_git"`
	DeployZip    DeployZip    `json:"deploy_zip"`
	DeployDocker DeployDocker `json:"deploy_docker"`
}

DeployTaskInfo 部署应用信息结构

func GetDeployTaskInfo

func GetDeployTaskInfo(serverId int) (result []DeployTaskInfo)

GetDeployTaskInfo 根据服务器ID获取部署应用任务信息

type DeployZip

type DeployZip struct {
	DeployID   int       `gorm:"primary_key;column:deploy_id;type:int(10) unsigned;not null" json:"deploy_id"` // 部署应用编号
	RemoteURL  string    `gorm:"column:remote_url;type:varchar(500);not null" json:"remote_url"`               // 资源地址
	DeployPath string    `gorm:"column:deploy_path;type:varchar(500);not null" json:"deploy_path"`             // 本地部署地址
	Password   string    `gorm:"column:password;type:varchar(255);not null" json:"password"`                   // 密码
	CreateTime time.Time `gorm:"column:create_time;type:datetime;not null" json:"create_time"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime" json:"update_time"`
}

DeployZip 纸喵部署-zip

type Member

type Member struct {
	Id          int       `gorm:"primary_key;column:id;type:int(10) unsigned;not null"`
	Phone       string    `gorm:"unique;column:phone;type:char(11);not null"`         // 手机号
	Password    string    `gorm:"column:password;type:varchar(255);not null"`         // 密码
	InviterUid  int       `gorm:"column:inviter_uid;type:int(10) unsigned;not null"`  // 邀请人UID
	MaxDeploy   int       `gorm:"column:max_deploy;type:int(10) unsigned;not null"`   // 最大部署应用数量
	MaxSchedule int       `gorm:"column:max_schedule;type:int(10) unsigned;not null"` // 最大调度任务数量
	Status      int8      `gorm:"column:status;type:tinyint(1);not null"`             // 0-锁定 1-正常
	CreateTime  time.Time `gorm:"column:create_time;type:datetime;not null"`
	UpdateTime  time.Time `gorm:"column:update_time;type:datetime;not null"`
}

Member 用户表

func (*Member) AddDeployNum

func (m *Member) AddDeployNum(num int) (err error)

AddDeployNum 添加部署任务数量

func (*Member) AddScheduleNum

func (m *Member) AddScheduleNum(num int) (err error)

AddScheduleNum 添加调度任务数量

func (*Member) InviterCount

func (m *Member) InviterCount() (num int, err error)

Count 统计当前用户邀请人数

func (*Member) MaxInfo

func (m *Member) MaxInfo() (err error)

MaxInfo 获取限制信息

type ModelBase

type ModelBase struct {
	Num int
	Has bool
}

type ModelBase1

type ModelBase1 struct {
	Id         int       `xorm:"not null pk autoincr INT(11)"`
	UpdateTime time.Time `xorm:"default 'CURRENT_TIMESTAMP' DATETIME"`
	CreateTime time.Time `xorm:"default 'CURRENT_TIMESTAMP' DATETIME"`
}

type Schedule

type Schedule struct {
	Command      string    `xorm:"not null comment('命令') TEXT"`
	CreateTime   time.Time `xorm:"default 'CURRENT_TIMESTAMP' DATETIME"`
	Crontab      string    `xorm:"not null comment('规则') VARCHAR(50)"`
	Id           int       `xorm:"not null pk autoincr INT(10)"`
	PrevTime     time.Time `gorm:"column:prev_time;type:datetime;default:null"` // 上次执行时间
	NextTime     time.Time `gorm:"column:next_time;type:datetime"`              // 下次执行时间
	Remain       int       `xorm:"not null default -1 comment('剩余执行次数 -1无限 0-停止') INT(11)"`
	ScheduleType int       `xorm:"not null default 1 comment('调度类型 1-serverhttp 2-clientShell') TINYINT(1)"`
	ServerId     int       `xorm:"not null default 0 comment('服务器ID') INT(10)"`
	Timeout      int       `xorm:"not null default 30 comment('超时时间s') INT(10)"`
	Title        string    `xorm:"not null comment('标题') VARCHAR(60)"`
	Uid          int       `xorm:"not null default 0 comment('用户ID') INT(10)"`
	UpdateTime   time.Time `xorm:"default 'CURRENT_TIMESTAMP' DATETIME"`
}

func (*Schedule) Count

func (m *Schedule) Count() (num int, err error)

Count 统计当前用户调度应用数量

func (*Schedule) Create

func (m *Schedule) Create() bool

Create 创建任务

func (*Schedule) Del

func (m *Schedule) Del() bool

Del 删除计划任务

func (*Schedule) ExportList

func (m *Schedule) ExportList(lastId int, scheduleType int) ([]Schedule, int)

ExportList 数据输出

func (*Schedule) Get

func (m *Schedule) Get() bool

func (*Schedule) List

func (m *Schedule) List(offset int, limit int) ([]Schedule, int)

List 获取任务列表

func (*Schedule) RunCallBack

func (m *Schedule) RunCallBack() bool

func (*Schedule) Save

func (m *Schedule) Save() bool

type Server

type Server struct {
	ApiSecret    string    `xorm:"not null default '' comment('API密钥') VARCHAR(32)"`
	CreateTime   time.Time `xorm:"default 'CURRENT_TIMESTAMP' DATETIME"`
	DeviceId     string    `xorm:"not null comment('服务器唯一设备号') CHAR(36)"`
	Domain       string    `xorm:"not null comment('服务器地址(域名/ip)') VARCHAR(255)"`
	Id           int       `xorm:"not null pk autoincr INT(11)"`
	ServerName   string    `xorm:"not null default '' comment('服务器备注名') VARCHAR(64)"`
	ServerRuleId int       `xorm:"not null default 0 comment('服务器规则id') INT(11)"`
	ServerStatus int       `xorm:"not null default 0 comment('服务器状态 -1-失效 0-待认领 1-已分配通信密钥 2-已绑定') TINYINT(1)"`
	Uid          int       `xorm:"not null comment('用户ID') index INT(10)"`
	UpdateTime   time.Time `xorm:"default 'CURRENT_TIMESTAMP' DATETIME"`
}

func (*Server) BatchCheck

func (m *Server) BatchCheck(ids []int) bool

BatchCheck 批量检测是否是当前用户服务器

func (*Server) Count

func (m *Server) Count() (num int, err error)

Count 统计当前用户客戶端注冊數量

func (*Server) Get

func (m *Server) Get() bool

Get 获取服务器信息

func (*Server) GetApiSecret

func (m *Server) GetApiSecret(id int) (secret string)

GetApiSecret 获取服务器ApiSecret信息

func (*Server) List

func (m *Server) List(offset int, limit int) ([]Server, int)

List 获取应用列表

func (*Server) ListByUser

func (m *Server) ListByUser() []Server

func (*Server) UserServerIds

func (m *Server) UserServerIds() (ids []int)

UserServerIds 获取用户的服务器编号

type SysConfig

type SysConfig struct {
	Key        string    `gorm:"primary_key;column:key;type:varchar(50);not null"`
	Data       string    `gorm:"column:data;type:longtext"`       // 数据
	Readme     string    `gorm:"column:readme;type:varchar(255)"` // 字段说明
	CreateTime time.Time `gorm:"column:create_time;type:datetime"`
	UpdateTime time.Time `gorm:"column:update_time;type:timestamp"`
}

SysConfig 内部回转配置

type Telegraf

type Telegraf struct {
	ServerID   int       `gorm:"primary_key;column:server_id;type:int(11);not null"` // 服务器ID
	UId        int       `gorm:"column:uid;type:int(11)"`                            // 用户ID
	TomlConfig string    `gorm:"column:toml_config;type:longtext"`                   // 私有配置
	IsOpen     int8      `gorm:"column:is_open;type:tinyint(1)"`                     // 是否开启监控功能 1-开启 2-关闭
	CreateTime time.Time `gorm:"column:create_time;type:datetime"`
	UpdateTime time.Time `gorm:"column:update_time;type:datetime"`
}

Telegraf 监控配置表

func (*Telegraf) Get

func (m *Telegraf) Get() bool

根据Key获取配置

Jump to

Keyboard shortcuts

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