Documentation ¶
Overview ¶
Package models 为项目所需的模型对象定义.
Index ¶
- Variables
- type Member
- type Relation
- func (m *Relation) Delete() error
- func (m *Relation) DeleteByWhere(where string, args ...interface{}) error
- func (m *Relation) Find(id int) error
- func (m *Relation) QueryByWebHookId(webHookId int, memberId int) ([]*ServerRelation, error)
- func (m *Relation) Save() error
- func (m *Relation) TableEngine() string
- func (m *Relation) TableName() string
- type RelationDetailed
- type Scheduler
- func (m *Scheduler) DeleteByWhere(where string, args ...interface{}) error
- func (m *Scheduler) Find() error
- func (m *Scheduler) InsertMulti(schedulers []Scheduler) (int64, error)
- func (m *Scheduler) QuerySchedulerByState(state ...string) ([]Scheduler, error)
- func (m *Scheduler) Save() error
- func (m *Scheduler) TableEngine() string
- func (m *Scheduler) TableName() string
- func (m *Scheduler) ToWebScheduler() WebScheduler
- type Server
- func (m *Server) Delete() error
- func (m *Server) Find() error
- func (m *Server) QueryServerByServerId(serverIds []int, memberId ...int) ([]*Server, error)
- func (m *Server) Save() error
- func (m *Server) Search(keyword string, memberId int, excludeServerId ...int) ([]Server, error)
- func (m *Server) TableEngine() string
- func (m *Server) TableName() string
- type ServerRelation
- type WebHook
- type WebScheduler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMemberNoExist 用户不存在. ErrMemberNoExist = errors.New("用户不存在") // ErrorMemberPasswordError 密码错误. ErrorMemberPasswordError = errors.New("用户密码错误") // ErrServerAlreadyExist 指定的服务已存在. ErrServerAlreadyExist = errors.New("服务已存在") // ErrInvalidParameter 参数错误. ErrInvalidParameter = errors.New("Invalid parameter") )
Functions ¶
This section is empty.
Types ¶
type Member ¶
type Member struct { MemberId int `orm:"pk;auto;unique;column(member_id)"` Account string `orm:"size(255);column(account)"` Password string `orm:"size(1000);column(password)"` Email string `orm:"size(255);column(email);null;default(null)"` Phone string `orm:"size(255);column(phone);null;default(null)"` Avatar string `orm:"size(1000);column(avatar)"` Role int `orm:"column(role);type(int);default(1)"` //用户角色:0 管理员/1 普通用户 Status int `orm:"column(status);type(int);default(0)"` //用户状态:0 正常/1 禁用 CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add"` CreateAt int `orm:"type(int);column(create_at)"` LastLoginTime time.Time `orm:"type(datetime);column(last_login_time);null"` }
Member 会员信息.
type Relation ¶
type Relation struct { RelationId int `orm:"pk;auto;unique;column(relation_id)" json:"relation_id"` WebHookId int `orm:"type(int);column(web_hook_id)" json:"web_hook_id"` ServerId int `orm:"type(int);column(server_id)" json:"server_id"` MemberId int `orm:"type(int);column(member_id)" json:"member_id"` CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` //添加时间 }
Relation WebHook和Server之间关系
func (*Relation) DeleteByWhere ¶
DeleteByWhere 删除指定用户的服务和WebHook的关系
func (*Relation) QueryByWebHookId ¶
func (m *Relation) QueryByWebHookId(webHookId int, memberId int) ([]*ServerRelation, error)
QueryByWebHookId 查找指定用户的服务和WebHook简单关系
type RelationDetailed ¶
type RelationDetailed struct { RelationId int `json:"relation_id"` MemberId int `json:"member_id"` WebHookId int `json:"web_hook_id" orm:"column(web_hook_id)"` RepositoryName string `json:"repository_name"` BranchName string `json:"branch_name"` ServerId int `json:"server_id"` WebHookTag string `json:"web_hook_tag"` Shell string `json:"shell"` WebHookStatus int `json:"web_hook_status"` Key string `json:"key"` Secure string `json:"secure"` HookType string `json:"hook_type"` //服务类型 ServerName string `json:"server_name"` ServerType string `json:"server_type"` IpAddress string `json:"ip_address"` Port int `json:"port"` Account string `json:"account"` PrivateKey string `json:"-"` ServerTag string `json:"server_tag"` ServerStatus int `json:"server_status"` }
RelationDetailed 包含 WebHook 和 Server 信息的关系实体
func FindRelationDetailedByWhere ¶
func FindRelationDetailedByWhere(where string, params ...interface{}) ([]RelationDetailed, error)
FindRelationDetailedByWhere 指定条件查询完整的关系对象
type Scheduler ¶
type Scheduler struct { SchedulerId int `orm:"pk;auto;unique;column(scheduler_id)" json:"scheduler_id"` WebHookId int `orm:"type(int);column(web_hook_id)" json:"web_hook_id"` ServerId int `orm:"type(int);column(server_id)" json:"server_id"` RelationId int `orm:"type(int);column(relation_id)" json:"relation_id"` Status string `orm:"column(status);default(wait)" json:"status"` //状态:wait 等待执行/executing 执行中/suspend 中断执行/ failure 执行失败/ success 执行成功 CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` //添加时间 StartExecTime time.Time `orm:"type(datetime);column(start_exec_time);null" json:"start_exec_time"` //开始执行时间 EndExecTime time.Time `orm:"type(datetime);column(end_exec_time);null" json:"end_exec_time"` //执行结束时间 Data string `orm:"type(text);column(data)" json:"-"` //推送的数据 PushUser string `orm:"column(push_user);null;size(255)" json:"push_user"` //推送用户 ShaValue string `orm:"column(sha_value);null;size(255)" json:"sha_value"` //当前请求的sha值 LogContent string `orm:"column(log_content);type(text);" json:"log_content"` ExecuteType int `orm:"column(execute_type);type(int);default(0)" json:"execute_type"` //执行方式:0 自动触发 / 1 手动执行 }
Scheduler 任务调度器储存表
func (*Scheduler) DeleteByWhere ¶
DeleteByWhere 根据条件删除
func (*Scheduler) InsertMulti ¶
InsertMulti 批量插入对象
func (*Scheduler) QuerySchedulerByState ¶
QuerySchedulerByState 根据状态查询
func (*Scheduler) ToWebScheduler ¶
func (m *Scheduler) ToWebScheduler() WebScheduler
ToWebScheduler 转换为前端可用的优化信息对象
type Server ¶
type Server struct { ServerId int `orm:"pk;auto;unique;column(server_id)" json:"server_id"` Name string `orm:"size(255);column(name)" json:"name"` Type string `orm:"size(255);column(type);default(ssh)" json:"type"` IpAddress string `orm:"size(255);column(ip_address)" json:"ip_address"` Port int `orm:"type(int);column(port)" json:"port"` Account string `orm:"size(255);column(account)" json:"account"` PrivateKey string `orm:"type(text);column(private_key)" json:"private_key"` Tag string `orm:"size(1000);column(tag)" json:"tag"` Status int `orm:"type(int);column(status);default(0)" json:"status"` CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` CreateAt int `orm:"type(int);column(create_at)" json:"-"` }
服务器对象
func (*Server) QueryServerByServerId ¶
根据server_id和用户id查询服务器信息列表
type ServerRelation ¶
type ServerRelation struct { ServerId int RelationId int WebHookId int MemberId int Status int Name string IpAddress string Port int Type string CreateTime time.Time CreateAt int }
ServerRelation 服务与WebHook简单关系
type WebHook ¶
type WebHook struct { WebHookId int `orm:"pk;auto;unique;column(web_hook_id)" json:"web_hook_id"` RepositoryName string `orm:"size(255);column(repo_name)" json:"repository_name"` BranchName string `orm:"size(255);column(branch_name)" json:"branch_name"` Tag string `orm:"size(1000);column(tag)" json:"tag"` Shell string `orm:"size(1000);column(shell)" json:"shell"` Status int `orm:"type(int);column(status);default(0)" json:"status"` Key string `orm:"size(255);column(key);unique" json:"key"` Secure string `orm:"size(255);column(secure)" json:"secure"` LastExecTime time.Time `orm:"type(datetime);column(last_exec_time);null" json:"last_exec_time"` CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"` HookType string `orm:"column(hook_type);size(50)" json:"hook_type"` CreateAt int `orm:"type(int);column(create_at)"` }
WebHook对象
type WebScheduler ¶
type WebScheduler struct { Scheduler Slogan string `json:"slogan"` Consuming string `json:"consuming"` }
WebScheduler 前端使用的结构体
Click to show internal directories.
Click to hide internal directories.