Documentation ¶
Index ¶
- Variables
- func AddJob(spec string, job *Job) bool
- func AddJobFunc()
- func AdminCreateOrUpdate(adminJ *AdminRequest) error
- func BanList() (interface{}, error)
- func DelAdminLoginData(userId int) bool
- func EditBan(data []string, id string) error
- func ExecuteTask(taskId int) error
- func GetCounter(key string) int
- func GetEntryById(taskId int) bool
- func GetRouteData() (map[int]*RouteCache, error)
- func GetUserRouteById(userId int) []interface{}
- func Init()
- func InitJobs()
- func IsBan(order string) error
- func NotifyCreateOrUpdate(data *NotifyTplDetail, adminId int) error
- func NotifyDelete(NotifyTplId int) error
- func PushMessage(message *MessageData) error
- func PushTakRunLog(log *TaskRunLog) error
- func RedisDataReload(funcList ...string)
- func RefreshLogin(userId int) error
- func RemoteAgent(servers *models.TaskServers) error
- func RemoteCommandByKey(servers *models.TaskServers) error
- func RemoteCommandByPassword(servers *models.TaskServers) error
- func RemoteCommandByTelnetPassword(servers *models.TaskServers) error
- func RoleCreateOrUpdate(roleJ *RoleRequest) error
- func RoleDelete(roleId int) error
- func RouteCreateOrUpdate(params *RouteDetail) error
- func RouteDelete(routeId int) int
- func RouteEdit(routeParams *RouteEditParams) int
- func RunServer(j *Job) bool
- func ServersCreateOrUpdate(params *ServersDetail) error
- func ServersDelete(routeId int) error
- func SetAdminLoginData(data *models.Admin, Role string) bool
- func SetCounter(key string)
- func SetRoleData() (map[int]*RoleCache, error)
- func SetRouteData() (map[int]*RouteCache, error)
- func SetRouteSort(routeId int, sort int16) error
- func SetTaskState(taskId int, status int8) error
- func TaskAudit(taskId int, audit int8) error
- func TaskCreateOrUpdate(params *TaskDetail, userId int) error
- func TaskDelete(taskId int) error
- func TaskLogGather()
- func TestServer(server *models.TaskServers) error
- type AdminBrief
- type AdminData
- type AdminDataValid
- type AdminDetail
- type AdminListData
- type AdminLoginData
- type AdminLoginRedisData
- type AdminLoginValid
- type AdminParams
- type AdminRequest
- type AdminUpdateDataValid
- type BanListData
- type BanListFind
- type DataCount
- type IndexData
- type Job
- func NewCommandJob(id int, serverId int, name string, command string) *Job
- func NewJobFromTask(task *models.Task) ([]*Job, error)
- func RemoteCommandJob(id int, serverId int, name string, command string, servers *models.TaskServers) *Job
- func RemoteCommandJobByAgentPassword(id int, serverId int, name string, command string, servers *models.TaskServers) *Job
- func RemoteCommandJobByPassword(id int, serverId int, name string, command string, servers *models.TaskServers) *Job
- func RemoteCommandJobByTelnetPassword(id int, serverId int, name string, command string, servers *models.TaskServers) *Job
- type JobResult
- type Menu
- type MenuData
- type MessageData
- type MessageRes
- type Meta
- type NotifyData
- type NotifyTplBrief
- type NotifyTplDetail
- type NotifyTplListData
- type NotifyTplOperation
- type NotifyTplParams
- type NotifyTypeDetail
- type RoleCache
- type RoleData
- type RoleDataTree
- type RoleDetail
- type RoleListData
- type RoleParams
- type RoleRequest
- type RouteCache
- type RouteDataTree
- type RouteDetail
- type RouteEditParams
- type RouteListData
- type RouteOperation
- type RouteParams
- type RpcResult
- type RunData
- type RunTimeList
- type ServersData
- type ServersDetail
- type ServersListData
- type ServersParams
- type TaskData
- type TaskDetail
- type TaskListData
- type TaskLogData
- type TaskLogListData
- type TaskLogParams
- type TaskOperation
- type TaskParams
- type TaskRunLog
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Counter sync.Map
)
调度计数器
View Source
var (
CronParse = cron.NewParser(options)
)
View Source
var (
NotifyTypeList = map[int8]NotifyTypeDetail{
1: {Id: 1, NotifyName: "邮件"},
}
)
View Source
var ServersGroupList = map[int]map[string]interface{}{
1: {"id": 1, "group_name": "内网服务器"},
2: {"id": 2, "group_name": "外网服务器"},
}
View Source
var TaskGroupList = map[int]map[string]interface{}{
1: {"id": 1, "group_name": "服务器任务"},
2: {"id": 2, "group_name": "业务层任务"},
}
Functions ¶
func GetCounter ¶
func GetEntryById ¶
func NotifyCreateOrUpdate ¶
func NotifyCreateOrUpdate(data *NotifyTplDetail, adminId int) error
创建或者新增
func NotifyDelete ¶
func PushMessage ¶
func PushMessage(message *MessageData) error
func PushTakRunLog ¶
func PushTakRunLog(log *TaskRunLog) error
func RemoteAgent ¶
func RemoteAgent(servers *models.TaskServers) error
func RemoteCommandByKey ¶
func RemoteCommandByKey(servers *models.TaskServers) error
func RemoteCommandByPassword ¶
func RemoteCommandByPassword(servers *models.TaskServers) error
func RemoteCommandByTelnetPassword ¶
func RemoteCommandByTelnetPassword(servers *models.TaskServers) error
func RoleDelete ¶
func RouteDelete ¶
func RouteEdit ¶
func RouteEdit(routeParams *RouteEditParams) int
func ServersDelete ¶
func SetCounter ¶
func SetCounter(key string)
Types ¶
type AdminBrief ¶
type AdminDataValid ¶
type AdminDataValid struct { UserName string `valid:"Required;MinSize(5);MaxSize(32)"` Password string `valid:"Required;Length(32)"` RealName string `valid:"Required;MinSize(2);MaxSize(10)"` Birthday string `valid:"Required"` Phone string `valid:"Required;Phone"` Email string `valid:"Required;Email"` Sex int8 `valid:"Required;Range(0,2)"` Status int8 `valid:"Required;Range(0,2)"` RoleId int `valid:"Required"` RouteIds string `valid:"MaxSize(200)"` }
Admin 用户数据校验--注册
type AdminDetail ¶
type AdminDetail struct { UserId int `json:"user_id"` Username string `json:"username"` RealName string `json:"real_name"` Status int8 `json:"status"` Birthday string `json:"birthday"` Phone string `json:"phone"` Email string `json:"email"` Sex int8 `json:"sex"` RoleId int `json:"role_id"` RouteIds string `json:"route_ids"` Introduction string `json:"introduction"` }
type AdminListData ¶
type AdminLoginData ¶
type AdminLoginData struct { UserId int `json:"user_id"` //用户id RealName string `json:"real_name"` //用户名称 Sex int8 `json:"sex"` //性別 Token string `json:"token"` //秘钥 Introduction string `json:"introduction"` //描述 Menu *Menu `json:"menu"` // 菜单 }
Admin 用户登录返回值
func AdminReLogin ¶
重新登录
type AdminLoginRedisData ¶
type AdminLoginRedisData struct { UserId int `json:"user_id"` //用户id RealName string `json:"real_name"` //姓名 Birthday int `json:"birthday"` //出生日期时间戳 Phone string `json:"phone"` //手机号码 Sex int8 `json:"sex"` //性别 RoleId int `json:"role_id"` //角色id Role string `json:"role"` //角色 RouteIds string `json:"route_ids"` //路由id Introduction string `json:"introduction"` //介绍 }
Admin 管理员-登录redis缓存数据
type AdminLoginValid ¶
type AdminLoginValid struct { UserName string `valid:"Required;MinSize(5);MaxSize(32)"` Password string `valid:"Required;Length(32)"` }
Admin 用户登录校验
type AdminParams ¶
type AdminRequest ¶
type AdminRequest struct { UserId int `json:"user_id"` //用户id UserName string `json:"username"` //用户名 PassWord string `json:"password"` //密码 RealName string `json:"real_name"` //姓名 Birthday string `json:"birthday"` //出生日期 Status int8 `json:"status"` //状态 IsDelete int8 `json:"is_delete"` //是否删除 Phone string `json:"phone"` //手机号码 Email string `json:"email"` //邮箱 Sex int8 `json:"sex"` //性别 RoleId int `json:"role_id"` //角色id Ip string `json:"ip"` //ip地址 Introduction string `json:"introduction"` //描述 RouteIds string `json:"route_ids"` //路由id }
Admin 管理员-请求数据
type AdminUpdateDataValid ¶
type AdminUpdateDataValid struct { UserId int `valid:"Required"` RealName string `valid:"Required;MinSize(2);MaxSize(10)"` Birthday string `valid:"Required"` Phone string `valid:"Required;Phone"` Email string `valid:"Required;Email"` Sex int8 `valid:"Required;Range(0,2)"` RoleId int `valid:"Required"` RouteIds string `valid:"MaxSize(200)"` }
Admin 用户数据校验--修改
type BanListData ¶
type BanListFind ¶
type DataCount ¶
type DataCount struct { ActualData []int64 `json:"actual_data"` DateData []string `json:"date_data"` Total int64 `json:"total"` }
总用户数
type IndexData ¶
type IndexData struct { UserCount DataCount `json:"user_count"` AuditTask DataCount `json:"audit_task"` SuccessTask DataCount `json:"success_task"` FailTask DataCount `json:"fail_task"` }
首页统计数据
func GetIndexData ¶
type Job ¶
type Job struct { Id int // taskID LogId interface{} // 日志记录ID ServerId int // 执行器信息 ServerName string // 执行器名称 ServerType int8 // 执行器类型, 0-ssh 1-telnet 2-agent Name string // 任务名称 Task *models.Task // 任务对象 RunFunc func(time.Duration) *JobResult // 执行函数 Status int // 任务状态,大于0表示正在执行中 Concurrent bool // 同一个任务是否允许并行执行 }
func NewCommandJob ¶
生成一个指定任务
func RemoteCommandJob ¶
func RemoteCommandJob(id int, serverId int, name string, command string, servers *models.TaskServers) *Job
远程执行任务 密钥验证
type MenuData ¶
type MenuData struct { Id int `json:"-"` ParentId int `json:"-"` //父id Path string `json:"path"` //路径 Redirect string `json:"redirect"` //重定向 Name string `json:"name"` //唯一标识 Meta Meta `json:"meta,omitempty"` //meta信息 Hidden int8 `json:"hidden"` //是否显示 Component string `json:"component"` //view地址 Child []*MenuData `json:"children,omitempty"` //子节点 }
type MessageData ¶
type MessageRes ¶
func SendMsg ¶
func SendMsg(data *MessageData) (res *MessageRes, err error)
type NotifyData ¶
type NotifyData struct { AdminList []AdminBrief `json:"admin_list,omitempty"` NotifyType []NotifyTypeDetail `json:"notify_type,omitempty"` NotifyTpl []NotifyTplBrief `json:"notify_tpl,omitempty"` }
func GetNotifyData ¶
func GetNotifyData(expand string) NotifyData
type NotifyTplBrief ¶
type NotifyTplDetail ¶
type NotifyTplDetail struct { Id int `json:"id"` TplName string `json:"tpl_name" valid:"Required;"` NotifyType int8 `json:"notify_type" valid:"Required;"` NotifyTypeName string `json:"notify_type_name"` TplData string `json:"tpl_data,omitempty" valid:"Required;MaxSize(500)" ` Status int8 `json:"status"` Ctime int `json:"ctime,omitempty"` Utime int `json:"utime,omitempty"` }
func NotifyDetailById ¶
func NotifyDetailById(id int) (NotifyTplDetail, error)
func (*NotifyTplDetail) Valid ¶
func (tpl *NotifyTplDetail) Valid(v *validation.Validation)
type NotifyTplListData ¶
type NotifyTplListData struct { Total int64 `json:"total"` List []NotifyTplDetail `json:"list"` }
查询返回数据
func NotifyTplList ¶
func NotifyTplList(params *NotifyTplParams) (error, NotifyTplListData)
type NotifyTplOperation ¶
type NotifyTypeDetail ¶
type RoleData ¶
type RoleDataTree ¶
type RoleDetail ¶
type RoleDetail struct { Id int `json:"role_id"` RoleName string `json:"role_name"` Role string `json:"role"` ParentId int `json:"parent_id"` RouteIds string `json:"route_ids"` Status int8 `json:"status"` IsDelete int8 `json:"is_delete"` Ctime int `json:"ctime,omitempty"` Utime int `json:"utime,omitempty"` }
func RoleDetailById ¶
func RoleDetailById(roleId int) (*RoleDetail, error)
type RoleListData ¶
type RoleListData struct { Total int64 `json:"total"` //角色数量 List []*RoleDataTree `json:"list"` // 角色列表 }
查询返回数据
type RoleRequest ¶
type RoleRequest struct { RoleId int `json:"role_id"` //角色id Role string `json:"role" valid:"Required;MaxSize(32)"` //角色 RoleName string `json:"role_name" valid:"Required;MaxSize(32)"` //角色名称 ParentId int `json:"parent_id"` //父级id Status int8 `json:"status"` //状态 IsDelete int8 `json:"is_delete"` //删除状态 }
Role 角色-请求数据
type RouteCache ¶
type RouteDataTree ¶
type RouteDataTree struct { Id int `json:"route_id"` ParentId int `json:"parent_id"` //父id RouteName string `json:"route_name"` //路由名称 Route string `json:"route"` //路由 Request string `json:"request"` //请求方式 Status int8 `json:"status"` //状态 Sort int16 `json:"sort"` //排序 Child []*RouteDataTree `json:"children,omitempty"` //子节点 }
type RouteDetail ¶
type RouteDetail struct { Id int `json:"route_id"` RouteName string `json:"route_name" valid:"Required;MaxSize(32)"` Route string `json:"route" valid:"Required;MaxSize(50)"` Request string `json:"request" valid:"MaxSize(10)"` ParentId int `json:"parent_id,omitempty"` Component string `json:"component"` Title string `json:"title"` Path string `json:"path"` Name string `json:"name"` Redirect string `json:"redirect"` Hidden int8 `json:"hidden"` Icon string `json:"icon"` Extra string `json:"extra"` Sort int16 `json:"sort"` IsRoute int8 `json:"is_route"` Status int8 `json:"status"` Ctime int `json:"ctime,omitempty"` Utime int `json:"utime,omitempty"` }
func RouteAll ¶
func RouteAll() []*RouteDetail
func RouteDetailById ¶
func RouteDetailById(routeId int) (*RouteDetail, error)
func (*RouteDetail) Valid ¶
func (data *RouteDetail) Valid(v *validation.Validation)
type RouteListData ¶
type RouteListData struct { Total int64 `json:"total"` //路由总数 List []*RouteDataTree `json:"list"` // 路由列表 }
查询返回数据
func RouteList ¶
func RouteList(routeJ *RouteParams) (error, *RouteListData)
type RouteOperation ¶
type ServersData ¶
type ServersData struct { Id int `json:"server_id"` GroupName string `json:"group_name"` //分組名名称 ServerName string `json:"server_name"` //服务器名称 ConnectionType int8 `json:"connection_type"` //连接方式 ServerIp string `json:"server_ip"` //连接ip Port int `json:"port"` //端口 Detail string `json:"detail"` //备注 Status int8 `json:"status"` //状态 Ctime int `json:"ctime"` //创建时间 Utime int `json:"utime"` //修改时间 }
type ServersDetail ¶
type ServersDetail struct { ServerId int `json:"server_id"` GroupId int `json:"group_id" valid:"Required;"` //服务器id ConnectionType int8 `json:"connection_type" valid:"Range(0,1)"` //连接方式 ServerName string `json:"server_name" valid:"Required;"` //服务器名称 Port int `json:"port" valid:"Required;"` //端口 ServerIp string `json:"server_ip" valid:"Required;IP"` //服务器id ServerAccount string `json:"server_account"` //服务器账号 Password string `json:"password"` //密码 PrivateKeySrc string `json:"private_key_src"` //私钥路径 PublicKeySrc string `json:"public_key_src"` //公钥路径 Type int8 `json:"type" valid:"Range(0,1)"` //登录类型 Detail string `json:"detail" valid:"Required;"` //备注 Status int8 `json:"status" valid:"Required;Range(0,1)"` //状态 Ctime int `json:"ctime,omitempty"` Utime int `json:"utime,omitempty"` }
func ServersDetailById ¶
func ServersDetailById(serverId int) (*ServersDetail, error)
func (*ServersDetail) Valid ¶
func (s *ServersDetail) Valid(v *validation.Validation)
type ServersListData ¶
type ServersListData struct { Total int64 `json:"total"` //資源服務器总数 List []*ServersData `json:"list"` // 資源服務器列表 }
查询返回数据
type TaskData ¶
type TaskData struct { Id int `json:"task_id"` GroupId int `json:"group_id"` GroupName string `json:"group_name"` RunType int8 `json:"run_type"` TaskName string `json:"task_name"` CronSpec string `json:"cron_spec"` Concurrent int8 `json:"concurrent"` ExecuteTimes int `json:"execute_times"` PrevTime int `json:"prev_time,omitempty"` NextTime int `json:"next_time,omitempty"` IsAudit int8 `json:"is_audit"` Status int8 `json:"status"` Ctime int `json:"ctime"` Utime int `json:"utime"` }
type TaskDetail ¶
type TaskDetail struct { TaskId int `json:"task_id"` GroupId int `json:"group_id" valid:"Required;"` ServerIds string `json:"server_ids" valid:"Required;"` RunType int8 `json:"run_type" valid:"Required;"` TaskName string `json:"task_name" valid:"Required;"` Description string `json:"description" valid:"Required;"` CronSpec string `json:"cron_spec" valid:"Required;"` Concurrent int8 `json:"concurrent"` Command string `json:"command" valid:"Required;"` Timeout int `json:"timeout"` IsNotify int8 `json:"is_notify"` NotifyType int8 `json:"notify_type"` NotifyTplId int `json:"notify_tpl_id"` NotifyUserIds string `json:"notify_user_ids"` IsAudit int8 `json:"is_audit"` UpdateId int `json:"update_id"` CreateId int `json:"create_id"` Status int8 `json:"status"` Ctime int `json:"-"` Utime int `json:"-"` }
Task
func TaskDetailById ¶
func TaskDetailById(taskId int) (*TaskDetail, error)
func (*TaskDetail) Valid ¶
func (task *TaskDetail) Valid(v *validation.Validation)
type TaskLogData ¶
type TaskLogData struct { Id string `json:"id"` TaskId int `json:"task_id"` ServerId int `json:"server_id"` ServerName string `json:"server_name"` Output string `json:"output"` Error string `json:"error"` Status int8 `json:"status"` ProcessTime int `json:"process_time"` Ctime int `json:"ctime"` TaskInfo TaskDetail `json:"task_info"` }
func TaskLogDetailById ¶
func TaskLogDetailById(LogId string) (*TaskLogData, error)
type TaskLogListData ¶
type TaskLogListData struct { Total int64 `json:"total"` List []*TaskLogData `json:"list"` }
func TaskLogList ¶
func TaskLogList(params *TaskLogParams) (error, *TaskLogListData)
type TaskLogParams ¶
type TaskOperation ¶
type TaskRunLog ¶
type TaskRunLog struct { TaskId int `json:"task_id"` ServerId int `json:"server_id"` ServerName string `json:"server_name"` Output string `json:"output"` Error string `json:"error"` Status int8 `json:"status"` ProcessTime int `json:"process_time"` Ctime int `json:"ctime"` }
定时任务任务日志
Click to show internal directories.
Click to hide internal directories.