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,34 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/admin/main/apm/model/app:all-srcs",
"//app/admin/main/apm/model/canal:all-srcs",
"//app/admin/main/apm/model/databus:all-srcs",
"//app/admin/main/apm/model/discovery:all-srcs",
"//app/admin/main/apm/model/ecode:all-srcs",
"//app/admin/main/apm/model/log:all-srcs",
"//app/admin/main/apm/model/monitor:all-srcs",
"//app/admin/main/apm/model/need:all-srcs",
"//app/admin/main/apm/model/pprof:all-srcs",
"//app/admin/main/apm/model/tree:all-srcs",
"//app/admin/main/apm/model/user:all-srcs",
"//app/admin/main/apm/model/ut:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

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 = [
"app.go",
"auth.go",
],
importpath = "go-common/app/admin/main/apm/model/app",
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,20 @@
package app
import (
xtime "go-common/library/time"
)
// TableName case tablename
func (*App) TableName() string {
return "app"
}
// App app
type App struct {
ID int64 `gorm:"column:id" json:"id"`
AppTreeID int64 `gorm:"column:app_tree_id" json:"app_tree_id"`
AppID string `gorm:"column:app_id" json:"app_id"`
Limit int64 `gorm:"column:limit" json:"limit"`
CTime xtime.Time `gorm:"column:ctime" json:"ctime"`
MTime xtime.Time `gorm:"column:mtime" json:"mtime"`
}

View File

@@ -0,0 +1,24 @@
package app
import (
xtime "go-common/library/time"
)
// TableName case tablename
func (*Auth) TableName() string {
return "app_auth"
}
// Auth app auth
type Auth struct {
ID int64 `gorm:"column:id" json:"id"`
ServiceTreeID int64 `gorm:"column:service_tree_id" json:"service_tree_id"`
AppTreeID int64 `gorm:"column:app_tree_id" json:"app_tree_id"`
ServiceID string `gorm:"column:service_id" json:"service_id"`
AppID string `gorm:"column:app_id" json:"app_id"`
RPCMethod string `gorm:"column:rpc_method" json:"rpc_method"`
HTTPMethod string `gorm:"column:http_method" json:"http_method"`
Quota int64 `gorm:"column:quota" json:"quota"`
CTime xtime.Time `gorm:"column:ctime" json:"ctime"`
MTime xtime.Time `gorm:"column:mtime" json:"mtime"`
}

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"`
}

View File

@@ -0,0 +1,40 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"alarm.go",
"app.go",
"apply.go",
"auth.go",
"filter.go",
"message.go",
"notify.go",
"notifygroup.go",
"oldapp.go",
"oldauth.go",
"topic.go",
],
importpath = "go-common/app/admin/main/apm/model/databus",
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,96 @@
package databus
// AlarmOpen ...
type AlarmOpen struct {
ReqID string `json:"ReqId"`
Action string `json:"Action"`
RetCode int64 `json:"RetCode"`
Data []*Open `json:"Data"`
}
// Open ...
type Open struct {
AdjustID string `json:"adjust_id"`
PolicyID string `json:"policy_id"`
Group string `json:"group"`
}
//Scope ...
type Scope struct {
Type int64
Key string
Val []string
}
//Owner ...
type Owner struct {
Owner string `json:"owner"`
App string `json:"app"`
}
// Res ...
type Res struct {
ReqID string `json:"ReqId"`
Action string `json:"Action"`
RetCode int64 `json:"RetCode"`
Data Opsmind `json:"Data"`
}
// Opsmind ...
type Opsmind struct {
PolicyID string `json:"policy_id"`
AdjustID string `json:"adjust_id"`
Category string `json:"category"`
Scope string `json:"scope"`
TriggerID string `json:"trigger_id"`
TriggerLevel string `json:"trigger_level"`
TriggerFor int64 `json:"trigger_for"`
TriggerNotes string `json:"trigger_notes"`
TriggerOperator string `json:"trigger_operator"`
TriggerThreshold int64 `json:"trigger_threshold"`
Silence bool `json:"silence"`
Hashid string `json:"hashid"`
ExpiredAt string `json:"expired_at"`
}
//Query ...
type Query struct {
Key string
Val []string
}
// ResQuery ...
type ResQuery struct {
ReqID string `json:"ReqId"`
Action string `json:"Action"`
RetCode int64 `json:"RetCode"`
Data []*Querys `json:"Data"`
}
// Querys ...
type Querys struct {
ID string `json:"id"`
PolicyID string `json:"policy_id"`
Creator string `json:"creator"`
Ctime int64 `json:"ctime"`
Mtime int64 `json:"mtime"`
Scope []*Scope `json:"scope"`
Triggers []*Trigger `json:"triggers"`
Notes *Owner `json:"notes"`
Desc string `json:"desc"`
Silence bool `json:"silence"`
ExpiredAt int64 `json:"expired_at"`
}
//Trigger ...
type Trigger struct {
ID string `json:"id"`
Desc string `json:"desc"`
Operator string `json:"operator"`
For int64 `json:"for"`
Threshold float64 `json:"threshold"`
Level string `json:"level"`
NodataType string `json:"nodata_type"`
NodataFor int64 `json:"nodata_for"`
Notes *Owner `json:"notes"`
}

View File

@@ -0,0 +1,19 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*App) TableName() string {
return "app2"
}
// App app model
type App struct {
ID int `gorm:"column:id" json:"id"`
AppKey string `gorm:"column:app_key" json:"app_key"`
AppSecret string `gorm:"column:app_secret" json:"app_secret"`
Project string `gorm:"column:project" json:"cluster"`
Remark string `gorm:"column:remark" json:"remark"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,37 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*Apply) TableName() string {
return "group_apply"
}
// Apply apply model
type Apply struct {
ID int `gorm:"column:id" json:"id"`
Group string `gorm:"column:group" json:"group"`
Cluster string `gorm:"column:cluster" json:"cluster"`
TopicRemark string `gorm:"column:topic_remark" json:"topic_remark"`
TopicID int `gorm:"column:topic_id" json:"topic_id"`
TopicName string `gorm:"column:topic_name" json:"topic"`
AppID int `gorm:"column:app_id" json:"app_id"`
Project string `gorm:"column:project" json:"project"`
Operation int8 `gorm:"column:operation" json:"operation"`
State int8 `gorm:"column:state" json:"state"`
Operator string `gorm:"column:operator" json:"operator"`
Remark string `gorm:"column:remark" json:"remark"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
// notify
Gid int `gorm:"-" json:"notify_gid"`
Nid int64 `gorm:"-" json:"notify_id"`
Offset string `gorm:"-" json:"notify_offset"`
Nstate int8 `gorm:"-" json:"notify_state"`
Filter int8 `gorm:"-" json:"notify_filter"`
Concurrent int8 `gorm:"-" json:"notify_concurrent"`
Callback string `gorm:"-" json:"notify_callback"`
Filters string `gorm:"-" json:"-"`
FilterList []*Filter `gorm:"-" json:"filters"`
Zone string `gorm:"-" json:"notify_zone"`
}

View File

@@ -0,0 +1,65 @@
package databus
import (
"go-common/library/time"
)
// TableName case tablename
func (*Group) TableName() string {
return "auth2"
}
// Group group model
type Group struct {
ID int `gorm:"column:id" json:"id"`
Group string `gorm:"column:group" json:"group"`
AppID int `gorm:"column:app_id" json:"app_id"`
AppKey string `gorm:"-" json:"app_key"`
Project string `gorm:"-" json:"project"`
TopicID int `gorm:"column:topic_id" json:"topic_id"`
Topic string `gorm:"-" json:"topic"`
Cluster string `gorm:"-" json:"cluster"`
Operation int8 `gorm:"column:operation" json:"operation"`
IsDelete int8 `gorm:"column:is_delete" json:"is_delete"`
Remark string `gorm:"column:remark" json:"remark"`
Alarm int8 `gorm:"column:alarm;default:1" json:"alarm"`
Percentage string `gorm:"column:percentage" json:"percentage"`
Number int `gorm:"column:number" json:"number"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
Callback string `gorm:"-" json:"notify_callback"`
Concurrent string `gorm:"-" json:"notify_concurrent"`
Filter int8 `gorm:"-" json:"notify_filter"`
Filters string `gorm:"-" json:"-"`
FilterList []*Filter `gorm:"-" json:"filters"`
State int8 `gorm:"-" json:"notify_state"`
Gid int64 `gorm:"-" json:"notify_gid"`
Nid int64 `gorm:"-" json:"notify_id"`
Zone string `gorm:"-" json:"notify_zone"`
}
//Alarm alarm
type Alarm struct {
Group string `json:"group"`
Project string `json:"project"`
Alarm int8 `json:"alarm"`
Percentage string `json:"percentage"`
}
//Alarms alarms
type Alarms struct {
Cluster string `json:"cluster"`
Topic string `json:"topic"`
Group string `json:"group"`
Project string `json:"project"`
Alarm int8 `json:"alarm"`
Percentage string `json:"percentage"`
Diff []*Record `json:"diff"`
}
// Record diff
type Record struct {
Partition int32 `json:"partition"`
Diff int64 `json:"diff"`
New int64 `json:"new"`
}

View File

@@ -0,0 +1,16 @@
package databus
// TableName case tablename
func (*Filter) TableName() string {
return "filters"
}
// Filter apply model
type Filter struct {
ID int `gorm:"column:id" json:"id"`
Nid int `gorm:"column:nid" json:"nid"`
Filters string `gorm:"column:filters" json:"-"`
Field string `gorm:"-" json:"field"`
Condition int8 `gorm:"-" json:"condition"`
Value string `gorm:"-" json:"value"`
}

View File

@@ -0,0 +1,11 @@
package databus
// Message Data.
type Message struct {
Key string `json:"key"`
Value string `json:"value"`
Topic string `json:"topic"`
Partition int32 `json:"partition"`
Offset int64 `json:"offset"`
Timestamp int64 `json:"timestamp"`
}

View File

@@ -0,0 +1,22 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*Notify) TableName() string {
return "notify"
}
// Notify apply model
type Notify struct {
ID int `gorm:"column:id" json:"id"`
Gid int `gorm:"column:gid" json:"gid"`
Offset string `gorm:"column:offset" json:"offset"`
State int8 `gorm:"column:state" json:"state"`
Filter int8 `gorm:"column:filter" json:"filter"`
Concurrent int8 `gorm:"column:concurrent" json:"concurrent"`
Callback string `gorm:"column:callback" json:"callback"`
Zone string `gorm:"column:zone" json:"zone"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
}

View File

@@ -0,0 +1,34 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*NotifyGroup) TableName() string {
return "group_apply"
}
// NotifyGroup apply model
type NotifyGroup struct {
ID int `gorm:"column:id" json:"notify_id"`
Gid int `gorm:"column:gid" json:"notify_gid"`
Offset string `gorm:"column:offset" json:"notify_offset"`
State int8 `gorm:"column:state" json:"notify_state"`
Filter int8 `gorm:"column:filter" json:"notify_filter"`
Concurrent int8 `gorm:"column:concurrent" json:"notify_concurrent"`
Callback string `gorm:"column:callback" json:"notify_callback"`
Ctime time.Time `gorm:"column:ctime" json:"notify_ctime"`
Mtime time.Time `gorm:"column:mtime" json:"notify_mtime"`
GGroup string `gorm:"column:group" json:"group"`
GCluster string `gorm:"column:cluster" json:"cluster"`
GTopicRemark string `gorm:"column:topic_remark" json:"topic_remark"`
GTopicID int `gorm:"column:topic_id" json:"topic_id"`
GTopicName string `gorm:"column:topic_name" json:"topic"`
GAppID int `gorm:"column:app_id" json:"app_id"`
GState int8 `gorm:"column:gstate" json:"state"`
GOperation int8 `gorm:"column:operation" json:"operation"`
GOperator string `gorm:"column:operator" json:"operator"`
GRemark string `gorm:"column:remark" json:"remark"`
Filters string `gorm:"column:filters" json:"filters"`
GCtime time.Time `gorm:"column:gctime" json:"ctime"`
GMtime time.Time `gorm:"column:gmtime" json:"mtime"`
}

View File

@@ -0,0 +1,18 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*OldApp) TableName() string {
return "app"
}
// OldApp app model
type OldApp struct {
ID int64 `gorm:"column:id" json:"id"`
AppKey string `gorm:"column:app_key" json:"app_key"`
AppSecret string `gorm:"column:app_secret" json:"app_secret"`
Cluster string `gorm:"column:cluster" json:"cluster"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,22 @@
package databus
import (
"go-common/library/time"
)
// TableName case tablename
func (*OldAuth) TableName() string {
return "auth"
}
// OldAuth group model
type OldAuth struct {
ID int64 `gorm:"column:id" json:"id"`
GroupName string `gorm:"column:group_name" json:"group_name"`
Topic string `gorm:"column:topic" json:"topic"`
Business string `gorm:"business" json:"business"`
AppID int64 `gorm:"column:app_id" json:"app_id"`
Operation int8 `gorm:"column:operation" json:"operation"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
}

View File

@@ -0,0 +1,20 @@
package databus
import (
"go-common/library/time"
)
// TableName case tablename
func (*Topic) TableName() string {
return "topic"
}
// Topic topic
type Topic struct {
ID int `gorm:"column:id" json:"id"`
Topic string `gorm:"column:topic" json:"topic"`
Cluster string `gorm:"column:cluster" json:"cluster"`
Remark string `gorm:"column:remark" json:"remark"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["discovery.go"],
importpath = "go-common/app/admin/main/apm/model/discovery",
tags = ["automanaged"],
)
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,13 @@
package discovery
// Status node
type Status struct {
Status int `json:"status"`
Others interface{} `json:"others"`
}
// Addr addr
type Addr struct {
Addr string `json:"addr"`
Status int `json:"status"`
}

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 = [
"code_msg.go",
"ecode.go",
],
importpath = "go-common/app/admin/main/apm/model/ecode",
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,21 @@
package codes
import (
xtime "go-common/library/time"
)
// TableName case tablename
func (*CodeMsg) TableName() string {
return "code_msg"
}
// CodeMsg ...
type CodeMsg struct {
ID int64 `gorm:"column:id" json:"cid"`
CodeID int64 `gorm:"column:code_id" json:"code_id"`
Locale string `gorm:"column:locale" json:"locale"`
Msg string `gorm:"column:msg" json:"msg"`
Operator string `gorm:"column:operator" json:"c_operator"`
CTime xtime.Time `gorm:"column:ctime" json:"c_ctime"`
MTime xtime.Time `gorm:"column:mtime" json:"c_mtime"`
}

View File

@@ -0,0 +1,41 @@
package codes
import (
xtime "go-common/library/time"
)
// code status
const (
StatusOpen = int8(1)
Type = int8(1)
)
// TableName case tablename
func (*Codes) TableName() string {
return "codes"
}
// Codes codes
type Codes struct {
ID int64 `gorm:"column:id" json:"id"`
Code int32 `gorm:"column:code" json:"code"`
Message string `gorm:"column:message" json:"message"`
Operator string `gorm:"column:operator" json:"operator"`
CTime xtime.Time `gorm:"column:ctime" json:"ctime"`
MTime xtime.Time `gorm:"column:mtime" json:"mtime"`
HantMessage string `gorm:"column:hant_message" json:"hant_message"`
Level int8 `gorm:"column:level" json:"level"`
}
// ResultCodes ...
type ResultCodes struct {
Code int32 `json:"code"`
Message string `json:"message"`
Data []*Codes
}
// NewCodes ...
type NewCodes struct {
*Codes
List []*CodeMsg `json:"list"`
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["log.go"],
importpath = "go-common/app/admin/main/apm/model/log",
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,20 @@
package log
import (
xtime "go-common/library/time"
)
// TableName case tablename
func (*Log) TableName() string {
return "log"
}
// Log log model
type Log struct {
ID int64 `gorm:"column:id" json:"id"`
UserName string `gorm:"column:username" json:"username"`
Business string `gorm:"column:business" json:"business"`
Info string `gorm:"column:info" json:"info"`
CTime xtime.Time `gorm:"column:ctime" json:"ctime"`
MTime xtime.Time `gorm:"column:mtime" json:"mtime"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["monitor.go"],
importpath = "go-common/app/admin/main/apm/model/monitor",
tags = ["automanaged"],
visibility = ["//visibility:public"],
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,42 @@
package monitor
import (
"go-common/library/time"
)
// TableName define table name
func (*Monitor) TableName() string {
return "monitor"
}
// Monitor .
type Monitor struct {
ID int64 `gorm:"column:id" json:"id"`
AppID string `gorm:"column:app_id" json:"app_id"`
Interface string `gorm:"column:interface" json:"interface"`
Count int64 `gorm:"column:count" json:"count"`
Cost int64 `gorm:"column:cost" json:"cost"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
TempName string `gorm:"-" json:"temp_name"`
}
// Data .
type Data struct {
Interface string `json:"interface"`
Counts []int64 `json:"counts"`
Costs []int64 `json:"costs"`
Times []string `json:"times"`
}
// MoniRet .
type MoniRet struct {
XAxis []string `json:"xAxis"`
Items []*Items `json:"items"`
}
// Items .
type Items struct {
Interface string `json:"interface"`
YAxis []int64 `json:"yAxis"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["need.go"],
importpath = "go-common/app/admin/main/apm/model/need",
tags = ["automanaged"],
visibility = ["//visibility:public"],
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,111 @@
package need
import "go-common/library/time"
// type and states
const (
TypeCancel = 0
TypeLike = 1
TypeDislike = 2
VerifyAccept = 2
VerifyReject = 3
VerifyObserved = 4
NeedApply = 5
NeedVerify = 6
NeedReview = 7
)
//VerifyType is
var (
VerifyType = map[int]string{
VerifyAccept: "采纳",
VerifyReject: "驳回",
VerifyObserved: "待观察",
NeedApply: "申请",
NeedVerify: "确认",
NeedReview: "审核",
}
)
//TableName needs
func (*NInfo) TableName() string {
return "needs"
}
//NInfo struct
type NInfo struct {
ID int64 `gorm:"column:id" json:"id"`
Title string `gorm:"column:title" json:"title"`
Content string `gorm:"column:content" json:"content"`
Reporter string `gorm:"column:reporter" json:"reporter"`
Status int8 `gorm:"column:status" json:"status"`
LikeCounts int `gorm:"column:like_counts" json:"like_counts"`
DislikeCounts int `gorm:"column:dislike_counts" json:"dislike_counts"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
LikeState int8 `gorm:"-" json:"like_state"`
}
//NAddReq add request struct
type NAddReq struct {
Title string `form:"title" validate:"required"`
Content string `form:"content" validate:"required"`
}
// EmpResp is empty resp.
type EmpResp struct {
}
//NEditReq edit request struct
type NEditReq struct {
ID int64 `form:"id" validate:"required"`
Title string `form:"title"`
Content string `form:"content"`
}
//NListReq is list request struct
type NListReq struct {
Ps int `form:"ps" default:"20"`
Pn int `form:"pn" default:"1"`
Status int `form:"status"`
Reporter string `form:"reporter"`
}
//NListResp is list resp struct
type NListResp struct {
Data []*NInfo `json:"data"`
Total int64 `json:"total"`
}
//NVerifyReq is verify req struct
type NVerifyReq struct {
ID int64 `form:"id" validate:"required"`
Status int `form:"status" validate:"required"`
}
//TableName user_likes
func (*UserLikes) TableName() string {
return "user_likes"
}
//UserLikes struct
type UserLikes struct {
ID int64 `gorm:"column:id" json:"id"`
ReqID int64 `gorm:"column:req_id" json:"req_id"`
User string `gorm:"column:user" json:"user"`
LikeType int8 `gorm:"column:like_type" json:"like_type"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
}
//Likereq is userlike req struct
type Likereq struct {
ReqID int64 `form:"req_id" validate:"required"`
LikeType int8 `form:"like_type"`
}
//VoteListResp is vote resp struct
type VoteListResp struct {
Data []*UserLikes `json:"data"`
Total int64 `json:"total"`
}

View File

@@ -0,0 +1,29 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["pprof.go"],
importpath = "go-common/app/admin/main/apm/model/pprof",
tags = ["automanaged"],
visibility = ["//visibility:public"],
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,55 @@
package pprof
import (
"go-common/library/time"
)
// TableName .
func (*Warn) TableName() string {
return "pprof_warn"
}
// Warn .
type Warn struct {
ID int64 `gorm:"column:id" json:"id"`
AppID string `gorm:"column:app_id" json:"app_id"`
SvgName string `gorm:"column:svg_name" json:"svg_name"`
IP string `gorm:"column:ip" json:"ip"`
Kind int64 `gorm:"column:kind" json:"kind"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
URL string `gorm:"-" json:"url"`
}
// Response .
type Response struct {
Code int `json:"code"`
Data *Ins `json:"data"`
}
// Warning .
type Warning struct {
Tags struct {
App string `json:"app"`
} `json:"tags"`
}
// Ins .
type Ins struct {
Instances []struct {
Treeid int `json:"treeid"`
Hostname string `json:"hostname"`
Addrs []string `json:"addrs"`
Status int `json:"status"`
} `json:"instances"`
}
// Params .
type Params struct {
AppID string `form:"app_id" default:""`
SvgName string `form:"svg_name" default:""`
Kind int64 `form:"kind" default:"0"`
IP string `form:"ip" default:""`
StartTime time.Time `form:"start_time" default:"0"`
EndTime time.Time `form:"end_time" default:"0"`
}

View File

@@ -0,0 +1,27 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["tree.go"],
importpath = "go-common/app/admin/main/apm/model/tree",
tags = ["automanaged"],
)
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,65 @@
package tree
import "time"
// Token token
type Token struct {
Token string `json:"token"`
UserName string `json:"user_name"`
Secret string `json:"secret"`
Expired int64 `json:"expired"`
}
// TokenResult token result
type TokenResult struct {
Code int `json:"code"`
Data *Token `json:"data"`
Message string `json:"message"`
Status int `json:"status"`
}
// Resp tree resp
type Resp struct {
Data []*Node `json:"data"`
}
// Node node
type Node struct {
TreeID int `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Type int `json:"type"`
Role int `json:"role"`
DiscoveryID string `json:"discovery_id"`
}
// Tree tree model
type Tree struct {
Project string `json:"project"`
Subs []*Tree `json:"subs"`
}
// Rest tree rest
type Rest struct {
Data []*Info `json:"data"`
}
// Info tree info
type Info struct {
AppTreeID int `json:"app_tree_id"`
AppID string `json:"app_id"`
}
// Resd tree resd
type Resd struct {
Data []*DiscoveryID `json:"data"`
CTime time.Time `json:"ctime"`
}
// DiscoveryID node
type DiscoveryID struct {
TreeID int `json:"app_tree_id"`
AppID string `json:"app_id"`
AppAuth string `json:"app_auth"`
DiscoveryID string `json:"discovery_id"`
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"module.go",
"rule.go",
"user.go",
],
importpath = "go-common/app/admin/main/apm/model/user",
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,75 @@
package user
import (
"go-common/library/time"
)
// modules
const (
USER = "USER"
ECODE = "ECODE"
DATABUS = "DATABUS"
DAPPER = "DAPPER"
CONFIG = "CONFIG"
CANAL = "CANAL"
DISCOVERY = "DISCOVERY"
APP = "APP"
PLATFORM = "PLATFORM"
CACHE = "CACHE"
OPEN = "OPEN"
NEED = "NEED"
PERFORMANCE = "PERFORMANCE"
BFS = "BFS"
)
// Modules modules
var (
Modules = map[string]*Permission{
USER: {Name: "USER", Permit: PermitSuper, Des: "用户管理"},
ECODE: {Name: "ECODE", Permit: PermitDefault, Des: "错误码管理"},
DATABUS: {Name: "DATABUS", Permit: PermitDefault, Des: "DATABUS管理"},
DAPPER: {Name: "DAPPER", Permit: PermitDefault, Des: "DAPPER查询"},
CONFIG: {Name: "CONFIG", Permit: PermitDefault, Des: "配置中心"},
CANAL: {Name: "CANAL", Permit: PermitDefault, Des: "CANAL管理"},
DISCOVERY: {Name: "DISCOVERY", Permit: PermitDefault, Des: "DISCOVERY管理"},
APP: {Name: "APP", Permit: PermitDefault, Des: "APP管理"},
PLATFORM: {Name: "PLATFORM", Permit: PermitAuth, Des: "平台管理"},
CACHE: {Name: "CACHE", Permit: PermitDefault, Des: "缓存集群"},
OPEN: {Name: "OPEN", Permit: PermitDefault, Des: "open鉴权管理"},
NEED: {Name: "NEED", Permit: PermitDefault, Des: "需求管理"},
PERFORMANCE: {Name: "PERFORMANCE", Permit: PermitDefault, Des: "性能管理"},
BFS: {Name: "BFS", Permit: PermitAuth, Des: "BFS管理"},
}
)
// var (
// Modules = map[string]string{
// USER: "用户管理",
// ECODE: "错误码管理",
// DATABUS: "DATABUS管理",
// DAPPER: "DAPPER查询",
// CONFIG: "配置中心",
// CANAL: "CANAL管理",
// DISCOVERY: "DISCOVERY管理",
// APP: "APP管理",
// PLATFORM: "平台管理",
// CACHE: "缓存集群",
// OPEN: "open鉴权管理",
// NEED: "需求管理",
// }
// DefaultModules = []string{ECODE, DATABUS, DAPPER, CONFIG, CANAL, DISCOVERY, APP, CACHE, OPEN}
// )
// TableName case tablename
func (*Module) TableName() string {
return "user_module"
}
// Module module model
type Module struct {
ID int64 `gorm:"column:id" json:"id"`
UserID int64 `gorm:"column:user_id" json:"user_id"`
Module string `gorm:"column:module" json:"module"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,151 @@
package user
import (
"go-common/library/time"
)
// rules
const (
UserView = "USER_VIEW"
UserEdit = "USER_EDIT"
UserAudit = "USER_AUDIT"
EcodeView = "ECODE_VIEW"
EcodeEdit = "ECODE_EDIT"
DatabusKeyView = "DATABUS_KEY_VIEW"
DatabusKeyEdit = "DATABUS_KEY_EDIT"
DatabusGroupView = "DATABUS_GROUP_VIEW"
DatabusGroupEdit = "DATABUS_GROUP_EDIT"
DatabusTopicView = "DATABUS_TOPIC_VIEW"
DatabusTopicEdit = "DATABUS_TOPIC_EDIT"
DatabusNotifyView = "DATABUS_NOTIFY_VIEW"
DatabusNotifyEdit = "DATABUS_NOTIFY_EDIT"
DatabusGroupApply = "DATABUS_GROUP_APPLY"
DapperView = "DAPPER_VIEW"
CanalView = "CANAL_VIEW"
CanalEdit = "CANAL_EDIT"
ConfigView = "CONFIG_VIEW"
ConfigSearchView = "CONFIG_SEARCH_VIEW"
ConfigPublicView = "CONFIG_PUBLIC_VIEW"
DiscoveryView = "DISCOVERY_VIEW"
PerformanceManager = "PERFORMANCE_MANAGER"
AppView = "APP_VIEW"
AppEdit = "APP_EDIT"
AppAuthView = "APP_AUTH_VIEW"
AppCallerSearch = "APP_CALLER_SEARCH"
NeedVerify = "NEED_VERIFY"
PlatformSearchView = "PLATFORM_SEARCH_VIEW"
PlatformReplyView = "PLATFORM_REPLY_VIEW"
PlatformTagView = "PLATFORM_TAG_VIEW"
CacheOpsView = "CACHE_OPS_VIEW"
OpenView = "OPEN_VIEW"
BFSView = "BFS_VIEW"
BFSEdit = "BFS_EDIT"
)
//PermitType value
const (
PermitDefault = iota
PermitAuth
PermitSuper
)
// PermitType permit type
type PermitType int
// Permission descript modules and rules
type Permission struct {
Name string
Permit PermitType
Des string
}
// rules
var (
Rules = map[string]*Permission{
UserView: {Name: "UserView", Permit: PermitSuper, Des: "用户查看"},
UserEdit: {Name: "UserEdit", Permit: PermitSuper, Des: "用户管理"},
UserAudit: {Name: "UserAudit", Permit: PermitSuper, Des: "权限审核"},
EcodeView: {Name: "EcodeView", Permit: PermitDefault, Des: "错误码查看"},
EcodeEdit: {Name: "EcodeEdit", Permit: PermitDefault, Des: "错误码编辑"},
DatabusKeyView: {Name: "DatabusKeyView", Permit: PermitDefault, Des: "Key查看"},
DatabusKeyEdit: {Name: "DatabusKeyEdit", Permit: PermitAuth, Des: "Key编辑"},
DatabusGroupView: {Name: "DatabusGroupView", Permit: PermitDefault, Des: "Group查看"},
DatabusGroupEdit: {Name: "DatabusGroupEdit", Permit: PermitAuth, Des: "Group修改"},
DatabusTopicView: {Name: "DatabusTopicView", Permit: PermitDefault, Des: "Topic查看"},
DatabusTopicEdit: {Name: "DatabusTopicEdit", Permit: PermitAuth, Des: "Topic编辑"},
DatabusNotifyView: {Name: "DatabusNotifyView", Permit: PermitDefault, Des: "Notify查看"},
DatabusNotifyEdit: {Name: "DatabusNotifyEdit", Permit: PermitAuth, Des: "Notify编辑"},
DatabusGroupApply: {Name: "DatabusGroupApply", Permit: PermitAuth, Des: "Group审核"},
DapperView: {Name: "DapperView", Permit: PermitDefault, Des: "Dapper查询"},
CanalView: {Name: "CanalView", Permit: PermitDefault, Des: "Canal查看"},
CanalEdit: {Name: "CanalEdit", Permit: PermitAuth, Des: "Canal编辑"},
ConfigView: {Name: "ConfigView", Permit: PermitDefault, Des: "配置列表查看"},
ConfigSearchView: {Name: "ConfigSearchView", Permit: PermitAuth, Des: "搜索列表查看"},
ConfigPublicView: {Name: "ConfigPublicView", Permit: PermitDefault, Des: "公共配置查看"},
DiscoveryView: {Name: "DiscoveryView", Permit: PermitDefault, Des: "Discovery查看"},
AppView: {Name: "AppView", Permit: PermitDefault, Des: "APP查看"},
AppEdit: {Name: "AppEdit", Permit: PermitAuth, Des: "APP编辑"},
AppAuthView: {Name: "AppAuthView", Permit: PermitAuth, Des: "APP鉴权查看"},
AppCallerSearch: {Name: "AppCallerSearch", Permit: PermitAuth, Des: "APP调用方查询"},
PlatformSearchView: {Name: "PlatformSearchView", Permit: PermitAuth, Des: "平台搜索"},
PlatformReplyView: {Name: "PlatformReplyView", Permit: PermitAuth, Des: "平台评论"},
PlatformTagView: {Name: "PlatformTagView", Permit: PermitAuth, Des: "Tag"},
CacheOpsView: {Name: "CacheOpsView", Permit: PermitAuth, Des: "overlord缓存集群管理"},
NeedVerify: {Name: "NeedVerify", Permit: PermitSuper, Des: "需求建议审核"},
OpenView: {Name: "OpenView", Permit: PermitAuth, Des: "open鉴权查看"},
PerformanceManager: {Name: "PerformanceManager", Permit: PermitDefault, Des: "性能管理"},
BFSView: {Name: "BFSView", Permit: PermitAuth, Des: "BFS查看"},
BFSEdit: {Name: "BFSEdit", Permit: PermitAuth, Des: "BFS编辑"},
}
)
// TableName case tablename
func (*Rule) TableName() string {
return "user_rule"
}
// TableName case tablename
func (*Apply) TableName() string {
return "user_apply"
}
// Rule rule model
type Rule struct {
ID int64 `gorm:"column:id" json:"id"`
UserID int64 `gorm:"column:user_id" json:"user_id"`
Rule string `gorm:"column:rule" json:"rule"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}
// Apply user apply
type Apply struct {
ID int64 `gorm:"column:id" json:"id"`
UserID int64 `gorm:"column:user_id" json:"user_id" params:"user_id"`
Rules string `gorm:"column:rules" json:"rules" params:"rules"`
Admin string `gorm:"column:admin" json:"admin" params:"admin"`
Status int8 `gorm:"column:status" json:"status" `
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}
// Applies ...
type Applies struct {
ID int64 `gorm:"column:id" json:"id"`
UserID int64 `gorm:"column:user_id" json:"user_id"`
UserName string `gorm:"column:username" json:"username"`
Rules string `gorm:"column:rules" json:"rules"`
Status string `gorm:"column:status" json:"status"`
}

View File

@@ -0,0 +1,39 @@
package user
import (
"go-common/library/time"
)
// TableName case tablename
func (*User) TableName() string {
return "user"
}
// User user model
type User struct {
ID int64 `gorm:"column:id" json:"id" params:"id;Min(1)"`
UserName string `gorm:"column:username" json:"username" params:"username"`
NickName string `gorm:"column:nickname" json:"nickname" params:"nickname"`
Email string `gorm:"column:email" json:"email" params:"email"`
Phone string `gorm:"column:phone" json:"phone" params:"phone"`
Status int8 `gorm:"column:status" json:"status" params:"status"`
AvatarURL string `gorm:"-" json:"avatar_url"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}
// Pager user pager
type Pager struct {
Total int64 `json:"total"`
Pn int `params:"pn" default:"1"`
Ps int `params:"ps" default:"20"`
Items []*User `json:"items"`
}
// Result contains user and modules and rules.
type Result struct {
Super bool `json:"superman"`
Env string `json:"env"`
User *User `json:"user"`
Rules []string `json:"rules"`
}

View File

@@ -0,0 +1,34 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"app.go",
"dashboard.go",
"rank.go",
"ut.go",
],
importpath = "go-common/app/admin/main/apm/model/ut",
tags = ["automanaged"],
visibility = ["//visibility:public"],
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,56 @@
package ut
import (
"go-common/library/time"
"sync"
)
// TableName .
func (*App) TableName() string {
return "ut_app"
}
// App ..
type App struct {
ID int64 `gorm:"column:id" json:"id"`
Path string `gorm:"column:path" json:"path"`
Owner string `gorm:"column:owner" json:"owner"`
HasUt int `gorm:"column:has_ut" json:"has_ut"`
Link string `gorm:"-" json:"link"`
Coverage float64 `gorm:"coverage"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
}
// AppReq .
type AppReq struct {
HasUt int `form:"has_ut"`
Path string `form:"path"`
Pn int `form:"pn" default:"1"`
Ps int `form:"ps" defalut:"20"`
}
// Department .
type Department struct {
Name string
Total int64
Access int64
Coverage float64
}
// AppsCache apps cache.
type AppsCache struct {
Slice []*App
Map map[string]*App
Owner map[string][]*App
Dept map[string]*Department
sync.Mutex
}
//PathsByOwner get app paths by owner.
func (apps *AppsCache) PathsByOwner(owner string) (paths []string) {
for _, app := range apps.Owner[owner] {
paths = append(paths, app.Path)
}
return
}

View File

@@ -0,0 +1,31 @@
package ut
import (
"go-common/library/time"
)
// PCurveReq is
type PCurveReq struct {
User string `form:"user"`
Path string `form:"path"`
StartTime int64 `form:"start_time"`
EndTime int64 `form:"end_time"`
}
// PCurveResp .
type PCurveResp struct {
Pkg string `gorm:"column:pkg" json:"pkg,omitempty"`
Coverage float64 `gorm:"column:coverage" json:"coverage"`
Assertions int64 `gorm:"column:assertions" json:"assertions"`
Failures int64 `gorm:"column:failures" json:"failures"`
Panics int64 `gorm:"column:panics" json:"panics"`
Passed int64 `gorm:"column:passed" json:"passed"`
PassRate float64 `gorm:"-" json:"pass_rate"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
}
// PCurveDetailResp .
type PCurveDetailResp struct {
PCurveResp
Username string `json:"username"`
}

View File

@@ -0,0 +1,39 @@
package ut
import (
"go-common/library/time"
"sync"
)
// RankResp resp result of rank list
type RankResp struct {
UserName string `gorm:"column:username" json:"username"`
Score float64 `gorm:"-" json:"score"`
Newton float64 `gorm:"-" json:"newton"`
Coverage float64 `gorm:"-" json:"coverage"`
PassRate float64 `gorm:"-" json:"pass_rate"`
Assertions int `gorm:"-" json:"assertions"`
Passed int `gorm:"-" json:"passed"`
AvatarURL string `gorm:"-" json:"avatar_url"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
Rank int `gorm:"-" json:"rank"`
Total int `gorm:"-" json:"total"`
Change int `gorm:"-" json:"change"`
}
// RanksCache ranks cache.
type RanksCache struct {
Slice []*RankResp
Map map[string]*RankResp
sync.Mutex
}
// Image image of gitlab
type Image struct {
ID int `json:"id"`
Name string `json:"name"`
Username string `json:"username"`
State string `json:"state"`
AvatarURL string `json:"avatar_url"`
WebURL string `json:"web_url"`
}

View File

@@ -0,0 +1,202 @@
package ut
import (
"go-common/library/time"
)
// TableName .
func (*Merge) TableName() string {
return "ut_merge"
}
// TableName .
func (*Commit) TableName() string {
return "ut_commit"
}
// TableName .
func (*PkgAnls) TableName() string {
return "ut_pkganls"
}
// TableName .
func (*File) TableName() string {
return "ut_file"
}
// Merge ut_merge table from db.
type Merge struct {
ID int64 `gorm:"column:id" json:"id"`
MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
IsMerged int8 `gorm:"column:is_merged" json:"is_merged"`
UserName string `gorm:"column:username" json:"username"`
Commit *Commit `gorm:"-" json:"commit"`
NoteID int `gorm:"column:note_id"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
}
// Commit ut_commit table from db.
type Commit struct {
ID int64 `gorm:"column:id" json:"id"`
MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
CommitID string `gorm:"column:commit_id" json:"commit_id"`
UserName string `gorm:"column:username" json:"username"`
PkgAnls []*PkgAnls `gorm:"-" json:"pkganls"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
}
// PkgAnls ut_pkganls table from db.
type PkgAnls struct {
ID int64 `gorm:"column:id" json:"id"`
MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
CommitID string `gorm:"column:commit_id" json:"commit_id"`
PKG string `gorm:"column:pkg" json:"pkg"`
Assertions int64 `gorm:"column:assertions" json:"assertions"`
Passed int64 `gorm:"column:passed" json:"passed"`
Skipped int64 `gorm:"column:skipped" json:"skipped"`
Failures int64 `gorm:"column:failures" json:"failures"`
Panics int64 `gorm:"column:panics" json:"panics"`
Coverage float64 `gorm:"column:coverage" json:"coverage"`
Coverages string `gorm:"-" json:"coverages"`
CovChange float64 `gorm:"-" json:"cov_change"`
PassRate float64 `gorm:"-" json:"pass_rate"`
PassRates string `gorm:"-" json:"pass_rates"`
Score float64 `gorm:"-" json:"score"`
HTMLURL string `gorm:"column:html_url" json:"html_url"`
ReportURL string `gorm:"column:report_url" json:"report_url"`
DataURL string `gorm:"column:data_url" json:"data_url"`
Files []*File `gorm:"-" json:"files"`
CTime time.Time `gorm:"column:ctime" json:"ctime"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
Cids string `gorm:"-" json:"-"`
}
// MergeReq merge list req struct.
type MergeReq struct {
MergeID int64 `form:"merge_id" default:"0"`
UserName string `form:"username" default:""`
IsMerged int8 `form:"is_merged"`
Pn int `form:"pn" default:"1"`
Ps int `form:"ps" default:"20"`
}
// DetailReq .
type DetailReq struct {
CommitID string `form:"commit_id"`
PKG string `form:"pkg"`
}
//HistoryCommitReq struct
type HistoryCommitReq struct {
MergeID int64 `form:"merge_id" validate:"required"`
//CommitID string `form:"commit_id"`
Pn int `form:"pn" default:"1"`
Ps int `form:"ps" default:"20"`
}
// Tyrant .
type Tyrant struct {
Package string `json:"package"`
Coverage float64 `json:"coverage"`
PassRate float64 `json:"pass_rate"`
Increase float64 `json:"increase"`
LastCID string `json:"last_cid"`
Standard int `json:"standard"`
Tyrant bool `json:"tyrant"`
}
// UploadRes .
type UploadRes struct {
MergeID int64 `form:"merge_id" validate:"required"`
CommitID string `form:"commit_id" validate:"required"`
UserName string `form:"username" validate:"required"`
Author string `form:"author"`
PKG string `form:"pkg" validate:"required"`
}
// SAGAResponse .
type SAGAResponse struct {
Coverage float64 `json:"coverage"`
PKG string `json:"pkg"`
}
//QATrendReq is
type QATrendReq struct {
User string `form:"user"`
Period string `form:"period" default:"day"`
LastTime int `form:"last_time" default:"30"`
StartTime int64 `form:"start_time"`
EndTime int64 `form:"end_time"`
}
//QATrendResp is
type QATrendResp struct {
Dates []string `json:"dates"`
CommitIDs []string `json:"commit_ids"`
Coverages []float64 `json:"coverages"`
PassRates []float64 `json:"pass_rates"`
Scores []float64 `json:"scores"`
BaseLine int `json:"baseline"`
}
//CommitInfo is
type CommitInfo struct {
MergeID int64 `gorm:"column:merge_id" json:"merge_id"`
CommitID string `gorm:"column:commit_id" json:"-"`
MTime time.Time `gorm:"column:mtime" json:"mtime"`
Coverage float64 `gorm:"-" json:"coverage"`
PassRate float64 `gorm:"-" json:"pass_rate"`
GitlabCommit *GitlabCommit `gorm:"-" json:"gitlab_commit"`
}
//GitlabCommit is
type GitlabCommit struct {
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
Status string `json:"status"`
ProjectID int64 `json:"project_id"`
}
// WechatUsersMsg is used for sending wechat msg for users
type WechatUsersMsg struct {
ToUser []string `json:"touser"`
Content string `json:"content"`
}
// WechatGroupMsg is used for sending wechat msg for group
type WechatGroupMsg struct {
ChatID string `json:"chatid"`
MsgType string `json:"msgtype"`
Text *TextContent `json:"text"`
Safe int `json:"safe"`
}
// TextContent textContent
type TextContent struct {
Content string `json:"content"`
}
// File file
type File struct {
ID int64 `gorm:"column:id"`
CommitID string `gorm:"column:commit_id"`
PKG string `gorm:"column:pkg"`
Name string `gorm:"column:name"`
Statements int64 `gorm:"colum:statements"`
CoveredStatements int64 `gorm:"column:covered_statements"`
Coverage float64 `gorm:"-"`
CTime time.Time `gorm:"column:ctime"`
MTime time.Time `gorm:"column:mtime"`
}
// Block block
type Block struct {
Start int
End int
Statements int
Count int
}