db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlarmModeAggregation int
	AlarmModeAggregationCheck
)
View Source
const (
	AlarmStatusUnknown = iota
	AlarmStatusClose
	AlarmStatusNormal
	AlarmStatusFiring
	AlarmStatusRuleCheck
)
View Source
const (
	RuleStoreTypeFile         = 1
	RuleStoreTypeK8sConfigMap = 2
	RuleStoreTypeK8sOperator  = 3
)
View Source
const (
	ChannelDingDing = 1
	ChannelWeChat   = 2
	ChannelFeiShu   = 3
	ChannelSlack    = 4
	ChannelWebHook  = 5
	ChannelTelegram = 6
)
View Source
const (
	FEISHUURL = "https://open.feishu.cn"
	LARKSUITE = "https://open.larksuite.com"
	SLACKURL  = "https://hooks.slack.com/services/"
)
View Source
const (
	PushedStatusRepeat = iota
	PushedStatusSuccess
	PushedStatusFail
)
View Source
const (
	IndexTypeString int = 0
	IndexTypeRaw    int = -4
)
View Source
const (
	IndexKindBase int = 0
	IndexKindLog  int = 1
)
View Source
const (
	TimeFieldTypeDT     = 0 // DateTime
	TimeFieldTypeSecond = 1
	TimeFieldTypeTsMs   = 2 // unix ms
	TimeFieldTypeDT3    = 3 // DataTime64(3)
)
View Source
const (
	BigdataNodeResultUnknown int = iota
	BigdataNodeResultSucc
	BigdataNodeResultFailed
)
View Source
const (
	CollectTypeQuery        = 1 << 0
	CollectTypeTableFilter  = 1 << 1
	CollectTypeGlobalFilter = 1 << 2
)
View Source
const (
	OpnMigration = "system_setting_migration"

	OpnTablesDelete         = "opn_tables_delete"
	OpnTablesCreate         = "opn_tables_create"
	OpnTableCreateSelfBuilt = "opn_tables_create_self_built"
	OpnTablesUpdate         = "opn_tables_update"
	OpnTablesIndexUpdate    = "opn_tables_index_update"
	OpnTablesLogsQuery      = "opn_tables_logs_query"
	OpnDatabasesDelete      = "opn_databases_delete"
	OpnDatabasesCreate      = "opn_databases_create"
	OpnDatabasesUpdate      = "opn_databases_update"
	OpnInstancesDelete      = "opn_instances_delete"
	OpnInstancesCreate      = "opn_instances_create"
	OpnInstancesUpdate      = "opn_instances_update"
	OpnViewsDelete          = "opn_views_delete"
	OpnViewsCreate          = "opn_views_create"
	OpnViewsUpdate          = "opn_views_update"

	OpnConfigsDelete  = "opn_configs_delete"
	OpnConfigsCreate  = "opn_configs_create"
	OpnConfigsUpdate  = "opn_configs_update"
	OpnConfigsPublish = "opn_configs_publish"
	OpnConfigsSync    = "opn_configs_sync"

	OpnClustersDelete          = "opn_clusters_delete"
	OpnClustersCreate          = "opn_clusters_create"
	OpnClustersUpdate          = "opn_clusters_update"
	OpnClustersConfigMapDelete = "opn_clusters_config_map_delete"
	OpnClustersConfigMapCreate = "opn_clusters_config_map_create"
	OpnClustersConfigMapUpdate = "opn_clusters_config_map_update"

	OpnAlarmsDelete         = "opn_alarms_delete"
	OpnAlarmsCreate         = "opn_alarms_create"
	OpnAlarmsUpdate         = "opn_alarms_update"
	OpnAlarmsChannelsDelete = "opn_alarms_channels_delete"
	OpnAlarmsChannelsCreate = "opn_alarms_channels_create"
	OpnAlarmsChannelsUpdate = "opn_alarms_channels_update"

	OpnBigDataNodeCreate        = "opn_big_data_node_create"
	OpnBigDataNodeUpdate        = "opn_big_data_node_update"
	OpnBigDataNodeDelete        = "opn_big_data_node_delete"
	OpnBigDataFolderCreate      = "opn_big_data_folder_create"
	OpnBigDataFolderUpdate      = "opn_big_data_folder_update"
	OpnBigDataFolderDelete      = "opn_big_data_folder_delete"
	OpnBigDataNodeCrontabCreate = "opn_big_data_node_crontab_create"
	OpnBigDataNodeCrontabUpdate = "opn_big_data_node_crontab_update"
	OpnBigDataNodeCrontabDelete = "opn_big_data_node_crontab_delete"
	OpnBigDataNodeCrontabStop   = "opn_big_data_node_crontab_stop"
	OpnBigDataNodeResultUpdate  = "opn_big_data_node_result_update"
	OpnBigDataWorkflowCreate    = "opn_big_data_workflow_create"
	OpnBigDataWorkflowUpdate    = "opn_big_data_workflow_update"
	OpnBigDataWorkflowDelete    = "opn_big_data_workflow_delete"
	OpnBigDataSourceCreate      = "opn_big_data_source_create"
	OpnBigDataSourceUpdate      = "opn_big_data_source_update"
	OpnBigDataSourceDelete      = "opn_big_data_source_delete"
	OpnBigDataNodeLock          = "opn_big_data_node_lock"
	OpnBigDataNodeUnlock        = "opn_big_data_node_unlock"
	OpnBigDataNodeRun           = "opn_big_data_node_run"
	OpnBigDataNodeStop          = "opn_big_data_node_strop"

	OpnUserCreate        = "opn_base_user_create"
	OpnUserDelete        = "opn_base_user_delete"
	OpnUserPasswordReset = "opn_base_user_password_reset"
	OpnUserUpdate        = "opn_base_user_update"
	OpnUserPwdChange     = "user_pwd_change"
)

abbr. -> fullName "Opn" -> "Operation" "mgt" -> "management"

View Source
const (
	SourceInquiryMgtCenter = "log_mgt"
	SourceUserMgtCenter    = "user_mgt"
	SourceSystemSetting    = "system_setting"
	SourceClusterMgtCenter = "cluster_mgt"
	SourceAlarmMgtCenter   = "alarm_mgt"
	SourceConfigMgtCenter  = "config_mgt"
	SourceBigDataMgtCenter = "bigdata_mgt"
)
View Source
const (
	HashTypeSip int = 1
	HashTypeURL int = 2
)
View Source
const (
	DatasourceMySQL      = "mysql"
	DatasourceClickHouse = "ch"
	DatasourceDatabend   = "databend"
	DatasourceAgent      = "agent"
)
View Source
const (
	// ReplicaStatusYes This definition is really outrageous
	ReplicaStatusYes = 0
	ReplicaStatusNo  = 1
)
View Source
const (
	TableNameUser         = "cv_user"
	TableNameEvent        = "cv_event"
	TableNameK8SConfigMap = "cv_k8s_cm"
	TableNameCluster      = "cv_cluster"
	TableNameCollect      = "cv_collect"

	TableNameBaseView        = "cv_base_view"
	TableNameBaseTable       = "cv_base_table"
	TableNameBaseTableAttach = "cv_base_table_attach"
	TableNameBaseIndex       = "cv_base_index"
	TableNameBaseDatabase    = "cv_base_database"
	TableNameBaseInstance    = "cv_base_instance"
	TableNameBaseShortURL    = "cv_base_short_url"
	TableNameBaseHiddenField = "cv_base_hidden_field"

	TableNameAlarm          = "cv_alarm"
	TableNameAlarmFilter    = "cv_alarm_filter"
	TableNameAlarmHistory   = "cv_alarm_history"
	TableNameAlarmChannel   = "cv_alarm_channel"
	TableNameAlarmCondition = "cv_alarm_condition"

	TableNameConfiguration        = "cv_configuration"
	TableNameConfigurationHistory = "cv_configuration_history"
	TableNameConfigurationPublish = "cv_configuration_publish"

	TableNamePmsRole         = "cv_pms_role"
	TableNamePmsRoleRef      = "cv_pms_role_ref"
	TableNamePmsRoleDetail   = "cv_pms_role_detail"
	TableNamePmsRoleRefGrant = "cv_pms_role_ref_grant"
	TableNamePmsCasbinRule   = "cv_pms_casbin_rule"
	TableNamePmsCustomRole   = "cv_pms_custom_role"
	TableNamePmsDefaultRole  = "cv_pms_default_role"

	TableNameBigDataNode        = "cv_bd_node"
	TableNameBigDataNodeResult  = "cv_bd_node_result"
	TableNameBigDataNodeContent = "cv_bd_node_content"
	TableNameBigDataNodeHistory = "cv_bd_node_history"
	TableNameBigDataFolder      = "cv_bd_folder"
	TableNameBigDataSource      = "cv_bd_source"
	TableNameBigDataWorkflow    = "cv_bd_workflow"
	TableNameBigDataDepend      = "cv_bd_depend"
	TableNameBigDataCrontab     = "cv_bd_crontab"
)
View Source
const (
	CrontabStatusWait int = iota
	CrontabStatusPreempt
	CrontabStatusDoing
)
View Source
const (
	SourceTypMySQL      = 1
	SourceTypClickHouse = 2
	SourceDatabend      = 3
)
View Source
const (
	PrimaryMining = 1
	PrimaryShort  = 3
)
View Source
const (
	SecondaryAny             = 0
	SecondaryDatabase        = 1
	SecondaryDataIntegration = 2
	SecondaryDataMining      = 3
	SecondaryDashboard       = 4
)
View Source
const (
	TertiaryClickHouse   = 10
	TertiaryMySQL        = 11
	TertiaryOfflineSync  = 20
	TertiaryRealTimeSync = 21
)
View Source
const (
	NodeStatusDefault = 0
	NodeStatusHandler = 2
	NodeStatusError   = 3
	NodeStatusFinish  = 4
)

0 No status 2 Executing 3 Abnormal execution 4 Completed

View Source
const (
	PmsRoleTypeDefault
	PmsRoleTypeCustom
)
View Source
const (
	RefId = "{{ID}}" // is used to replace with real resourceObjId in ruleTpl when adding to casbin
	// used to generate "p" type ruleTpl like: role__{{PmsRole:Id}}__{{PmsRole:BelongResource}}__{{ID}},{{PmsRole:BelongResource}}__{{ID}}__subResource__(SubResourceRegex),ActsRegex,{{DOM}}
	TplOfRuleTpl = "role__%d__%s__{{ID}},%s__{{ID}}__subResource__%s,%s,*" // contains the const RefId. do not contain any blank chars
)
View Source
const (
	ClusterStatusMaintaining
)

status of kubernetes cluster

View Source
const (
	CrontabTypSuspended int
)
View Source
const (
	SuffixJaegerJSON = "_jaeger_dependencies"
)
View Source
const TimeFieldNanoseconds = "_time_nanosecond_"
View Source
const TimeFieldSecond = "_time_second_"
View Source
const (
	V3TableTypeJaegerJSON
)

Variables

View Source
var (
	ErrCollectCreator      = errors.New("only the creator can modify")
	ErrCollectUpdateParams = errors.New("collect update params error")
)
View Source
var (
	SourceMap = map[string]string{
		SourceInquiryMgtCenter: "Log",
		SourceUserMgtCenter:    "User",
		SourceSystemSetting:    "System",
		SourceClusterMgtCenter: "K8s",
		SourceAlarmMgtCenter:   "Alarm",
		SourceConfigMgtCenter:  "Configuration",
		SourceBigDataMgtCenter: "Analysis",
	}
	SourceOpnMap = map[string][]string{
		SourceInquiryMgtCenter: {
			OpnTablesDelete,
			OpnTablesCreate,
			OpnTablesUpdate,
			OpnTablesIndexUpdate,
			OpnTablesLogsQuery,
			OpnDatabasesDelete,
			OpnDatabasesCreate,
			OpnDatabasesUpdate,
			OpnInstancesDelete,
			OpnInstancesCreate,
			OpnInstancesUpdate,
			OpnViewsDelete,
			OpnViewsCreate,
			OpnViewsUpdate,
		},
		SourceClusterMgtCenter: {
			OpnClustersDelete,
			OpnClustersCreate,
			OpnClustersUpdate,
		},
		SourceAlarmMgtCenter: {
			OpnAlarmsDelete,
			OpnAlarmsCreate,
			OpnAlarmsUpdate,
			OpnAlarmsChannelsDelete,
			OpnAlarmsChannelsCreate,
			OpnAlarmsChannelsUpdate,
		},
		SourceConfigMgtCenter: {
			OpnConfigsDelete,
			OpnConfigsCreate,
			OpnConfigsUpdate,
			OpnConfigsPublish,
		},
		SourceUserMgtCenter: {OpnUserPwdChange, OpnUserCreate, OpnUserDelete, OpnUserPasswordReset, OpnUserUpdate},
		SourceSystemSetting: {OpnMigration},
		SourceBigDataMgtCenter: {
			OpnBigDataNodeCreate,
			OpnBigDataNodeUpdate,
			OpnBigDataNodeDelete,
			OpnBigDataFolderCreate,
			OpnBigDataFolderUpdate,
			OpnBigDataFolderDelete,
			OpnBigDataNodeCrontabCreate,
			OpnBigDataNodeCrontabUpdate,
			OpnBigDataNodeCrontabDelete,
			OpnBigDataNodeCrontabStop,
			OpnBigDataNodeResultUpdate,
			OpnBigDataWorkflowCreate,
			OpnBigDataWorkflowUpdate,
			OpnBigDataWorkflowDelete,
			OpnBigDataSourceCreate,
			OpnBigDataSourceUpdate,
			OpnBigDataSourceDelete,
			OpnBigDataNodeLock,
			OpnBigDataNodeUnlock,
			OpnBigDataNodeRun,
			OpnBigDataNodeStop},
	}
)
View Source
var OperationMap = map[string]string{
	OpnTablesDelete:         "table delete",
	OpnTablesCreate:         "table create",
	OpnTablesUpdate:         "table update",
	OpnTableCreateSelfBuilt: "an existing data table is connected",
	OpnTablesIndexUpdate:    "table analysis field updates",
	OpnTablesLogsQuery:      "log query",
	OpnDatabasesDelete:      "database delete",
	OpnDatabasesCreate:      "database create",
	OpnDatabasesUpdate:      "database update",
	OpnInstancesDelete:      "instance delete",
	OpnInstancesCreate:      "instance create",
	OpnInstancesUpdate:      "instance update",
	OpnViewsDelete:          "custom time field delete",
	OpnViewsCreate:          "custom time field create",
	OpnViewsUpdate:          "custom time field update",

	OpnConfigsDelete:  "config delete",
	OpnConfigsCreate:  "config create",
	OpnConfigsUpdate:  "config update",
	OpnConfigsPublish: "config publish",
	OpnConfigsSync:    "synchronize the configuration from the target cluster",

	OpnClustersDelete:          "cluster delete",
	OpnClustersCreate:          "cluster create",
	OpnClustersUpdate:          "cluster update",
	OpnClustersConfigMapDelete: "cluster configmap delete",
	OpnClustersConfigMapCreate: "cluster configmap create",
	OpnClustersConfigMapUpdate: "cluster configmap update",

	OpnAlarmsDelete:         "alarm delete",
	OpnAlarmsCreate:         "alarm create",
	OpnAlarmsUpdate:         "alarm update",
	OpnAlarmsChannelsDelete: "alarm channel delete",
	OpnAlarmsChannelsCreate: "alarm channel create",
	OpnAlarmsChannelsUpdate: "alarm channel update",

	OpnMigration: "upgrading the database structure",

	OpnBigDataNodeCreate:        "node create",
	OpnBigDataNodeUpdate:        "node update",
	OpnBigDataNodeDelete:        "node delete",
	OpnBigDataFolderCreate:      "folder create",
	OpnBigDataFolderUpdate:      "folder update",
	OpnBigDataFolderDelete:      "folder delete",
	OpnBigDataNodeCrontabCreate: "node crontab create",
	OpnBigDataNodeCrontabUpdate: "node crontab update",
	OpnBigDataNodeCrontabDelete: "node crontab delete",
	OpnBigDataNodeCrontabStop:   "node crontab stop",
	OpnBigDataNodeResultUpdate:  "node run result update",
	OpnBigDataWorkflowCreate:    "workflow create",
	OpnBigDataWorkflowUpdate:    "workflow update",
	OpnBigDataWorkflowDelete:    "workflow delete",
	OpnBigDataSourceCreate:      "source create",
	OpnBigDataSourceUpdate:      "source update",
	OpnBigDataSourceDelete:      "source delete",
	OpnBigDataNodeLock:          "node lock",
	OpnBigDataNodeUnlock:        "node unlock",
	OpnBigDataNodeRun:           "node run",
	OpnBigDataNodeStop:          "node stop",

	OpnUserCreate:        "user create",
	OpnUserDelete:        "user delete",
	OpnUserPasswordReset: "user password reset",
	OpnUserPwdChange:     "change the password",
	OpnUserUpdate:        "user update",
}
View Source
var UnitMap = map[int]UnitItem{
	0: {
		Alias:    "m",
		Duration: time.Minute,
	},
	1: {
		Alias:    "s",
		Duration: time.Second,
	},
	2: {
		Alias:    "h",
		Duration: time.Hour,
	},
	3: {
		Alias:    "d",
		Duration: time.Hour * 24,
	},
	4: {
		Alias:    "w",
		Duration: time.Hour * 24 * 7,
	},
}

Functions

func AlarmChannelCreate

func AlarmChannelCreate(db *gorm.DB, data *AlarmChannel) (err error)

func AlarmChannelDelete

func AlarmChannelDelete(db *gorm.DB, id int) (err error)

func AlarmChannelUpdate

func AlarmChannelUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func AlarmConditionCreate

func AlarmConditionCreate(db *gorm.DB, data *AlarmCondition) (err error)

func AlarmConditionDeleteBatch

func AlarmConditionDeleteBatch(db *gorm.DB, alarmId int) (err error)

func AlarmCreate

func AlarmCreate(db *gorm.DB, data *Alarm) (err error)

func AlarmDelete

func AlarmDelete(db *gorm.DB, id int) (err error)

func AlarmFilterCreate

func AlarmFilterCreate(db *gorm.DB, data *AlarmFilter) (err error)

func AlarmFilterDeleteBatch

func AlarmFilterDeleteBatch(db *gorm.DB, alarmId int) (err error)

func AlarmFilterUpdateStatus

func AlarmFilterUpdateStatus(db *gorm.DB, alarmId int, ups map[string]interface{}) (err error)

func AlarmHistoryCreate

func AlarmHistoryCreate(db *gorm.DB, data *AlarmHistory) (err error)

func AlarmHistoryUpdate

func AlarmHistoryUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func AlarmUpdate

func AlarmUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func BuildPreloadArgs

func BuildPreloadArgs(conds Conds) (args []interface{})

func BuildQuery

func BuildQuery(conds Conds) (sql string, binds []interface{})

BuildQuery 根据conds构建sql和绑定的参数

func ClusterCreate

func ClusterCreate(db *gorm.DB, data *Cluster) (err error)

ClusterCreate CRUD

func ClusterDelete

func ClusterDelete(db *gorm.DB, id int) (err error)

ClusterDelete soft delete item by id

func ClusterUpdate

func ClusterUpdate(db *gorm.DB, paramId int, ups map[string]interface{}) (err error)

ClusterUpdate ...

func ConfigurationCreate

func ConfigurationCreate(db *gorm.DB, data *Configuration) (err error)

ConfigurationCreate CRUD

func ConfigurationDelete

func ConfigurationDelete(db *gorm.DB, id int) (err error)

ConfigurationDelete 硬删除

func ConfigurationUpdate

func ConfigurationUpdate(db *gorm.DB, paramId int, ups map[string]interface{}) (err error)

ConfigurationUpdate ...

func CreatePmsRole

func CreatePmsRole(db *gorm.DB, data *PmsRole) (err error)

func CreatePmsRoleDetail

func CreatePmsRoleDetail(db *gorm.DB, data *PmsRoleDetail) (err error)

func CrontabCreate

func CrontabCreate(db *gorm.DB, data *BigdataCrontab) (err error)

func CrontabDelete

func CrontabDelete(db *gorm.DB, nodeId int) (err error)

func CrontabUpdate

func CrontabUpdate(db *gorm.DB, nodeId int, ups map[string]interface{}) (err error)

func DatabaseCreate

func DatabaseCreate(db *gorm.DB, data *BaseDatabase) (err error)

DatabaseCreate ...

func DatabaseDelete

func DatabaseDelete(db *gorm.DB, id int) (err error)

DatabaseDelete Soft delete

func DatabaseUpdate

func DatabaseUpdate(db *gorm.DB, paramId int, ups map[string]interface{}) (err error)

DatabaseUpdate ...

func DeletePmsRoleById

func DeletePmsRoleById(tx *gorm.DB, pmsRoleId int) (err error)

please make sure the associated casbinRules have removed after deleted pmsRole. do not only invoke this func to delete pmsRole.

func DeletePmsRoleRef

func DeletePmsRoleRef(tx *gorm.DB, id int) (err error)

func DependsBatchInsert

func DependsBatchInsert(db *gorm.DB, rows []*BigdataDepend) (err error)

func DependsDeleteAll

func DependsDeleteAll(db *gorm.DB, iid int) (err error)

func FolderCreate

func FolderCreate(db *gorm.DB, data *BigdataFolder) (err error)

func FolderDelete

func FolderDelete(db *gorm.DB, id int) (err error)

func FolderUpdate

func FolderUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func GetAlarmTableInstanceInfo

func GetAlarmTableInstanceInfo(id int) (alarmInfo Alarm, relatedList []*RespAlarmListRelatedInfo, err error)

func GetAlarmTableInstanceInfoWithCache

func GetAlarmTableInstanceInfoWithCache(id int, cache map[int]*RespAlarmListRelatedInfo) (alarmInfo Alarm, relatedList []*RespAlarmListRelatedInfo, err error)

func HiddenFieldCreateBatch

func HiddenFieldCreateBatch(db *gorm.DB, data []*BaseHiddenField) (err error)

func HiddenFieldDeleteByFields

func HiddenFieldDeleteByFields(db *gorm.DB, fields []string) (err error)

func IndexCreate

func IndexCreate(db *gorm.DB, data *BaseIndex) (err error)

func IndexDeleteBatch

func IndexDeleteBatch(db *gorm.DB, tid int, isDeleteAll bool) (err error)

IndexDeleteBatch 删除索引 isDeleteAll 是否删除所有索引 false 只删除日志索引

func InstanceCreate

func InstanceCreate(db *gorm.DB, data *BaseInstance) (err error)

func InstanceDelete

func InstanceDelete(db *gorm.DB, id int) (err error)

func InstanceKey

func InstanceKey(id int) string

func InstanceUpdate

func InstanceUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func K8SConfigMapCreate

func K8SConfigMapCreate(db *gorm.DB, data *K8SConfigMap) (err error)

K8SConfigMapCreate CRUD

func NodeContentCreate

func NodeContentCreate(db *gorm.DB, data *BigdataNodeContent) (err error)

func NodeContentDelete

func NodeContentDelete(db *gorm.DB, id int) (err error)

func NodeContentUpdate

func NodeContentUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func NodeCreate

func NodeCreate(db *gorm.DB, data *BigdataNode) (err error)

func NodeDelete

func NodeDelete(db *gorm.DB, id int) (err error)

func NodeHistoryCreate

func NodeHistoryCreate(db *gorm.DB, data *BigdataNodeHistory) (err error)

func NodeResultCreate

func NodeResultCreate(db *gorm.DB, data *BigdataNodeResult) (err error)

func NodeResultDelete30Days

func NodeResultDelete30Days()

func NodeResultUpdate

func NodeResultUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func NodeUpdate

func NodeUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func PmsCustomRoleCreate

func PmsCustomRoleCreate(item *PmsCustomRole) (err error)

func PmsCustomRoleDelete

func PmsCustomRoleDelete(paramId int) (err error)

func PmsDefaultRoleCreate

func PmsDefaultRoleCreate(item *PmsDefaultRole) (err error)

func PmsDefaultRoleDelete

func PmsDefaultRoleDelete(paramId int) (err error)

func ShortURLCreate

func ShortURLCreate(db *gorm.DB, data *BaseShortURL) (err error)

func ShortURLDelete30Days

func ShortURLDelete30Days()

func ShortURLUpdate

func ShortURLUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func SourceCreate

func SourceCreate(db *gorm.DB, data *BigdataSource) (err error)

func SourceDelete

func SourceDelete(db *gorm.DB, id int) (err error)

func SourceUpdate

func SourceUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

func TableCreate

func TableCreate(db *gorm.DB, data *BaseTable) (err error)

TableCreate ...

func TableDelete

func TableDelete(db *gorm.DB, id int) (err error)

TableDelete Soft delete

func TableUpdate

func TableUpdate(db *gorm.DB, paramId int, ups map[string]interface{}) (err error)

TableUpdate ...

func UserCreate

func UserCreate(db *gorm.DB, data *User) (err error)

UserCreate CRUD

func UserDelete

func UserDelete(db *gorm.DB, id int) (err error)

UserDelete soft delete item by id

func UserUpdate

func UserUpdate(db *gorm.DB, paramId int, ups map[string]interface{}) (err error)

UserUpdate ...

func ViewCreate

func ViewCreate(db *gorm.DB, data *BaseView) (err error)

func ViewDelete

func ViewDelete(db *gorm.DB, id int) (err error)

ViewDelete Soft delete

func ViewDeleteByTableID

func ViewDeleteByTableID(db *gorm.DB, tid int) (err error)

ViewDeleteByTableID Soft delete

func ViewUpdate

func ViewUpdate(db *gorm.DB, paramId int, ups map[string]interface{}) (err error)

ViewUpdate ...

func WorkflowCreate

func WorkflowCreate(db *gorm.DB, data *BigdataWorkflow) (err error)

func WorkflowDelete

func WorkflowDelete(db *gorm.DB, id int) (err error)

func WorkflowUpdate

func WorkflowUpdate(db *gorm.DB, id int, ups map[string]interface{}) (err error)

Types

type Alarm

type Alarm struct {
	BaseModel

	Uid              int           `gorm:"column:uid;type:int(11)" json:"uid"`                                // uid of alarm operator
	Uuid             string        `gorm:"column:uuid;type:varchar(128);NOT NULL" json:"uuid"`                // foreign key
	Name             string        `gorm:"column:name;type:varchar(128);NOT NULL" json:"alarmName"`           // name of an alarm
	Desc             string        `gorm:"column:desc;type:varchar(255);NOT NULL" json:"desc"`                // description
	Interval         int           `gorm:"column:interval;type:int(11)" json:"interval"`                      // interval second between alarm
	Unit             int           `gorm:"column:unit;type:int(11)" json:"unit"`                              // 0 m 1 s 2 h 3 d 4 w 5 y
	Tags             String2String `gorm:"column:tag;type:text" json:"tag"`                                   // tags
	ChannelIds       Ints          `gorm:"column:channel_ids;type:varchar(255);NOT NULL" json:"channelIds"`   // channel of an alarm
	NoDataOp         int           `gorm:"column:no_data_op;type:int(11)" db:"no_data_op" json:"noDataOp"`    // noDataOp 0 nodata 1 ok 2 alert
	Level            int           `gorm:"column:level;type:int(11)" json:"level"`                            // 0 m 1 s 2 h 3 d 4 w 5 y
	Status           int           `gorm:"column:status;type:int(11)" json:"status"`                          // status
	DutyOfficers     Ints          `gorm:"column:duty_officers;type:varchar(255)" json:"dutyOfficers"`        // duty officer id list
	IsDisableResolve int           `gorm:"column:is_disable_resolve;type:tinyint(1)" json:"isDisableResolve"` // is disable resolve message

	User *User `json:"user,omitempty" gorm:"foreignKey:uid;references:id"`

	// v2 field to support multiple alarm conditions
	ViewDDLs   String2String `gorm:"column:view_ddl_s;type:text" json:"viewDDLs"` // Users to store data generates the alarm condition
	TableIds   Ints          `gorm:"column:table_ids;type:varchar(255);NOT NULL" json:"tableIds"`
	AlertRules String2String `gorm:"column:alert_rules;type:text" json:"alertRules"` // prometheus alert rule

	// lint:ignore SA1019 Deprecated: Tid
	// Deprecated: Tid
	Tid int `gorm:"column:tid;type:int(11)" json:"tid"` // table id
	// nolint
	// Deprecated: AlertRule will be replaced by AlertRules field, is expected to delete 0.5.0 version
	AlertRule string `gorm:"column:alert_rule;type:text" json:"alertRule"` // prometheus alert rule
	// lint:ignore SA1019 Deprecated: View
	// Deprecated: View
	View string `gorm:"column:view;type:text" json:"view"` // view table ddl
	// lint:ignore SA1019 Deprecated: ViewTableName
	// Deprecated: ViewTableName
	ViewTableName string `gorm:"column:view_table_name;type:varchar(255)" json:"viewTableName"` // name of view table
}

func AlarmInfo

func AlarmInfo(db *gorm.DB, id int) (resp Alarm, err error)

func AlarmInfoX

func AlarmInfoX(db *gorm.DB, conds map[string]interface{}) (resp Alarm, err error)

func AlarmList

func AlarmList(conds egorm.Conds) (resp []*Alarm, err error)

func AlarmListByDidPage

func AlarmListByDidPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*Alarm)

func AlarmListByTidArr

func AlarmListByTidArr(conds egorm.Conds, tidArr []int) (resp []*Alarm, err error)

func AlarmListPageByTidArr

func AlarmListPageByTidArr(conds egorm.Conds, reqList *ReqPage, tidArr []int) (total int64, respList []*Alarm)

AlarmListPageByTidArr return item list by pagination SELECT * FROM `cv_alarm` WHERE JSON_CONTAINS(`table_ids`, '[1]') OR JSON_CONTAINS(`table_ids`, '[7]')

func (*Alarm) AlertInterval

func (m *Alarm) AlertInterval() string

func (*Alarm) GetGroupName

func (m *Alarm) GetGroupName(instanceId int) string

func (*Alarm) GetInterval

func (m *Alarm) GetInterval() time.Duration

func (*Alarm) GetStatus

func (m *Alarm) GetStatus(db *gorm.DB) int

func (*Alarm) RuleName

func (m *Alarm) RuleName(filterId int) string

func (*Alarm) RuleNameMap

func (m *Alarm) RuleNameMap() map[int][]string

RuleNameMap 提供 rule 兼容

func (*Alarm) TableName

func (m *Alarm) TableName() string

func (*Alarm) UniqueName

func (m *Alarm) UniqueName(filterId int) string

func (*Alarm) UpdateStatus

func (m *Alarm) UpdateStatus(db *gorm.DB, status int) (err error)

func (*Alarm) ViewName

func (m *Alarm) ViewName(database, table string, seq int) string

type AlarmChannel

type AlarmChannel struct {
	BaseModel

	Name string `gorm:"column:name;type:varchar(128);NOT NULL" json:"name"` // 告警渠道名称
	Key  string `gorm:"column:key;type:text" json:"key"`                    // 关键信息
	Typ  int    `gorm:"column:typ;type:int(11)" json:"typ"`                 // 告警类型:0 dd
	Uid  int    `gorm:"column:uid;type:int(11)" json:"uid"`                 // 操作人
}

AlarmChannel 告警渠道

func AlarmChannelInfo

func AlarmChannelInfo(db *gorm.DB, id int) (resp AlarmChannel, err error)

func AlarmChannelList

func AlarmChannelList(conds egorm.Conds) (resp []*AlarmChannel, err error)

func (*AlarmChannel) JudgmentType

func (m *AlarmChannel) JudgmentType() (err error)

JudgmentType judgment channel key legality temporary support slack feishu

func (*AlarmChannel) TableName

func (m *AlarmChannel) TableName() string

type AlarmCondition

type AlarmCondition struct {
	BaseModel

	AlarmId        int `gorm:"column:alarm_id;type:int(11)" json:"alarmId"`              // alarm id
	FilterId       int `gorm:"column:filter_id;type:int(11)" json:"filterId"`            // filter id
	SetOperatorTyp int `gorm:"column:set_operator_typ;type:int(11);NOT NULL" json:"typ"` // 0 WHEN 1 AND 2 OR
	SetOperatorExp int `gorm:"column:set_operator_exp;type:int(11);NOT NULL" json:"exp"` // 0 avg 1 min 2 max 3 sum 4 count
	Cond           int `gorm:"column:cond;type:int(11)" json:"cond"`                     // 0 above 1 below 2 outside range 3 within range
	Val1           int `gorm:"column:val_1;type:int(11)" json:"val1"`                    // 基准值/最小值
	Val2           int `gorm:"column:val_2;type:int(11)" json:"val2"`                    // 最大值
}

AlarmCondition alarm statement,the trigger condition

func AlarmConditionList

func AlarmConditionList(conds egorm.Conds) (resp []*AlarmCondition, err error)

func (*AlarmCondition) TableName

func (m *AlarmCondition) TableName() string

type AlarmFilter

type AlarmFilter struct {
	BaseModel

	Tid            int    `gorm:"column:tid;type:int(11)" json:"tid"`                            // table id
	AlarmId        int    `gorm:"column:alarm_id;type:int(11)" json:"alarmId"`                   // alarm id
	When           string `gorm:"column:when;type:text" json:"when"`                             // 执行条件
	SetOperatorTyp int    `gorm:"column:set_operator_typ;type:int(11);NOT NULL" json:"typ"`      // 0 default 1 INNER 2 LEFT OUTER 3 RIGHT OUTER 4 FULL OUTER 5 CROSS
	SetOperatorExp string `gorm:"column:set_operator_exp;type:varchar(255);NOT NULL" json:"exp"` // 操作
	Mode           int    `gorm:"column:mode;type:int(11)" json:"mode"`                          // 0 m 1 s 2 h 3 d 4 w 5 y
	Status         int    `gorm:"column:status;type:int(11)" json:"status"`
}

func AlarmFilterInfo

func AlarmFilterInfo(db *gorm.DB, id int) (resp AlarmFilter, err error)

func AlarmFilterList

func AlarmFilterList(db *gorm.DB, conds egorm.Conds) (resp []*AlarmFilter, err error)

func (*AlarmFilter) TableName

func (m *AlarmFilter) TableName() string

func (*AlarmFilter) UpdateStatus

func (m *AlarmFilter) UpdateStatus(db *gorm.DB) error

type AlarmHistory

type AlarmHistory struct {
	BaseModel

	AlarmId      int `gorm:"column:alarm_id;type:int(11)" json:"alarmId"`   // alarm id
	FilterId     int `gorm:"column:filter_id;type:int(11)" json:"filterId"` // filter id
	FilterStatus int `gorm:"column:filter_status;type:int(11)" json:"filterStatus"`
	IsPushed     int `gorm:"column:is_pushed;type:int(11)" json:"isPushed"` // alarm id
}

AlarmHistory 告警渠道

func AlarmHistoryInfo

func AlarmHistoryInfo(db *gorm.DB, id int) (resp AlarmHistory, err error)

func AlarmHistoryPage

func AlarmHistoryPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*AlarmHistory)

func (*AlarmHistory) TableName

func (m *AlarmHistory) TableName() string

type Alert

type Alert struct {
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
	StartsAt    time.Time         `json:"startsAt"`
	EndsAt      time.Time         `json:"endsAt"`
}

type At

type At struct {
	AtMobiles []string `json:"atMobiles"`
	IsAtAll   bool     `json:"isAtAll"`
}

type BaseDatabase

type BaseDatabase struct {
	BaseModel

	Iid          int    `gorm:"column:iid;type:int(11);index:uix_iid_name,unique" json:"iid"`                // datasource instance id
	Name         string `gorm:"column:name;type:varchar(64);index:uix_iid_name,unique;NOT NULL" json:"name"` // datasource database name
	Uid          int    `gorm:"column:uid;type:int(11)" json:"uid"`                                          // datasource operator uid
	Cluster      string `gorm:"column:cluster;type:varchar(128);NOT NULL" json:"cluster"`                    // cluster
	IsCreateByCV int    `gorm:"column:is_create_by_cv;type:tinyint(1)" json:"isCreateByCV"`
	Desc         string `gorm:"column:desc;type:varchar(255)" json:"desc"`

	Instance *BaseInstance `json:"instance,omitempty" gorm:"foreignKey:Iid;references:ID"`
}

BaseDatabase 数据库管理

func DatabaseGetOrCreate

func DatabaseGetOrCreate(db *gorm.DB, uid, iid int, name, cluster string) (resp BaseDatabase, err error)

func DatabaseInfo

func DatabaseInfo(db *gorm.DB, paramId int) (resp BaseDatabase, err error)

func DatabaseInfoX

func DatabaseInfoX(db *gorm.DB, conds map[string]interface{}) (resp BaseDatabase, err error)

DatabaseInfoX Info extension method to query a single record according to Cond

func DatabaseList

func DatabaseList(db *gorm.DB, conds egorm.Conds) (resp []*BaseDatabase, err error)

DatabaseList Get all currently undeleted clusters. Mainly used for front end

func (*BaseDatabase) TableName

func (b *BaseDatabase) TableName() string

type BaseHiddenField

type BaseHiddenField struct {
	BaseModel

	Tid   int    `gorm:"column:tid;type:int(11);index:uix_tid_field,unique" json:"tid"`                   // table id idx
	Field string `gorm:"column:field;type:varchar(128);NOT NULL;index:uix_tid_field,unique" json:"field"` // index field name
}

func HiddenFieldList

func HiddenFieldList(conds egorm.Conds) (resp []*BaseHiddenField, err error)

func (*BaseHiddenField) TableName

func (b *BaseHiddenField) TableName() string

type BaseIndex

type BaseIndex struct {
	BaseModel

	Tid      int    `gorm:"column:tid;type:int(11);index:uix_tid_field_root,unique" json:"tid"`                         // table id
	Field    string `gorm:"column:field;type:varchar(64);NOT NULL;index:uix_tid_field_root,unique" json:"field"`        // index field name
	RootName string `gorm:"column:root_name;type:varchar(64);NOT NULL;index:uix_tid_field_root,unique" json:"rootName"` // root_name
	Typ      int    `gorm:"column:typ;type:int(11);NOT NULL" json:"typ"`                                                // 0 string 1 int 2 float
	HashTyp  int    `gorm:"column:hash_typ;type:tinyint(1)" json:"hashTyp"`                                             // hash type, 0 no hash 1 sipHash64 2 URLHash
	Alias    string `gorm:"column:alias;type:varchar(128);NOT NULL" json:"alias"`                                       // index filed alias name
	Kind     int    `gorm:"column:kind;type:tinyint(1)" json:"kind"`                                                    // 0 base field 1 log field
}

BaseIndex 索引数据存储

func IndexInfo

func IndexInfo(db *gorm.DB, id int) (resp BaseIndex, err error)

func IndexList

func IndexList(conds egorm.Conds) (resp []*BaseIndex, err error)

func (*BaseIndex) GetFieldName

func (t *BaseIndex) GetFieldName() string

func (*BaseIndex) GetHashFieldName

func (t *BaseIndex) GetHashFieldName() (string, bool)

func (*BaseIndex) TableName

func (b *BaseIndex) TableName() string

type BaseInstance

type BaseInstance struct {
	BaseModel

	Datasource string `gorm:"column:datasource;type:varchar(32);NOT NULL;index:idx_datasource_name,unique" json:"datasource"` // datasource type
	Name       string `gorm:"column:name;type:varchar(128);NOT NULL;index:idx_datasource_name,unique" json:"name"`            // datasource instance name
	Dsn        string `gorm:"column:dsn;type:text" json:"dsn"`                                                                // dsn
	Desc       string `gorm:"column:desc;type:varchar(255)" json:"desc"`                                                      // file_path

	// Deprecated: Use real time data instead.
	Mode int `gorm:"column:mode;type:tinyint(1)" json:"mode"` // 0 standalone 1 cluster
	// Deprecated: Use real time data instead.
	ReplicaStatus int `gorm:"column:replica_status;type:tinyint(1)" json:"replicaStatus"` // status 0 has replica 1 no replica
	// Deprecated: Use real time data instead.
	Clusters Strings `gorm:"column:clusters;type:text" json:"clusters"`

	// alarm
	PrometheusTarget string `gorm:"column:prometheus_target;type:varchar(128)" json:"prometheusTarget"` // prometheus ip or domain, eg: https://prometheus:9090
	RuleStoreType    int    `gorm:"column:rule_store_type;type:int(11)" json:"ruleStoreType"`           // rule_store_type 1 文件 2 集群
	// file
	FilePath string `gorm:"column:file_path;type:varchar(255)" json:"filePath"` // file_path
	// configmap
	K8sClusterId int    `gorm:"column:cluster_id;type:int(11)" json:"clusterId"`     // k8s cluster id
	K8sNamespace string `gorm:"column:namespace;type:varchar(128)" json:"namespace"` // namespace
	K8sConfigmap string `gorm:"column:configmap;type:varchar(128)" json:"configmap"` // configmap
	// operator
	ConfigPrometheusOperator string `gorm:"column:config_prometheus_operator;type:text" json:"ConfigPrometheusOperator"` // configmap
}

BaseInstance 服务配置存储

func InstanceInfo

func InstanceInfo(db *gorm.DB, id int) (resp BaseInstance, err error)

func InstanceInfoX

func InstanceInfoX(db *gorm.DB, conds map[string]interface{}) (resp BaseInstance, err error)

InstanceInfoX Info extension method to query a single record according to Cond

func InstanceList

func InstanceList(conds egorm.Conds, extra ...string) (resp []*BaseInstance, err error)

InstanceList ..

func (*BaseInstance) DsKey

func (b *BaseInstance) DsKey() string

func (*BaseInstance) GetRuleStoreKey

func (b *BaseInstance) GetRuleStoreKey() string

func (*BaseInstance) TableName

func (b *BaseInstance) TableName() string

type BaseModel

type BaseModel struct {
	ID    int               `gorm:"not null;primary_key;AUTO_INCREMENT;comment:自增id" json:"id"`
	Ctime int64             `gorm:"bigint;autoCreateTime;comment:创建时间" json:"ctime"`
	Utime int64             `gorm:"bigint;autoUpdateTime;comment:更新时间" json:"utime"`
	Dtime sdelete.DeletedAt `gorm:"bigint;comment:删除时间" json:"dtime"`
}

type BaseShortURL

type BaseShortURL struct {
	BaseModel

	OriginUrl string `gorm:"column:origin_url;type:text" json:"origin_url"`
	SCode     string `gorm:"column:s_code;type:varchar(64);NOT NULL" json:"s_code"`
	CallCnt   int    `gorm:"column:call_cnt;type:int(11)" json:"call_cnt"`
}

func ShortURLInfoBySCode

func ShortURLInfoBySCode(db *gorm.DB, sCode string) (resp BaseShortURL, err error)

func (*BaseShortURL) TableName

func (b *BaseShortURL) TableName() string

type BaseTable

type BaseTable struct {
	BaseModel
	Uid          int    `gorm:"column:uid;type:int(11)" json:"uid"`                                           // operator uid
	Did          int    `gorm:"column:did;type:int(11);index:uix_did_name,unique" json:"did"`                 // database id
	Name         string `gorm:"column:name;type:varchar(128);NOT NULL;index:uix_did_name,unique" json:"name"` // table
	Desc         string `gorm:"column:desc;type:varchar(255)" json:"desc"`
	TraceTableId int    `gorm:"column:trace_table_id;type:int(11)" json:"traceTableId"` // associated trace table id

	// base attribute
	TimeFieldKind int `gorm:"column:typ;type:int(11)" json:"typ"`                                          // time field kind: 1 string 2 float
	TimeFieldType int `gorm:"column:time_field_type;type:int(11);default:0;NOT NULL" json:"timeFieldType"` // time field type: 0 DateTime 1 second 2 ms 3 DataTime64(3)

	CreateType int `gorm:"column:create_type;type:tinyint(1)" json:"createType"` // operation type, 0 means create clickvisual fresh table, 1 means use exists table

	// ClickHouse setting
	Days                    int    `gorm:"column:days;type:int(11)" json:"days"`                     // data expire days
	Topic                   string `gorm:"column:topic;type:varchar(128);NOT NULL" json:"topic"`     // kafka topic
	Brokers                 string `gorm:"column:brokers;type:varchar(255);NOT NULL" json:"brokers"` // kafka broker
	ConsumerNum             int    `gorm:"column:consumer_num;type:int(11)" json:"consumerNum"`      // kafka consumer number
	TimeField               string `gorm:"column:time_field;type:varchar(128);NOT NULL" json:"timeField"`
	RawLogField             string `gorm:"column:raw_log_field;type:varchar(255)" json:"rawLogField"`
	KafkaSkipBrokenMessages int    `gorm:"column:kafka_skip_broken_messages;type:int(11)" json:"kafkaSkipBrokenMessages"`

	// Deprecated: use CreateType instead
	IsKafkaTimestamp int `gorm:"column:is_kafka_timestamp;type:tinyint(1)" json:"isKafkaTimestamp"`
	// Deprecated: use CreateType instead
	V3TableType int `gorm:"column:v3_table_type;type:int(11)" json:"v3TableType"` // 0 default 1 jaegerJson
	// Deprecated: use base_table_attach instead
	SelectFields string `gorm:"column:select_fields;type:text" json:"selectFields"` // sql_distributed
	// Deprecated: use base_table_attach instead
	AnyJSON string `gorm:"column:any_json;type:text" json:"anyJSON"`
	// Deprecated: use base_table_attach instead
	SqlData string `gorm:"column:sql_data;type:text" json:"sqlData"` // sql_data
	// Deprecated: use base_table_attach instead
	SqlStream string `gorm:"column:sql_stream;type:text" json:"sqlStream"` // sql_stream
	// Deprecated: use base_table_attach instead
	SqlView string `gorm:"column:sql_view;type:text" json:"sqlView"` // sql_view
	// Deprecated: use base_table_attach instead
	SqlDistributed string `gorm:"column:sql_distributed;type:text" json:"sqlDistributed"` // sql_distributed

	Database *BaseDatabase `json:"database,omitempty" gorm:"foreignKey:Did;references:ID"`
}

func TableInfo

func TableInfo(db *gorm.DB, paramId int) (resp BaseTable, err error)

func TableInfoX

func TableInfoX(db *gorm.DB, conds map[string]interface{}) (resp BaseTable, err error)

TableInfoX Info extension method to query a single record according to Cond

func TableList

func TableList(db *gorm.DB, conds egorm.Conds) (resp []*BaseTable, err error)

TableList Get all currently undeleted clusters. Mainly used for front end

func TableListByInstanceId

func TableListByInstanceId(db *gorm.DB, iid int) (resp []*BaseTable, err error)

func (*BaseTable) GetTimeField

func (b *BaseTable) GetTimeField() string

func (*BaseTable) TableName

func (b *BaseTable) TableName() string

type BaseTableAttach

type BaseTableAttach struct {
	Tid   int     `gorm:"column:tid;type:int(11);index:uix_tid,unique" json:"tid"`
	SQLs  Strings `gorm:"column:sqls;type:longtext" json:"sqls"`
	Names Strings `gorm:"column:names;type:text" json:"names"`
}

func (*BaseTableAttach) Create

func (model *BaseTableAttach) Create(db *gorm.DB) (err error)

func (*BaseTableAttach) Delete

func (model *BaseTableAttach) Delete(db *gorm.DB) (err error)

func (*BaseTableAttach) Info

func (model *BaseTableAttach) Info(db *gorm.DB) (err error)

func (*BaseTableAttach) InfoX

func (model *BaseTableAttach) InfoX(db *gorm.DB, conds map[string]interface{}) (err error)

func (*BaseTableAttach) List

func (model *BaseTableAttach) List(conds egorm.Conds) (resp []*BaseTableAttach, err error)

func (*BaseTableAttach) ListPage

func (model *BaseTableAttach) ListPage(db *gorm.DB, conds egorm.Conds, reqList *ReqPage) (total int64, respList []*BaseTableAttach)

func (*BaseTableAttach) TableName

func (model *BaseTableAttach) TableName() string

func (*BaseTableAttach) Update

func (model *BaseTableAttach) Update(db *gorm.DB, ups map[string]interface{}) (err error)

type BaseView

type BaseView struct {
	BaseModel

	Tid              int    `gorm:"column:tid;type:int(11);index:uix_tid_name,unique" json:"tid"`                // table id
	Name             string `gorm:"column:name;type:varchar(64);NOT NULL;index:uix_tid_name,unique" json:"name"` // view name
	IsUseDefaultTime int    `gorm:"column:is_use_default_time;type:int(11)" json:"isUseDefaultTime"`             // use system time or not
	Key              string `gorm:"column:key;type:varchar(64);NOT NULL" json:"key"`                             // field name of time in raw log
	Format           string `gorm:"column:format;type:varchar(64);NOT NULL" json:"format"`                       // timestamp parse to extract time from raw log and parse it to datetime
	SqlView          string `gorm:"column:sql_view;type:text" json:"sqlView"`                                    // sql_view
	Uid              int    `gorm:"column:uid;type:int(11)" json:"uid"`                                          // operator uid
}

BaseView Materialized view management

func ViewInfo

func ViewInfo(db *gorm.DB, paramId int) (resp BaseView, err error)

func ViewInfoX

func ViewInfoX(conds map[string]interface{}) (resp BaseView, err error)

ViewInfoX Info extension method to query a single record according to Cond

func ViewList

func ViewList(db *gorm.DB, conds egorm.Conds) (resp []*BaseView, err error)

ViewList Get all currently undeleted clusters. Mainly used for front end

func (*BaseView) TableName

func (b *BaseView) TableName() string

type BigdataCrontab

type BigdataCrontab struct {
	NodeId        int    `gorm:"column:node_id;type:int(11);uix_node_id,unique" json:"nodeId"`
	Desc          string `gorm:"column:desc;type:varchar(255);NOT NULL" json:"desc"` // description
	DutyUid       int    `gorm:"column:duty_uid;type:int(11)" json:"dutyUid"`        // person in charge
	Cron          string `gorm:"column:cron;type:varchar(255);NOT NULL" json:"cron"` // cron expression
	Typ           int    `gorm:"column:typ;type:int(11)" json:"typ"`                 // typ 0 Normal scheduling 1 Suspended scheduling
	Status        int    `gorm:"column:status;type:int(11)" json:"status"`           // status 0 default 1 preempt 2 doing
	Uid           int    `gorm:"column:uid;type:int(11)" json:"uid"`                 // user id
	Args          string `gorm:"args:sql_view;type:text" json:"args"`                // sql_view
	IsRetry       int    `gorm:"column:is_retry;type:tinyint(1)" json:"isRetry"`
	RetryTimes    int    `gorm:"column:retry_times;type:int(11)" json:"retryTimes"`
	RetryInterval int    `gorm:"column:retry_interval;type:int(11)" json:"retryInterval"`
	Ctime         int64  `gorm:"column:ctime;bigint;autoCreateTime;comment:创建时间" json:"ctime"`
	Utime         int64  `gorm:"column:utime;bigint;autoUpdateTime;comment:更新时间" json:"utime"`
	ChannelIds    Ints   `gorm:"column:channel_ids;type:varchar(255);NOT NULL" json:"channelIds"` // channel of an alarm
}

func CrontabInfo

func CrontabInfo(db *gorm.DB, nodeId int) (resp BigdataCrontab, err error)

func CrontabList

func CrontabList(conds egorm.Conds) (resp []*BigdataCrontab, err error)

func (*BigdataCrontab) TableName

func (m *BigdataCrontab) TableName() string

type BigdataDepend

type BigdataDepend struct {
	Iid                  int     `gorm:"column:iid;type:int(11);index:uix_iid_database_table,unique" json:"iid"`
	Database             string  `gorm:"column:database;type:varchar(64);index:uix_iid_database_table,unique;NOT NULL" json:"database"`
	Table                string  `gorm:"column:table;type:varchar(128);index:uix_iid_database_table,unique;NOT NULL" json:"table"`
	Engine               string  `gorm:"column:engine;type:varchar(128);NOT NULL" json:"engine"`
	DownDepDatabaseTable Strings `gorm:"column:down_dep_database_table;type:text;NOT NULL" json:"downDepDatabaseTable"`
	UpDepDatabaseTable   Strings `gorm:"column:up_dep_database_table;type:text;NOT NULL" json:"upDepDatabaseTable"`
	Rows                 uint64  `gorm:"column:rows;type:bigint(20);default:0;NOT NULL" json:"rows"`
	Bytes                uint64  `gorm:"column:bytes;type:bigint(20);default:0;NOT NULL" json:"bytes"`

	Utime int64 `gorm:"bigint;autoUpdateTime;comment:更新时间" json:"utime"`
}

func DependsList

func DependsList(conds egorm.Conds) (resp []*BigdataDepend, err error)

func EarliestDependRow

func EarliestDependRow(iid int) (resp BigdataDepend, err error)

func (*BigdataDepend) Key

func (m *BigdataDepend) Key() string

func (*BigdataDepend) Name

func (m *BigdataDepend) Name() string

func (*BigdataDepend) TableName

func (m *BigdataDepend) TableName() string

type BigdataFolder

type BigdataFolder struct {
	BaseModel

	Uid        int    `gorm:"column:uid;type:int(11)" json:"uid"` // uid of alarm operator
	Iid        int    `gorm:"column:iid;type:int(11)" json:"iid"`
	Name       string `gorm:"column:name;type:varchar(128);NOT NULL" json:"name"` // name of an alarm
	Desc       string `gorm:"column:desc;type:varchar(255);NOT NULL" json:"desc"` // description
	Primary    int    `gorm:"column:primary;type:int(11)" json:"primary"`
	Secondary  int    `gorm:"column:secondary;type:int(11)" json:"secondary"`
	WorkflowId int    `gorm:"column:workflow_id;type:int(11)" json:"workflowId"`
	ParentId   int    `gorm:"column:parent_id;type:int(11)" json:"parentId"`
}

func FolderInfo

func FolderInfo(db *gorm.DB, id int) (resp BigdataFolder, err error)

func FolderList

func FolderList(conds egorm.Conds) (resp []*BigdataFolder, err error)

func (*BigdataFolder) TableName

func (m *BigdataFolder) TableName() string

type BigdataNode

type BigdataNode struct {
	BaseModel

	Uid        int    `gorm:"column:uid;type:int(11)" json:"uid"`
	Iid        int    `gorm:"column:iid;type:int(11)" json:"iid"`
	FolderID   int    `gorm:"column:folder_id;type:int(11)" json:"folderId"`
	Primary    int    `gorm:"column:primary;type:int(11)" json:"primary"`
	Secondary  int    `gorm:"column:secondary;type:int(11)" json:"secondary"`
	Tertiary   int    `gorm:"column:tertiary;type:int(11)" json:"tertiary"`
	WorkflowId int    `gorm:"column:workflow_id;type:int(11)" json:"workflowId"`
	SourceId   int    `gorm:"column:sourceId;type:int(11)" json:"sourceId"`
	Name       string `gorm:"column:name;type:varchar(128);NOT NULL" json:"name"`
	Desc       string `gorm:"column:desc;type:varchar(255);NOT NULL" json:"desc"`
	LockUid    int    `gorm:"column:lock_uid;type:int(11) unsigned" json:"lockUid"`
	LockAt     int64  `gorm:"column:lock_at;type:int(11)" json:"lockAt"`
	Status     int    `gorm:"column:status;type:int(11)" json:"status"` // 0 无状态 1 待执行 2 执行中 3 执行异常 4 执行完成
	UUID       string `gorm:"column:uuid;type:varchar(128)" json:"uuid"`
}

func NodeInfo

func NodeInfo(db *gorm.DB, id int) (resp BigdataNode, err error)

func NodeList

func NodeList(conds egorm.Conds) (resp []*BigdataNode, err error)

func NodeListWithWorker

func NodeListWithWorker() (resp []*BigdataNode, err error)

NodeListWithWorker ... TertiaryClickHouse = 10 TertiaryMySQL = 11 TertiaryOfflineSync = 20

func (*BigdataNode) TableName

func (m *BigdataNode) TableName() string

type BigdataNodeContent

type BigdataNodeContent struct {
	NodeId          int    `gorm:"column:node_id;type:int(11);uix_node_id,unique" json:"nodeId"`
	Content         string `gorm:"column:content;type:longtext" json:"content"`
	Result          string `gorm:"column:result;type:longtext" json:"result"`
	PreviousContent string `gorm:"column:previous_content;type:longtext" json:"previousContent"`
	Utime           int64  `gorm:"bigint;autoUpdateTime;comment:update time" json:"utime"`
}

func NodeContentInfo

func NodeContentInfo(db *gorm.DB, id int) (resp BigdataNodeContent, err error)

func (*BigdataNodeContent) TableName

func (m *BigdataNodeContent) TableName() string

type BigdataNodeHistory

type BigdataNodeHistory struct {
	UUID    string `gorm:"column:uuid;type:varchar(128);uix_uuid,unique" json:"uuid"`
	NodeId  int    `gorm:"column:node_id;type:int(11)" json:"nodeId"`
	Content string `gorm:"column:content;type:longtext" json:"content"`
	Uid     int    `gorm:"column:uid;type:int(11)" json:"uid"`
	Utime   int64  `gorm:"bigint;autoUpdateTime;comment:update time" json:"utime"`
}

func NodeHistoryInfo

func NodeHistoryInfo(db *gorm.DB, uuid string) (resp BigdataNodeHistory, err error)

func NodeHistoryListPage

func NodeHistoryListPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*BigdataNodeHistory)

func (*BigdataNodeHistory) TableName

func (m *BigdataNodeHistory) TableName() string

type BigdataNodeResult

type BigdataNodeResult struct {
	BaseModel

	NodeId int   `gorm:"column:node_id;type:int(11)" json:"nodeId"`
	Uid    int   `gorm:"column:uid;type:int(11)" json:"uid"`
	Cost   int64 `gorm:"column:cost;type:bigint(20)" json:"cost"` // ms
	Status int   `gorm:"column:status;type:int(11)" json:"status"`

	Content      string `gorm:"column:content;type:longtext" json:"content"`
	Result       string `gorm:"column:result;type:longtext" json:"result"`
	ExcelProcess string `gorm:"column:excel_process;type:longtext" json:"excelProcess"`
}

func NodeResultInfo

func NodeResultInfo(db *gorm.DB, id int) (resp BigdataNodeResult, err error)

func NodeResultList

func NodeResultList(conds egorm.Conds) (resp []*BigdataNodeResult, err error)

func NodeResultListPage

func NodeResultListPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*BigdataNodeResult)

func (*BigdataNodeResult) TableName

func (m *BigdataNodeResult) TableName() string

type BigdataSource

type BigdataSource struct {
	BaseModel

	Iid      int    `gorm:"column:iid;type:int(11)" json:"iid"`
	Name     string `gorm:"column:name;type:varchar(128);NOT NULL" json:"name"` // name of an alarm
	Desc     string `gorm:"column:desc;type:varchar(255);NOT NULL" json:"desc"` // description
	URL      string `gorm:"column:url;type:varchar(255);NOT NULL" json:"url"`
	UserName string `gorm:"column:username;type:varchar(255);NOT NULL" json:"username"`
	Password string `gorm:"column:password;type:varchar(255);NOT NULL" json:"password"`
	Typ      int    `gorm:"column:typ;type:int(11)" json:"typ"`
	Uid      int    `gorm:"column:uid;type:int(11)" json:"uid"`
}

func SourceInfo

func SourceInfo(db *gorm.DB, id int) (resp BigdataSource, err error)

func SourceList

func SourceList(conds egorm.Conds) (resp []*BigdataSource, err error)

func (*BigdataSource) TableName

func (m *BigdataSource) TableName() string

type BigdataWorkflow

type BigdataWorkflow struct {
	BaseModel

	Iid  int    `gorm:"column:iid;type:int(11)" json:"iid"`
	Name string `gorm:"column:name;type:varchar(128);NOT NULL" json:"name"` // name of an alarm
	Desc string `gorm:"column:desc;type:varchar(255);NOT NULL" json:"desc"` // description
	Uid  int    `gorm:"column:uid;type:int(11)" json:"uid"`
}

func WorkflowInfo

func WorkflowInfo(db *gorm.DB, id int) (resp BigdataWorkflow, err error)

func WorkflowList

func WorkflowList(conds egorm.Conds) (resp []*BigdataWorkflow, err error)

func (*BigdataWorkflow) TableName

func (m *BigdataWorkflow) TableName() string

type CasbinRules

type CasbinRules []*PmsCasbinRule

type Cluster

type Cluster struct {
	BaseModel

	Name        string `gorm:"column:name;type:varchar(128);NOT NULL;index:uix_cluster_name,unique" json:"clusterName"` // unique name of cluster
	Description string `gorm:"column:description;type:varchar(128)" json:"description"`                                 // brief description of cluster
	Status      int    `gorm:"column:status;type:tinyint(1)" json:"status"`                                             // 0 means Well-Running, others mean not running
	ApiServer   string `gorm:"column:api_server;type:varchar(255);NOT NULL" json:"apiServer"`                           // address of cluster API server
	KubeConfig  string `gorm:"column:kube_config;type:mediumtext;NOT NULL" json:"kubeConfig"`                           // raw content of kube config
}

func ClusterInfo

func ClusterInfo(paramId int) (resp Cluster, err error)

func ClusterListHideSensitiveInfo

func ClusterListHideSensitiveInfo(conds egorm.Conds) (resp []*Cluster, err error)

func ClusterListPage

func ClusterListPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*Cluster)

ClusterListPage return item list by pagination

func ClusterNormalInfo

func ClusterNormalInfo(paramId int) (resp Cluster, err error)

func ClusterNormalList

func ClusterNormalList(conds egorm.Conds) (resp []*Cluster, err error)

func (*Cluster) Key

func (m *Cluster) Key() string

func (*Cluster) TableName

func (m *Cluster) TableName() string

type ClusterRuleGroup

type ClusterRuleGroup struct {
	ClusterId int
	Instance  BaseInstance
	GroupName string
	Rules     []ClusterRuleItem
}

type ClusterRuleItem

type ClusterRuleItem struct {
	RuleName string
	Content  string
}

type Collect

type Collect struct {
	BaseModel

	Uid         int    `gorm:"column:uid;type:int(11)" json:"uid"`
	TableId     int    `gorm:"column:table_id;type:int(11)" json:"tableId"`
	Alias       string `gorm:"column:alias;type:varchar(255);NOT NULL" json:"alias"`
	Statement   string `gorm:"column:statement;type:text" json:"statement"`
	CollectType int    `gorm:"column:collect_type;type:int" json:"collectType"`
}

func (*Collect) Create

func (model *Collect) Create(db *gorm.DB) (err error)

func (*Collect) Delete

func (model *Collect) Delete(db *gorm.DB) (err error)

func (*Collect) Info

func (model *Collect) Info(db *gorm.DB) (err error)

func (*Collect) InfoX

func (model *Collect) InfoX(db *gorm.DB, conds map[string]interface{}) (err error)

func (*Collect) List

func (model *Collect) List(db *gorm.DB, conds egorm.Conds) (resp []*Collect, err error)

func (*Collect) ListPage

func (model *Collect) ListPage(db *gorm.DB, conds egorm.Conds, reqList *ReqPage) (total int64, respList []*Collect)

func (*Collect) TableName

func (model *Collect) TableName() string

func (*Collect) Update

func (model *Collect) Update(db *gorm.DB, ups map[string]interface{}) (err error)

type Cond

type Cond struct {
	// Op MySQL中查询条件,如like,=,in
	Op string
	// Val 查询条件对应的值
	Val interface{}
}

Cond 为字段查询结构体

type Conds

type Conds map[string]interface{}

Conds 为Cond类型map,用于定义Where方法参数 map[field.name]interface{}

type ConfigPrometheusOperator

type ConfigPrometheusOperator struct {
	MetaData struct {
		Labels    map[string]string `json:"labels" form:"labels" yaml:"labels"`
		Name      string            `json:"name" form:"name" yaml:"name"`
		Namespace string            `json:"namespace" form:"namespace" yaml:"namespace"`
	} `json:"metadata" form:"metadata" yaml:"metadata"`
}

func (*ConfigPrometheusOperator) IsValid

func (c *ConfigPrometheusOperator) IsValid() bool

type Configuration

type Configuration struct {
	BaseModel

	K8SCmId     int    `gorm:"column:k8s_cm_id;type:int(11);" json:"k8sConfigmapId"` // config map id
	Name        string `gorm:"column:name;type:varchar(255);" json:"name"`
	Content     string `gorm:"column:content;type:longtext" json:"content"`
	Format      string `gorm:"column:format;type:varchar(32)" json:"format"`
	Version     string `gorm:"column:version;type:varchar(64)" json:"version"`
	Uid         int    `gorm:"column:uid;type:int(11) unsigned" json:"uid"`
	PublishTime int64  `gorm:"column:publish_time;type:int(11)" json:"publishTime"`
	LockUid     int    `gorm:"column:lock_uid;type:int(11) unsigned" json:"lockUid"`
	LockAt      int64  `gorm:"column:lock_at;type:bigint(11) unsigned" json:"lockAt"`

	K8SConfigMap K8SConfigMap `gorm:"foreignKey:K8SCmId;references:ID" json:"-"`
}

func ConfigurationInfo

func ConfigurationInfo(paramId int) (resp Configuration, err error)

func ConfigurationInfoX

func ConfigurationInfoX(conds map[string]interface{}) (resp Configuration, err error)

ConfigurationInfoX Info extension method to query a single record according to Cond

func ConfigurationList

func ConfigurationList(conds egorm.Conds) (resp []*Configuration, err error)

ConfigurationList return item list by condition

func (Configuration) FileName

func (c Configuration) FileName() string

FileName ..

func (*Configuration) TableName

func (c *Configuration) TableName() string

type ConfigurationHistory

type ConfigurationHistory struct {
	BaseModel
	Uid             int    `gorm:"column:uid;type:int(11) unsigned" json:"uid"`
	ConfigurationId int    `gorm:"column:configuration_id;type:int(11) unsigned" json:"configurationId"`
	ChangeLog       string `gorm:"column:change_log;type:longtext" json:"changeLog"`
	Content         string `gorm:"column:content;type:longtext" json:"content"`
	Version         string `gorm:"column:version;type:varchar(64)" json:"version"`

	Configuration Configuration `json:"configuration,omitempty" gorm:"foreignKey:ConfigurationId;references:ID"`
}

func ConfigurationHistoryInfoX

func ConfigurationHistoryInfoX(conds map[string]interface{}) (resp ConfigurationHistory, err error)

ConfigurationHistoryInfoX get single item by condition

func ConfigurationHistoryListPage

func ConfigurationHistoryListPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*ConfigurationHistory)

ConfigurationHistoryListPage return item list by pagination

func (*ConfigurationHistory) TableName

func (m *ConfigurationHistory) TableName() string

type ConfigurationPublish

type ConfigurationPublish struct {
	BaseModel

	Uid                    uint `gorm:"column:uid;type:int(11) unsigned" json:"uid"`
	ConfigurationId        uint `gorm:"column:configuration_id;type:int(11) unsigned" json:"configurationId"`
	ConfigurationHistoryId uint `gorm:"column:configuration_history_id;type:int(11) unsigned" json:"configurationHistoryId"`
}

func (*ConfigurationPublish) TableName

func (m *ConfigurationPublish) TableName() string

type DingTalkText

type DingTalkText struct {
	MsgType string `json:"msgType"`
	At      *At    `json:"at"`
	Text    *Text  `json:"text"`
}

type Event

type Event struct {
	ID            int    `gorm:"primary_key,not null;AUTO_INCREMENT" json:"id"`
	Source        string `gorm:"not null;default:'';size:64;index:idx_source;comment:事件来源" json:"source"`
	UserName      string `gorm:"not null;default:'';size:32;comment:操作用户的名字" json:"userName"`
	UID           int64  `gorm:"not null;default:0;comment:操作用户的uid" json:"uid"`
	Operation     string `gorm:"not null;default:'';size:64;index:idx_operation;comment:操作名" json:"operation"`
	ObjectType    string `gorm:"not null;default:'';size:64;comment:被操作对象的类型(一般为db.Table名)" json:"objectType"`
	ObjectId      int    `gorm:"not null;default:0;comment:被操作对象类型(db.BaseTable)下的具体对象的主键(id)" json:"objectId"`
	Metadata      string `gorm:"not null;type:text;comment:事件内容" json:"metadata"`
	Ctime         int64  `gorm:"bigint;autoCreateTime;comment:创建时间" json:"ctime"`
	OperationName string `gorm:"-" json:"operationName"`
	SourceName    string `gorm:"-" json:"sourceName"`
}

func (*Event) HandleOperationName

func (a *Event) HandleOperationName()

func (*Event) HandleSourceName

func (a *Event) HandleSourceName()

func (Event) TableName

func (Event) TableName() string

type IBaseTableAttach

type IBaseTableAttach interface {
	TableName() string
	Create(db *gorm.DB) (err error)
	Update(db *gorm.DB, ups map[string]interface{}) (err error)
	Info(db *gorm.DB) (err error)
	InfoX(db *gorm.DB, conds map[string]interface{}) (err error)
	List(conds egorm.Conds) (resp []*BaseTableAttach, err error)
	Delete(db *gorm.DB) (err error)
}

type ICollect

type ICollect interface {
	TableName() string
	Create(db *gorm.DB) (err error)
	Update(db *gorm.DB, ups map[string]interface{}) (err error)
	Info(db *gorm.DB) (err error)
	InfoX(db *gorm.DB, conds map[string]interface{}) (err error)
	List(db *gorm.DB, conds egorm.Conds) (resp []*Collect, err error)
	ListPage(db *gorm.DB, conds egorm.Conds, reqList *ReqPage) (total int64, respList []*Collect)
	Delete(db *gorm.DB) (err error)
}

type Ints

type Ints []int

func (*Ints) Scan

func (t *Ints) Scan(input interface{}) error

func (Ints) Value

func (t Ints) Value() (driver.Value, error)

type K8SConfigMap

type K8SConfigMap struct {
	BaseModel

	ClusterId int    `gorm:"column:cluster_id;type:int(11);index:uix_cluster_id_name_namespace,unique" json:"clusterId"` // 集群ID
	Name      string `gorm:"column:name;type:varchar(128);index:uix_cluster_id_name_namespace,unique" json:"name"`
	Namespace string `gorm:"column:namespace;type:varchar(64);index:uix_cluster_id_name_namespace,unique" json:"namespace"`
}

func K8SConfigMapInfo

func K8SConfigMapInfo(paramId int) (resp K8SConfigMap, err error)

func K8SConfigMapInfoX

func K8SConfigMapInfoX(conds map[string]interface{}) (resp K8SConfigMap, err error)

K8SConfigMapInfoX get single item by condition

func K8SConfigMapListX

func K8SConfigMapListX(conds map[string]interface{}) (resp []K8SConfigMap, err error)

K8SConfigMapListX get single item by condition

func K8SConfigMapLoadOrSave

func K8SConfigMapLoadOrSave(db *gorm.DB, data *K8SConfigMap) (resp *K8SConfigMap, err error)

func (*K8SConfigMap) TableName

func (m *K8SConfigMap) TableName() string

type Notification

type Notification struct {
	Version           string            `json:"version"`
	GroupKey          string            `json:"groupKey"`
	Status            string            `json:"status"`
	Receiver          string            `json:"receiver"`
	GroupLabels       map[string]string `json:"groupLabels"`
	CommonLabels      map[string]string `json:"commonLabels"`
	CommonAnnotations map[string]string `json:"commonAnnotations"`
	ExternalURL       string            `json:"externalURL"`
	Alerts            []Alert           `json:"alerts"`
}

func (*Notification) GetStatus

func (n *Notification) GetStatus() int

type OAuthToken

type OAuthToken struct {
	*oauth2.Token
}

func (*OAuthToken) Scan

func (t *OAuthToken) Scan(input interface{}) error

func (OAuthToken) Value

func (t OAuthToken) Value() (driver.Value, error)

type Pagination

type Pagination struct {
	// Current 总记录数
	Current int `json:"current" form:"current"`
	// PageSize 每页记录数
	PageSize int `json:"pageSize" form:"pageSize"`
	// Total 总页数
	Total int64 `json:"total" form:"total"`
	// Sort 顺序
	Sort string `json:"sort"  form:"sort"`
}

type PmsCasbinRule

type PmsCasbinRule struct {
	Id    uint   `gorm:"column:id;not null;primaryKey;autoIncrement;comment:'id'" json:"id" form:"id"`
	Ptype string `gorm:"column:ptype;not null;type:varchar(100);comment:'ptype: value in [p, g, g2, g3]'" json:"ptype" form:"ptype"`
	V0    string `gorm:"column:v0;not null;type:varchar(100);comment:'sub'" json:"v0" form:"v0"`
	V1    string `gorm:"column:v1;not null;type:varchar(100);comment:'obj'" json:"v1" form:"v1"`
	V2    string `gorm:"column:v2;not null;type:varchar(100);comment:'act'" json:"v2" form:"v2"`
	V3    string `gorm:"column:v3;not null;type:varchar(100);comment:'dom'" json:"v3" form:"v3"`
	V4    string `gorm:"column:v4;not null;type:varchar(100);comment:'reserved'" json:"v4" form:"v4"`
	V5    string `gorm:"column:v5;not null;type:varchar(100);comment:'reserved'" json:"v5" form:"v5"`
	V6    string `gorm:"column:v6;type:varchar(25);comment:'reserved'" json:"v6" form:"v6"`
	V7    string `gorm:"column:v7;type:varchar(25);comment:'reserved'" json:"v7" form:"v7"`
}

func (*PmsCasbinRule) TableName

func (t *PmsCasbinRule) TableName() string

type PmsCustomRole

type PmsCustomRole struct {
	BaseModel
	BelongType   string  `gorm:"not null;size:50;comment:所属资源类型,如'app'" json:"belong_type"`
	ReferId      int     `gorm:"not null;comment:所属资源类型的对应资源id" json:"refer_id"`
	RoleName     string  `gorm:"not null;size:50;comment:所属对应资源的角色名称" json:"role_name"`
	Description  string  `gorm:"not null;size:255;default:'';comment:对角色的中文描述" json:"description"`
	SubResources Strings `gorm:"not null;type:json;comment:角色所属refer_id资源的子资源列表" json:"sub_resources"`
	Acts         Strings `gorm:"not null;type:json;comment:对资源列表中各资源的actions" json:"acts"`
	UpdatedBy    int     `gorm:"not null;default:0;comment:最近一次对记录做更新的用户id" json:"updated_by"`
}
PmsCustomRole: 对资源的自定义角色表; 该表记录的增删会实时反映到 casbin_rule表中 (那么为什么不直接用casbin_rule表去维护?

因为, casbin_rule表中没有description描述, 该表的作用是供app负责人自定义一些在default_role_pms之外的一些角色.)

note: 1. 需要保证 belong_type, refer_id, role_name, resources, act 这5个字段建立联合唯一索引.
	     但由于resources字段是json类型, 不能用于uniqueIndex, 所以需要代码去保证这5个字段的uniqueIndex
	  2. 是否支持custom_role_pms的自定义, 需要看当前代码实现, 目前支持的belong_type 为 ["app"]

func GetCustomRolePmsList

func GetCustomRolePmsList(conds Conds) (resp []*PmsCustomRole, err error)

func (*PmsCustomRole) TableName

func (t *PmsCustomRole) TableName() string

type PmsDefaultRole

type PmsDefaultRole struct {
	BaseModel

	BelongType   string  `gorm:"column:belong_type;not null;size:50;comment:所属资源类型,如'app'" json:"belongType"`
	RoleName     string  `gorm:"column:role_name;not null;size:50;comment:所属资源的角色名称" json:"roleName"`
	Description  string  `gorm:"column:description;not null;size:255;default:'';comment:对角色的中文描述" json:"description"`
	SubResources Strings `gorm:"column:sub_resources;not null;type:json;comment:角色所属belongType资源下的子资源列表" json:"subResources"`
	Acts         Strings `gorm:"column:acts;not null;type:json;comment:对资源列表中各资源的actions" json:"acts"`
	UpdatedBy    int     `gorm:"column:updated_by;type:int(11);not null;default:0;comment:最近一次对记录做更新的用户id" json:"updatedBy"`
}
	TableDefaultRolePms: 记录belongType资源的默认角色; i.e. 当belongType资源创建时, 会根据该表中的记录去创建对应的casbinRules
	note: 需要保证 belong_type, role_name, resources, act 这4个字段建立联合唯一索引.
		  但由于resources字段是json类型, 不能用于uniqueIndex, TODO: 代码中保证4个字段的uniqueIndex
 		  不能只对belong_type和role_name两个字段设置uniqueIndex, 应为存在belong_type和role_name相同的情况(它们sub_resources不同)

func GetDefaultRolePmsList

func GetDefaultRolePmsList(conds Conds) (resp []*PmsDefaultRole, err error)

func (*PmsDefaultRole) TableName

func (t *PmsDefaultRole) TableName() string

type PmsRole

type PmsRole struct {
	BaseModel

	Name           string           `gorm:"not null;type:varchar(64);column:name;comment:角色英文名,可修改,不唯一" json:"name"`
	Desc           string           `gorm:"not null;type:varchar(128);default:'';column:desc;comment:角色描述" json:"desc"`
	BelongResource string           `` /* 133-byte string literal not displayed */
	RoleType       int              `` /* 152-byte string literal not displayed */
	ResourceId     int              `` /* 161-byte string literal not displayed */
	Details        []*PmsRoleDetail `gorm:"->" json:"details"`
	Refs           []*PmsRoleRef    `gorm:"->" json:"refs"`
}

func GetPmsRoleList

func GetPmsRoleList(conds egorm.Conds) (resp []*PmsRole, err error)

func PmsRoleInfo

func PmsRoleInfo(id int) (resp *PmsRole, err error)

func PmsRoleInfoWithTgtRef

func PmsRoleInfoWithTgtRef(roleId int, belongResource string, resourceId int) (resp *PmsRole, err error)

not contain grant info

func (*PmsRole) GenerateOnePRuleTplByDetail

func (pr *PmsRole) GenerateOnePRuleTplByDetail(roleDetail *PmsRoleDetail) (resp string, err error)

GenerateOnePRuleTplByDetail : Generate a pType casbin policy string based on inputParam(PmsRoleDetail) returned resp(if not empty) like,

role__{{PmsRole:Id}}__{{PmsRole:BelongResource}}__{{ID}},{{PmsRole:BelongResource}}__{{ID}}__subResource__(SubResourceRegex),ActsRegex,*

func (*PmsRole) IsDetailsValid

func (pr *PmsRole) IsDetailsValid() (err error)

func (*PmsRole) TableName

func (pr *PmsRole) TableName() string

type PmsRoleDetail

type PmsRoleDetail struct {
	BaseModel

	PmsRoleId    int     `gorm:"type:int(11);not null;column:pms_role_id;comment:所属pmsRole的id" json:"pmsRoleId"`
	SubResources Strings `gorm:"not null;type:json;column:sub_resources;comment:授权目标资源的子资源列表" json:"subResources"`
	Acts         Strings `gorm:"not null;type:json;column:acts;comment:准许动作列表" json:"acts"`
	RuleTpl      string  `gorm:"not null;type:text;column:rule_tpl;comment:规则模板,用于生成casbin中的p类型规则" json:"-"`
}

PmsRoleDetail uniqueIndex is not support for json column, please make sure (pms_role_id, sub_resources) is unique, and (pms_role_id, acts) is unique.

func (*PmsRoleDetail) TableName

func (prd *PmsRoleDetail) TableName() string

type PmsRoleRef

type PmsRoleRef struct {
	ID        int                `json:"id" gorm:"column:id;type:int;not null;primary_key;auto_increment"`
	PmsRoleId int                `gorm:"not null;column:pms_role_id;uniqueIndex:uix_role_ref;comment:已存在的角色(pms_role)的Id" json:"pmsRoleId"`
	RefId     int                `gorm:"not null;column:ref_id;uniqueIndex:uix_role_ref;comment:角色belongResource类型对象的id" json:"refId"`
	Grants    []*PmsRoleRefGrant `gorm:"->" json:"-"`
}

PmsRoleRef the table to store the assignment states of every PmsRole. Note, add or delete one record, must create or remove corresponding p rules(which generated from details)

func GetPmsRoleRefInfo

func GetPmsRoleRefInfo(conds egorm.Conds) (resp PmsRoleRef, err error)

func GetPmsRoleRefList

func GetPmsRoleRefList(conds egorm.Conds, withGrants ...bool) (resp []*PmsRoleRef, err error)

GetPmsRoleRefList for resp, default do not contain grants info

func (*PmsRoleRef) TableName

func (prf *PmsRoleRef) TableName() string

type PmsRoleRefGrant

type PmsRoleRefGrant struct {
	ID           int    `gorm:"column:id;type:int;not null;primary_key;auto_increment" json:"id" `
	PmsRoleRefId int    `gorm:"not null;column:pms_role_ref_id;uniqueIndex:uix_ref_obj_domain;comment:所关联pms_role_ref的Id" json:"pmsRoleRefId"`
	Ptype        string `` /* 135-byte string literal not displayed */
	ObjectType   string `` /* 155-byte string literal not displayed */
	ObjectId     int    `gorm:"not null;column:object_id;uniqueIndex:uix_ref_obj_domain;comment:被授权对象的id" json:"objectId,omitempty"`
	DomainType   string `` /* 164-byte string literal not displayed */
	DomainId     int    `` /* 151-byte string literal not displayed */
}

PmsRoleRefGrant Note, all columns can NOT be modified after crated. if want to modify, please, remove and add again. add or delete record, must create or remove corresponding gType rules

func (*PmsRoleRefGrant) TableName

func (prfg *PmsRoleRefGrant) TableName() string

type PushMsg

type PushMsg struct {
	Title   string   `json:"title"`
	Text    string   `json:"text"`
	Mobiles []string `json:"mobiles"`
}

type ReqAlarmWebhook

type ReqAlarmWebhook struct {
	Name string `json:"name" form:"name"`
	Key  string `json:"key" form:"key"`
	Typ  int    `json:"typ" form:"typ"`
	Uid  int    `json:"uid" form:"uid"`
}

type ReqAlertSettingUpdate

type ReqAlertSettingUpdate struct {
	RuleStoreType    int    `json:"ruleStoreType" form:"ruleStoreType"` // ruleStoreType 1 文件 2 configmap 3 prometheus operator
	PrometheusTarget string `json:"prometheusTarget" form:"prometheusTarget"`

	// file
	FilePath string `json:"filePath" form:"filePath"`

	// k8s
	Namespace string `json:"namespace" form:"namespace"`
	Configmap string `json:"configmap" form:"configmap"`
	ClusterId int    `json:"clusterId" form:"clusterId"`

	// ConfigPrometheusOperator Yaml 格式 e.g.
	// metadata:
	//  labels:
	//    prometheus: example
	//    role: alert-rules
	//  name: prometheus-example-rules-2
	//  namespace: default
	ConfigPrometheusOperator string `json:"configPrometheusOperator" form:"configPrometheusOperator"`
}

type ReqCreateBaseTableAttach

type ReqCreateBaseTableAttach struct {
	Alias     string `json:"alias" form:"alias"`
	Statement string `json:"statement" form:"statement"`
}

type ReqCreateBufferNullDataPipe

type ReqCreateBufferNullDataPipe struct {
	Cluster  string
	Database string
	Table    string
	TTL      int
}

type ReqCreateCollect

type ReqCreateCollect struct {
	TableId int `json:"tableId" form:"tableId"`
	ReqUpdateCollect
}

type ReqCreateMetricsSamples

type ReqCreateMetricsSamples struct {
	Iid     int    `json:"iid" form:"iid"`
	Cluster string `json:"cluster" form:"cluster"`
}

type ReqListBaseTableAttach

type ReqListBaseTableAttach struct {
	Alias string `json:"alias" form:"alias"`
}

type ReqListCollect

type ReqListCollect struct {
	CollectType int `json:"collectType" form:"collectType" required:"true"` // 1 query 2 table filter 4 global filter, if query table filter and global filter, use collectType 6
	TableId     int `json:"tableId" form:"tableId"`
}

type ReqPage

type ReqPage struct {
	Current  int `json:"current" form:"current"`
	PageSize int `json:"pageSize" form:"pageSize"`
}

func (*ReqPage) Valid

func (r *ReqPage) Valid() error

type ReqShortURLCreate

type ReqShortURLCreate struct {
	OriginUrl string `json:"originUrl" form:"originUrl"`
}

type ReqUpdateCollect

type ReqUpdateCollect struct {
	Alias       string `json:"alias" form:"alias"`
	Statement   string `json:"statement" form:"statement"`
	CollectType int    `json:"collectType" form:"collectType"` // 1 query 2 table filter 4 global filter
}

type ReqUserUpdate

type ReqUserUpdate struct {
	Email    string `json:"email" form:"email"`
	Nickname string `json:"nickname" form:"nickname"`
	Phone    string `json:"phone" form:"phone"`
}

type RespAlarmListRelatedInfo

type RespAlarmListRelatedInfo struct {
	Table    BaseTable    `json:"table"`
	Instance BaseInstance `json:"instance"`
}

type RespAlertSettingInfo

type RespAlertSettingInfo struct {
	InstanceId int `json:"instanceId"`
	ReqAlertSettingUpdate
}

type RespAlertSettingListItem

type RespAlertSettingListItem struct {
	InstanceId       int    `json:"instanceId"`
	InstanceName     string `json:"instanceName"`
	RuleStoreType    int    `json:"ruleStoreType"` // rule_store_type 1 文件 2 集群
	PrometheusTarget string `json:"prometheusTarget"`

	// check
	IsPrometheusOK            int    `json:"isPrometheusOK"` // 0 no 1 yes
	CheckPrometheusResult     string `json:"checkPrometheusResult"`
	IsAlertManagerOK          int    `json:"isAlertManagerOK"` // 0 no 1 yes
	CheckAlertManagerResult   string `json:"checkAlertManagerResult"`
	IsMetricsSamplesOk        int    `json:"isMetricsSamplesOk"` // 0 no 1 yes
	CheckMetricsSamplesResult string `json:"checkMetricsSamplesResult"`
}

type RespAllEnums

type RespAllEnums struct {
	SourceEnums    map[string]string `json:"sourceEnums"`
	OperationEnums map[string]string `json:"operationEnums"`
	UserEnums      map[int]string    `json:"userEnums"`
}

type RespEnumsOfSource

type RespEnumsOfSource struct {
	TargetSource   string            `json:"targetSource"`
	OperationEnums map[string]string `json:"operationEnums"`
}

type RespListBaseTableAttach

type RespListBaseTableAttach struct {
	Total int64                         `json:"total"`
	List  []RespListBaseTableAttachItem `json:"list"`
}

type RespListBaseTableAttachItem

type RespListBaseTableAttachItem struct {
	ID        string `json:"id"`
	Alias     string `json:"alias"`
	Statement string `json:"statement"`
}

type RespListCollect

type RespListCollect struct {
	Total int64                  `json:"total"`
	List  []*RespListCollectItem `json:"list"`
}

type RespListCollectItem

type RespListCollectItem struct {
	ID        int    `json:"id"`
	Alias     string `json:"alias"`
	Statement string `json:"statement"`
}

type String2String

type String2String map[string]string

func (*String2String) Scan

func (t *String2String) Scan(input interface{}) error

func (String2String) Value

func (t String2String) Value() (driver.Value, error)

type Strings

type Strings []string

func (*Strings) Scan

func (t *Strings) Scan(input interface{}) error

func (Strings) Value

func (t Strings) Value() (driver.Value, error)

type Text

type Text struct {
	Content string `json:"content"`
}

type UnitItem

type UnitItem struct {
	Alias    string        `json:"alias"`
	Duration time.Duration `json:"duration"`
}

type Ups

type Ups = map[string]interface{}

Ups 为更新某一条记录时存放的变更数据集合 map[field.name]field.value

type User

type User struct {
	BaseModel

	Uid              int        `gorm:"-" json:"uid"`
	OaId             int64      `gorm:"column:oa_id;type:bigint(20);NOT NULL" json:"oaId"`                                // oa_id
	Username         string     `gorm:"column:username;type:varchar(128);NOT NULL;index:uix_user,unique" json:"username"` // 用户名
	Nickname         string     `gorm:"column:nickname;type:varchar(128);NOT NULL;index:uix_user,unique" json:"nickname"` // 昵称
	Secret           string     `gorm:"column:secret;type:varchar(256);NOT NULL" json:"secret"`                           // 实例名称
	Phone            string     `gorm:"column:phone;type:varchar(64);NOT NULL" json:"phone"`                              // phone
	Email            string     `gorm:"column:email;type:varchar(64);NOT NULL" json:"email"`                              // email
	Avatar           string     `gorm:"column:avatar;type:varchar(256);NOT NULL" json:"avatar"`                           // avatar
	Hash             string     `gorm:"column:hash;type:varchar(256);NOT NULL" json:"hash"`                               // hash
	WebUrl           string     `gorm:"column:web_url;type:varchar(256);NOT NULL" json:"webUrl"`                          // webUrl
	Oauth            string     `gorm:"column:oauth;type:varchar(256);NOT NULL" json:"oauth"`                             // oauth
	State            string     `gorm:"column:state;type:varchar(256);NOT NULL" json:"state"`                             // state
	OauthId          string     `gorm:"column:oauth_id;type:varchar(256);NOT NULL" json:"oauthId"`                        // oauthId
	Password         string     `gorm:"column:password;type:varchar(256);NOT NULL" json:"password"`                       // password
	CurrentAuthority string     `gorm:"column:current_authority;type:varchar(256);NOT NULL" json:"currentAuthority"`      // currentAuthority
	Access           string     `gorm:"column:access;type:varchar(256);NOT NULL" json:"access"`                           // access
	OauthToken       OAuthToken `gorm:"column:oauth_token;type:text" json:"-"`                                            // oauth_token
}

func UserInfo

func UserInfo(paramId int) (resp User, err error)

func UserInfoX

func UserInfoX(conds map[string]interface{}) (resp User, err error)

UserInfoX get single item by condition

func UserList

func UserList(conds egorm.Conds) (resp []*User, err error)

UserList return item list by condition

func UserListPage

func UserListPage(conds egorm.Conds, reqList *ReqPage) (total int64, respList []*User)

UserListPage return item list by pagination

func (User) TableName

func (User) TableName() string

type UserIdName

type UserIdName struct {
	ID       int
	Username string
}

Jump to

Keyboard shortcuts

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