Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"apply.go",
"canal.go",
],
importpath = "go-common/app/admin/main/apm/model/canal",
tags = ["automanaged"],
deps = ["//library/time:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,116 @@
package canal
import (
"go-common/library/time"
)
//type and explanation
const (
TypeApply = int8(iota)
TypeReview
ReviewReject
ReviewSuccess
ReviewFailed
)
//TypeMap struct
var (
TypeMap = map[int8]string{
TypeApply: "申请",
TypeReview: "审核",
ReviewReject: "驳回",
ReviewSuccess: "通过",
ReviewFailed: "失败",
}
)
// TableName case tablename
func (*Apply) TableName() string {
return "canal_apply"
}
//Apply apply model
type Apply struct {
ID int `gorm:"column:id" json:"id"`
Addr string `gorm:"column:addr" json:"addr"`
Remark string `gorm:"column:remark" json:"remark"`
Cluster string `gorm:"column:cluster" json:"project"`
Leader string `gorm:"column:leader" json:"leader"`
Comment string `gorm:"column:comment" json:"comment"`
State int8 `gorm:"column:state" json:"status"`
Operator string `gorm:"column:operator" json:"operator"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
ConfID int `gorm:"column:conf_id" json:"conf_id"`
}
//Config struct
type Config struct {
Instance *Instance `json:"instance" toml:"instance"`
}
//Instance struct
type Instance struct {
Caddr string `json:"caddr" toml:"addr"`
User string `json:"user" toml:"user"`
Password string `json:"password" toml:"password"`
MonitorPeriod string `json:"monitor_period" toml:"monitor_period,omitempty"`
ServerID int64 `json:"server_id" toml:"server_id"`
Flavor string `json:"flavor" toml:"flavor"`
HeartbeatPeriod time.Duration `json:"heartbeat_period" toml:"heartbeat_period"`
ReadTimeout time.Duration `json:"read_timeout" toml:"read_timeout"`
DB []*DB `json:"db" toml:"db"`
}
//DB struct
type DB struct {
Schema string `json:"schema" toml:"schema"`
Table []*Table `json:"table" toml:"table"`
Databus *Databus `json:"databus" toml:"databus"`
Infoc *Infoc `json:"infoc" toml:"infoc"`
}
//Table struct
type Table struct {
Name string `json:"name" toml:"name"`
Primarykey []string `json:"primarykey" toml:"primarykey"`
Omitfield []string `json:"omitfield" toml:"omitfield"`
}
//Databus struct
type Databus struct {
Key string `json:"key" toml:"key"`
Secret string `json:"secret" toml:"secret"`
Group string `json:"group" toml:"group"`
Topic string `json:"topic" toml:"topic"`
Action string `json:"action" toml:"action"`
Name string `json:"name" toml:"name"`
Proto string `json:"proto" toml:"proto"`
Addr string `json:"addr" toml:"addr"`
Idle int `json:"idle" toml:"idle"`
Active int `json:"active" toml:"active"`
DialTimeout string `json:"dialTimeout" toml:"dialTimeout"`
ReadTimeout string `json:"readTimeout" toml:"readTimeout"`
WriteTimeout string `json:"writeTimeout" toml:"writeTimeout"`
IdleTimeout string `json:"idleTimeout" toml:"idleTimeout"`
}
//Infoc struct
type Infoc struct {
TaskID string `json:"taskID" toml:"taskID"`
Proto string `json:"proto" toml:"proto"`
Addr string `json:"addr" toml:"addr"`
ReporterAddr string `json:"reporterAddr" toml:"reporterAddr"`
}
//ConfigReq struct is
type ConfigReq struct {
Addr string `form:"addr" validate:"required"`
User string `form:"user"`
Password string `form:"password"`
MonitorPeriod string `form:"monitor_period"`
Databases string `form:"databases" validate:"required"`
Project string `form:"project"`
Leader string `form:"leader"`
Mark string `form:"mark" validate:"required"`
}

View File

@@ -0,0 +1,109 @@
package canal
import (
xtime "go-common/library/time"
)
// TableName case tablename
func (*Canal) TableName() string {
return "master_info"
}
// Canal canal
type Canal struct {
ID int64 `gorm:"column:id" json:"id"`
Addr string `gorm:"column:addr" json:"addr" form:"addr" validate:"required"`
BinName string `gorm:"column:bin_name" json:"bin_name" form:"bin_name"`
BinPos int32 `gorm:"column:bin_pos" json:"bin_pos" form:"bin_pos"`
Remark string `gorm:"column:remark" json:"remark" form:"remark"`
Leader string `gorm:"column:leader" json:"leader" form:"leader"`
Cluster string `gorm:"column:cluster" json:"project" form:"project"`
CTime xtime.Time `gorm:"column:ctime" json:"ctime"`
MTime xtime.Time `gorm:"column:mtime" json:"mtime"`
IsDelete int `gorm:"column:is_delete" json:"is_delete"`
}
//ScanReq canal scan req
type ScanReq struct {
Addr string `form:"addr" validate:"required"`
}
//Results canalscan resp
type Results struct {
ID int64 `json:"id"`
Addr string `json:"addr"`
Cluster string `json:"project"`
Leader string `json:"leader"`
Document *Document `json:"document"`
}
//EditReq canal edit req
type EditReq struct {
ID int64 `form:"id" validate:"required"`
BinName string `form:"bin_name"`
BinPos int32 `form:"bin_pos"`
Remark string `form:"remark"`
Leader string `form:"leader"`
Project string `form:"project"`
}
//ListReq canallist req
type ListReq struct {
Addr string `form:"addr"`
Project string `form:"project"`
Status int8 `form:"status"`
Pn int `form:"pn" default:"1"`
Ps int `form:"ps" default:"20"`
}
//Paper canallist resp
type Paper struct {
Total int `json:"total"`
Pn int `json:"pn"`
Ps int `json:"ps"`
Items interface{} `json:"items"`
}
//Conf is
type Conf struct {
ID int64 `json:"id"`
Comment string `json:"comment"`
}
//Document document
type Document struct {
Instance struct {
User string `json:"user" toml:"user"`
Password string `json:"password" toml:"password"`
MonitorPeriod string `json:"monitor_period" toml:"monitor_period"`
ServerID int64 `json:"server_id" toml:"server_id"`
Db []*struct {
Schema string `json:"schema" toml:"schema"`
Table []*struct {
Name string `json:"name" toml:"name"`
Primarykey []string `json:"primarykey,omitempty" toml:"primarykey"`
Omitfield []string `json:"omitfield,omitempty" toml:"omitfield"`
} `json:"table" toml:"table"`
Databus *struct {
Group string `json:"group" toml:"group"`
Topic string `json:"topic" toml:"topic"`
Action string `json:"action" toml:"action"`
Name string `json:"name" toml:"name"`
Proto string `json:"proto" toml:"proto"`
Addr string `json:"addr" toml:"addr"`
Idle int `json:"idle" toml:"idle"`
Active int `json:"active" toml:"active"`
DialTimeout string `json:"dialTimeout" toml:"dialTimeout"`
ReadTimeout string `json:"readTimeout" toml:"readTimeout"`
WriteTimeout string `json:"writeTimeout" toml:"writeTimeout"`
IdleTimeout string `json:"idleTimeout" toml:"idleTimeout"`
} `json:"databus" toml:"databus"`
Infoc *struct {
TaskID string `json:"taskID" toml:"taskID"`
Proto string `json:"proto" toml:"proto"`
Addr string `json:"addr" toml:"addr"`
ReporterAddr string `json:"reporterAddr" toml:"reporterAddr"`
} `json:"infoc" toml:"infoc"`
} `json:"db"`
} `json:"instance"`
}