models

package
v5.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Dingtalk   = "dingtalk"
	Wecom      = "wecom"
	Feishu     = "feishu"
	FeishuCard = "feishucard"
	Mm         = "mm"
	Telegram   = "telegram"
	Email      = "email"

	DingtalkKey = "dingtalk_robot_token"
	WecomKey    = "wecom_robot_token"
	FeishuKey   = "feishu_robot_token"
	MmKey       = "mm_webhook_url"
	TelegramKey = "telegram_robot_token"
)
View Source
const AdminRole = "Admin"
View Source
const ClusterAll = "$all"

if rule's cluster field contains `ClusterAll`, means it take effect in all clusters

Variables

This section is empty.

Functions

func AlertAggrViewDel added in v5.5.0

func AlertAggrViewDel(ids []int64, createBy ...interface{}) error

AlertAggrViewDel: userid for safe delete

func AlertCurEventDel

func AlertCurEventDel(ids []int64) error

func AlertCurEventDelByHash

func AlertCurEventDelByHash(hash string) error

func AlertCurEventExists

func AlertCurEventExists(where string, args ...interface{}) (bool, error)

func AlertCurEventGetMap

func AlertCurEventGetMap(cluster string) (map[int64]map[string]struct{}, error)

func AlertCurEventTotal

func AlertCurEventTotal(prod string, bgid, stime, etime int64, severity int, clusters, cates []string, query string) (int64, error)

func AlertHisEventTotal

func AlertHisEventTotal(prod string, bgid, stime, etime int64, severity int, recovered int, clusters, cates []string, query string) (int64, error)

func AlertMuteDel

func AlertMuteDel(ids []int64) error

func AlertNumbers

func AlertNumbers(bgids []int64) (map[int64]int64, error)

for busi_group list page

func AlertRuleDels

func AlertRuleDels(ids []int64, bgid ...int64) error

func AlertRuleExists

func AlertRuleExists(id, groupId int64, cluster, name string) (bool, error)

func AlertRuleGetName

func AlertRuleGetName(id int64) (string, error)

func AlertSubscribeDel

func AlertSubscribeDel(ids []int64) error

func AlertingEngineAdd added in v5.14.3

func AlertingEngineAdd(instance, cluster string) error

func AlertingEngineDel added in v5.14.3

func AlertingEngineDel(ids []int64) error

func AlertingEngineGetClusters added in v5.14.3

func AlertingEngineGetClusters(instance string) ([]string, error)

AlertingEngineGetCluster 根据实例名获取对应的集群名字

func AlertingEngineGetsInstances added in v5.11.0

func AlertingEngineGetsInstances(where string, args ...interface{}) ([]string, error)

func AlertingEngineHeartbeat added in v5.11.0

func AlertingEngineHeartbeat(instance string) error

func AlertingEngineHeartbeatWithCluster added in v5.14.3

func AlertingEngineHeartbeatWithCluster(instance, cluster string) error

func BoardCount added in v5.8.0

func BoardCount(where string, args ...interface{}) (num int64, err error)

func BoardExists added in v5.8.0

func BoardExists(where string, args ...interface{}) (bool, error)

func BoardPayloadGet added in v5.8.0

func BoardPayloadGet(id int64) (string, error)

func BoardPayloadSave added in v5.8.0

func BoardPayloadSave(id int64, payload string) error

func BusiGroupAdd

func BusiGroupAdd(name string, labelEnable int, labelValue string, members []BusiGroupMember, creator string) error

func BusiGroupExists

func BusiGroupExists(where string, args ...interface{}) (bool, error)

func BusiGroupGetMap added in v5.5.0

func BusiGroupGetMap() (map[int64]*BusiGroup, error)

func BusiGroupIds

func BusiGroupIds(userGroupIds []int64, permFlag ...string) ([]int64, error)

func BusiGroupMemberAdd

func BusiGroupMemberAdd(member BusiGroupMember) error

func BusiGroupMemberCount

func BusiGroupMemberCount(where string, args ...interface{}) (int64, error)

func BusiGroupMemberDel

func BusiGroupMemberDel(where string, args ...interface{}) error

func ChartGroupIdsOf

func ChartGroupIdsOf(dashId int64) ([]int64, error)

func ConfigsDel added in v5.11.4

func ConfigsDel(ids []int64) error

func ConfigsGet

func ConfigsGet(ckey string) (string, error)

func ConfigsGetsByKey added in v5.11.4

func ConfigsGetsByKey(ckeys []string) (map[string]string, error)

func ConfigsSet

func ConfigsSet(ckey, cval string) error

func Count

func Count(tx *gorm.DB) (int64, error)

func CryptoPass

func CryptoPass(raw string) (string, error)

CryptoPass crypto password use salt

func DB

func DB() *gorm.DB

func DashboardCount

func DashboardCount(where string, args ...interface{}) (num int64, err error)

func DashboardExists

func DashboardExists(where string, args ...interface{}) (bool, error)

func Exists

func Exists(tx *gorm.DB) (bool, error)

func IdentsFilter

func IdentsFilter(idents []string, where string, args ...interface{}) ([]string, error)

func InitRoot

func InitRoot()

func InitSalt

func InitSalt()

InitSalt generate random salt

func Insert

func Insert(obj interface{}) error

func IsClusterAll added in v5.9.7

func IsClusterAll(ruleCluster string) bool

func MatchCluster added in v5.9.7

func MatchCluster(ruleCluster, targetCluster string) bool

func MemberIds

func MemberIds(groupId int64) ([]int64, error)

func MetricDescriptionDel

func MetricDescriptionDel(ids []int64) error

func MetricDescriptionMapper

func MetricDescriptionMapper(metrics []string) (map[string]string, error)

func MetricDescriptionTotal

func MetricDescriptionTotal(query string) (int64, error)

func MetricDescriptionUpdate

func MetricDescriptionUpdate(mds []MetricDescription) error

func MetricViewDel added in v5.5.0

func MetricViewDel(ids []int64, createBy ...interface{}) error

MetricViewDel: userid for safe delete

func MyGroupIds

func MyGroupIds(userId int64) ([]int64, error)

func NewDefaultChartGroup

func NewDefaultChartGroup(dashId int64) error

func OperationsOfRole

func OperationsOfRole(roles []string) ([]string, error)

func Process added in v5.11.0

func Process(labels []*prompb.Label, cfgs ...*RelabelConfig) []*prompb.Label

func RecordingRuleDels added in v5.9.5

func RecordingRuleDels(ids []int64, groupId int64) error

func RecordingRuleExists added in v5.9.5

func RecordingRuleExists(id, groupId int64, cluster, name string) (bool, error)

func RoleHasOperation

func RoleHasOperation(roles []string, operation string) (bool, error)

func TargetDel

func TargetDel(idents []string) error

func TargetGetTags

func TargetGetTags(idents []string) ([]string, error)

func TargetIdents

func TargetIdents(ids []int64) ([]string, error)

func TargetIds

func TargetIds(idents []string) ([]int64, error)

func TargetTotal

func TargetTotal(bgid int64, clusters []string, query string) (int64, error)

func TargetTotalCount added in v5.11.0

func TargetTotalCount() (int64, error)

func TargetUpdateBgid

func TargetUpdateBgid(idents []string, bgid int64, clearTags bool) error

func TargetUpdateNote

func TargetUpdateNote(idents []string, note string) error

func TaskRecordTotal

func TaskRecordTotal(bgid, beginTime int64, createBy, query string) (int64, error)

list task, filter by group_id, create_by

func TaskTplTotal

func TaskTplTotal(groupId int64, query string) (int64, error)

func UserGroupCount

func UserGroupCount(where string, args ...interface{}) (num int64, err error)

func UserGroupIdsOfBusiGroup

func UserGroupIdsOfBusiGroup(busiGroupId int64, permFlag ...string) ([]int64, error)

func UserGroupMemberAdd

func UserGroupMemberAdd(groupId, userId int64) error

func UserGroupMemberCount

func UserGroupMemberCount(where string, args ...interface{}) (int64, error)

func UserGroupMemberDel

func UserGroupMemberDel(groupId int64, userIds []int64) error

func UserTotal

func UserTotal(query string) (num int64, err error)

Types

type Action added in v5.11.0

type Action string
const (
	Replace   Action = "replace"
	Keep      Action = "keep"
	Drop      Action = "drop"
	HashMod   Action = "hashmod"
	LabelMap  Action = "labelmap"
	LabelDrop Action = "labeldrop"
	LabelKeep Action = "labelkeep"
	Lowercase Action = "lowercase"
	Uppercase Action = "uppercase"
)

type AggrRule added in v5.5.0

type AggrRule struct {
	Type  string
	Value string
}

type AlertAggrView added in v5.5.0

type AlertAggrView struct {
	Id       int64  `json:"id" gorm:"primaryKey"`
	Name     string `json:"name"`
	Rule     string `json:"rule"`
	Cate     int    `json:"cate"`
	CreateAt int64  `json:"create_at"`
	CreateBy int64  `json:"create_by"`
	UpdateAt int64  `json:"update_at"`
}

AlertAggrView 在告警聚合视图查看的时候,要存储一些聚合规则

func AlertAggrViewGet added in v5.5.0

func AlertAggrViewGet(where string, args ...interface{}) (*AlertAggrView, error)

func AlertAggrViewGets added in v5.5.0

func AlertAggrViewGets(createBy interface{}) ([]AlertAggrView, error)

func (*AlertAggrView) Add added in v5.5.0

func (v *AlertAggrView) Add() error

func (*AlertAggrView) TableName added in v5.5.0

func (v *AlertAggrView) TableName() string

func (*AlertAggrView) Update added in v5.5.0

func (v *AlertAggrView) Update(name, rule string, cate int, createBy int64) error

func (*AlertAggrView) Verify added in v5.5.0

func (v *AlertAggrView) Verify() error

type AlertCurEvent

type AlertCurEvent struct {
	Id                 int64             `json:"id" gorm:"primaryKey"`
	Cate               string            `json:"cate"`
	Cluster            string            `json:"cluster"`
	GroupId            int64             `json:"group_id"`   // busi group id
	GroupName          string            `json:"group_name"` // busi group name
	Hash               string            `json:"hash"`       // rule_id + vector_key
	RuleId             int64             `json:"rule_id"`
	RuleName           string            `json:"rule_name"`
	RuleNote           string            `json:"rule_note"`
	RuleProd           string            `json:"rule_prod"`
	RuleAlgo           string            `json:"rule_algo"`
	Severity           int               `json:"severity"`
	PromForDuration    int               `json:"prom_for_duration"`
	PromQl             string            `json:"prom_ql"`
	PromEvalInterval   int               `json:"prom_eval_interval"`
	Callbacks          string            `json:"-"`                  // for db
	CallbacksJSON      []string          `json:"callbacks" gorm:"-"` // for fe
	RunbookUrl         string            `json:"runbook_url"`
	NotifyRecovered    int               `json:"notify_recovered"`
	NotifyChannels     string            `json:"-"`                          // for db
	NotifyChannelsJSON []string          `json:"notify_channels" gorm:"-"`   // for fe
	NotifyGroups       string            `json:"-"`                          // for db
	NotifyGroupsJSON   []string          `json:"notify_groups" gorm:"-"`     // for fe
	NotifyGroupsObj    []*UserGroup      `json:"notify_groups_obj" gorm:"-"` // for fe
	TargetIdent        string            `json:"target_ident"`
	TargetNote         string            `json:"target_note"`
	TriggerTime        int64             `json:"trigger_time"`
	TriggerValue       string            `json:"trigger_value"`
	Tags               string            `json:"-"`                         // for db
	TagsJSON           []string          `json:"tags" gorm:"-"`             // for fe
	TagsMap            map[string]string `json:"-" gorm:"-"`                // for internal usage
	IsRecovered        bool              `json:"is_recovered" gorm:"-"`     // for notify.py
	NotifyUsersObj     []*User           `json:"notify_users_obj" gorm:"-"` // for notify.py
	LastEvalTime       int64             `json:"last_eval_time" gorm:"-"`   // for notify.py 上次计算的时间
	LastSentTime       int64             `json:"last_sent_time" gorm:"-"`   // 上次发送时间
	NotifyCurNumber    int               `json:"notify_cur_number"`         // notify: current number
	FirstTriggerTime   int64             `json:"first_trigger_time"`        // 连续告警的首次告警时间
}

func AlertCurEventGet

func AlertCurEventGet(where string, args ...interface{}) (*AlertCurEvent, error)

func AlertCurEventGetAll

func AlertCurEventGetAll(cluster string) ([]*AlertCurEvent, error)

func AlertCurEventGetById

func AlertCurEventGetById(id int64) (*AlertCurEvent, error)

func AlertCurEventGetByIds added in v5.5.0

func AlertCurEventGetByIds(ids []int64) ([]*AlertCurEvent, error)

func AlertCurEventGetByRuleIdAndCluster added in v5.14.3

func AlertCurEventGetByRuleIdAndCluster(ruleId int64, cluster string) ([]*AlertCurEvent, error)

func AlertCurEventGets

func AlertCurEventGets(prod string, bgid, stime, etime int64, severity int, clusters, cates []string, query string, limit, offset int) ([]AlertCurEvent, error)

func (*AlertCurEvent) Add

func (e *AlertCurEvent) Add() error

func (*AlertCurEvent) DB2FE

func (e *AlertCurEvent) DB2FE()

func (*AlertCurEvent) DB2Mem

func (e *AlertCurEvent) DB2Mem()

func (*AlertCurEvent) FillNotifyGroups

func (e *AlertCurEvent) FillNotifyGroups(cache map[int64]*UserGroup) error

for webui

func (*AlertCurEvent) GenCardTitle added in v5.5.0

func (e *AlertCurEvent) GenCardTitle(rules []*AggrRule) string

func (*AlertCurEvent) GetField added in v5.5.0

func (e *AlertCurEvent) GetField(field string) string

func (*AlertCurEvent) GetTagValue added in v5.5.0

func (e *AlertCurEvent) GetTagValue(tagkey string) string

func (*AlertCurEvent) ParseRule added in v5.14.0

func (e *AlertCurEvent) ParseRule(field string) error

func (*AlertCurEvent) TableName

func (e *AlertCurEvent) TableName() string

func (*AlertCurEvent) ToHis

func (e *AlertCurEvent) ToHis() *AlertHisEvent

type AlertHisEvent

type AlertHisEvent struct {
	Id                 int64       `json:"id" gorm:"primaryKey"`
	Cate               string      `json:"cate"`
	IsRecovered        int         `json:"is_recovered"`
	Cluster            string      `json:"cluster"`
	GroupId            int64       `json:"group_id"`
	GroupName          string      `json:"group_name"` // busi group name
	Hash               string      `json:"hash"`
	RuleId             int64       `json:"rule_id"`
	RuleName           string      `json:"rule_name"`
	RuleNote           string      `json:"rule_note"`
	RuleProd           string      `json:"rule_prod"`
	RuleAlgo           string      `json:"rule_algo"`
	Severity           int         `json:"severity"`
	PromForDuration    int         `json:"prom_for_duration"`
	PromQl             string      `json:"prom_ql"`
	PromEvalInterval   int         `json:"prom_eval_interval"`
	Callbacks          string      `json:"-"`
	CallbacksJSON      []string    `json:"callbacks" gorm:"-"`
	RunbookUrl         string      `json:"runbook_url"`
	NotifyRecovered    int         `json:"notify_recovered"`
	NotifyChannels     string      `json:"-"`
	NotifyChannelsJSON []string    `json:"notify_channels" gorm:"-"`
	NotifyGroups       string      `json:"-"`
	NotifyGroupsJSON   []string    `json:"notify_groups" gorm:"-"`
	NotifyGroupsObj    []UserGroup `json:"notify_groups_obj" gorm:"-"`
	TargetIdent        string      `json:"target_ident"`
	TargetNote         string      `json:"target_note"`
	TriggerTime        int64       `json:"trigger_time"`
	TriggerValue       string      `json:"trigger_value"`
	RecoverTime        int64       `json:"recover_time"`
	LastEvalTime       int64       `json:"last_eval_time"`
	Tags               string      `json:"-"`
	TagsJSON           []string    `json:"tags" gorm:"-"`
	NotifyCurNumber    int         `json:"notify_cur_number"`  // notify: current number
	FirstTriggerTime   int64       `json:"first_trigger_time"` // 连续告警的首次告警时间
}

func AlertHisEventGet

func AlertHisEventGet(where string, args ...interface{}) (*AlertHisEvent, error)

func AlertHisEventGetById

func AlertHisEventGetById(id int64) (*AlertHisEvent, error)

func AlertHisEventGets

func AlertHisEventGets(prod string, bgid, stime, etime int64, severity int, recovered int, clusters, cates []string, query string, limit, offset int) ([]AlertHisEvent, error)

func (*AlertHisEvent) Add

func (e *AlertHisEvent) Add() error

func (*AlertHisEvent) DB2FE

func (e *AlertHisEvent) DB2FE()

func (*AlertHisEvent) FillNotifyGroups

func (e *AlertHisEvent) FillNotifyGroups(cache map[int64]*UserGroup) error

func (*AlertHisEvent) TableName

func (e *AlertHisEvent) TableName() string

type AlertMute

type AlertMute struct {
	Id       int64        `json:"id" gorm:"primaryKey"`
	GroupId  int64        `json:"group_id"`
	Note     string       `json:"note"`
	Cate     string       `json:"cate"`
	Prod     string       `json:"prod"`    // product empty means n9e
	Cluster  string       `json:"cluster"` // take effect by clusters, seperated by space
	Tags     ormx.JSONArr `json:"tags"`
	Cause    string       `json:"cause"`
	Btime    int64        `json:"btime"`
	Etime    int64        `json:"etime"`
	Disabled int          `json:"disabled"` // 0: enabled, 1: disabled
	CreateBy string       `json:"create_by"`
	UpdateBy string       `json:"update_by"`
	CreateAt int64        `json:"create_at"`
	UpdateAt int64        `json:"update_at"`
	ITags    []TagFilter  `json:"-" gorm:"-"` // inner tags
}

func AlertMuteGet added in v5.11.3

func AlertMuteGet(where string, args ...interface{}) (*AlertMute, error)

func AlertMuteGetById added in v5.11.3

func AlertMuteGetById(id int64) (*AlertMute, error)

func AlertMuteGets

func AlertMuteGets(prods []string, bgid int64, query string) (lst []AlertMute, err error)

func AlertMuteGetsByBG added in v5.9.2

func AlertMuteGetsByBG(groupId int64) (lst []AlertMute, err error)

func AlertMuteGetsByCluster

func AlertMuteGetsByCluster(cluster string) ([]*AlertMute, error)

func (*AlertMute) Add

func (m *AlertMute) Add() error

func (*AlertMute) Parse

func (m *AlertMute) Parse() error

func (*AlertMute) TableName

func (m *AlertMute) TableName() string

func (*AlertMute) Update added in v5.11.3

func (m *AlertMute) Update(arm AlertMute) error

func (*AlertMute) UpdateFieldsMap added in v5.11.3

func (m *AlertMute) UpdateFieldsMap(fields map[string]interface{}) error

func (*AlertMute) Verify

func (m *AlertMute) Verify() error

type AlertNumber

type AlertNumber struct {
	GroupId    int64
	GroupCount int64
}

type AlertRule

type AlertRule struct {
	Id                    int64       `json:"id" gorm:"primaryKey"`
	GroupId               int64       `json:"group_id"`                      // busi group id
	Cate                  string      `json:"cate"`                          // alert rule cate (prometheus|elasticsearch)
	Cluster               string      `json:"cluster"`                       // take effect by clusters, seperated by space
	Name                  string      `json:"name"`                          // rule name
	Note                  string      `json:"note"`                          // will sent in notify
	Prod                  string      `json:"prod"`                          // product empty means n9e
	Algorithm             string      `json:"algorithm"`                     // algorithm (”|holtwinters), empty means threshold
	AlgoParams            string      `json:"-" gorm:"algo_params"`          // params algorithm need
	AlgoParamsJson        interface{} `json:"algo_params" gorm:"-"`          //
	Delay                 int         `json:"delay"`                         // Time (in seconds) to delay evaluation
	Severity              int         `json:"severity"`                      // 1: Emergency 2: Warning 3: Notice
	Disabled              int         `json:"disabled"`                      // 0: enabled, 1: disabled
	PromForDuration       int         `json:"prom_for_duration"`             // prometheus for, unit:s
	PromQl                string      `json:"prom_ql"`                       // just one ql
	PromEvalInterval      int         `json:"prom_eval_interval"`            // unit:s
	EnableStime           string      `json:"-"`                             // split by space: "00:00 10:00 12:00"
	EnableStimeJSON       string      `json:"enable_stime" gorm:"-"`         // for fe
	EnableStimesJSON      []string    `json:"enable_stimes" gorm:"-"`        // for fe
	EnableEtime           string      `json:"-"`                             // split by space: "00:00 10:00 12:00"
	EnableEtimeJSON       string      `json:"enable_etime" gorm:"-"`         // for fe
	EnableEtimesJSON      []string    `json:"enable_etimes" gorm:"-"`        // for fe
	EnableDaysOfWeek      string      `json:"-"`                             // eg: "0 1 2 3 4 5 6 ; 0 1 2"
	EnableDaysOfWeekJSON  []string    `json:"enable_days_of_week" gorm:"-"`  // for fe
	EnableDaysOfWeeksJSON [][]string  `json:"enable_days_of_weeks" gorm:"-"` // for fe
	EnableInBG            int         `json:"enable_in_bg"`                  // 0: global 1: enable one busi-group
	NotifyRecovered       int         `json:"notify_recovered"`              // whether notify when recovery
	NotifyChannels        string      `json:"-"`                             // split by space: sms voice email dingtalk wecom
	NotifyChannelsJSON    []string    `json:"notify_channels" gorm:"-"`      // for fe
	NotifyGroups          string      `json:"-"`                             // split by space: 233 43
	NotifyGroupsObj       []UserGroup `json:"notify_groups_obj" gorm:"-"`    // for fe
	NotifyGroupsJSON      []string    `json:"notify_groups" gorm:"-"`        // for fe
	NotifyRepeatStep      int         `json:"notify_repeat_step"`            // notify repeat interval, unit: min
	NotifyMaxNumber       int         `json:"notify_max_number"`             // notify: max number
	RecoverDuration       int64       `json:"recover_duration"`              // unit: s
	Callbacks             string      `json:"-"`                             // split by space: http://a.com/api/x http://a.com/api/y'
	CallbacksJSON         []string    `json:"callbacks" gorm:"-"`            // for fe
	RunbookUrl            string      `json:"runbook_url"`                   // sop url
	AppendTags            string      `json:"-"`                             // split by space: service=n9e mod=api
	AppendTagsJSON        []string    `json:"append_tags" gorm:"-"`          // for fe
	CreateAt              int64       `json:"create_at"`
	CreateBy              string      `json:"create_by"`
	UpdateAt              int64       `json:"update_at"`
	UpdateBy              string      `json:"update_by"`
}

func AlertRuleGet

func AlertRuleGet(where string, args ...interface{}) (*AlertRule, error)

func AlertRuleGetById

func AlertRuleGetById(id int64) (*AlertRule, error)

func AlertRuleGets

func AlertRuleGets(groupId int64) ([]AlertRule, error)

func AlertRuleGetsByCluster

func AlertRuleGetsByCluster(cluster string) ([]*AlertRule, error)

func AlertRulesGetsBy added in v5.9.2

func AlertRulesGetsBy(prods []string, query, algorithm, cluster string, cates []string, disabled int) ([]*AlertRule, error)

func (*AlertRule) Add

func (ar *AlertRule) Add() error

func (*AlertRule) DB2FE

func (ar *AlertRule) DB2FE()

func (*AlertRule) FE2DB

func (ar *AlertRule) FE2DB() error

func (*AlertRule) FillNotifyGroups

func (ar *AlertRule) FillNotifyGroups(cache map[int64]*UserGroup) error

func (*AlertRule) GenerateNewEvent added in v5.14.5

func (ar *AlertRule) GenerateNewEvent() *AlertCurEvent

func (*AlertRule) IsPrometheusRule added in v5.14.5

func (ar *AlertRule) IsPrometheusRule() bool

func (*AlertRule) TableName

func (ar *AlertRule) TableName() string

func (*AlertRule) Update

func (ar *AlertRule) Update(arf AlertRule) error

func (*AlertRule) UpdateEvent added in v5.14.5

func (ar *AlertRule) UpdateEvent(event *AlertCurEvent)

func (*AlertRule) UpdateFieldsMap

func (ar *AlertRule) UpdateFieldsMap(fields map[string]interface{}) error

func (*AlertRule) Verify

func (ar *AlertRule) Verify() error

type AlertSubscribe

type AlertSubscribe struct {
	Id               int64        `json:"id" gorm:"primaryKey"`
	Name             string       `json:"name"`     // AlertSubscribe name
	Disabled         int          `json:"disabled"` // 0: enabled, 1: disabled
	GroupId          int64        `json:"group_id"`
	Cate             string       `json:"cate"`
	Cluster          string       `json:"cluster"` // take effect by clusters, seperated by space
	RuleId           int64        `json:"rule_id"`
	RuleName         string       `json:"rule_name" gorm:"-"` // for fe
	Tags             ormx.JSONArr `json:"tags"`
	RedefineSeverity int          `json:"redefine_severity"`
	NewSeverity      int          `json:"new_severity"`
	RedefineChannels int          `json:"redefine_channels"`
	NewChannels      string       `json:"new_channels"`
	UserGroupIds     string       `json:"user_group_ids"`
	UserGroups       []UserGroup  `json:"user_groups" gorm:"-"` // for fe
	CreateBy         string       `json:"create_by"`
	CreateAt         int64        `json:"create_at"`
	UpdateBy         string       `json:"update_by"`
	UpdateAt         int64        `json:"update_at"`
	ITags            []TagFilter  `json:"-" gorm:"-"` // inner tags
}

func AlertSubscribeGet

func AlertSubscribeGet(where string, args ...interface{}) (*AlertSubscribe, error)

func AlertSubscribeGets

func AlertSubscribeGets(groupId int64) (lst []AlertSubscribe, err error)

func AlertSubscribeGetsByCluster

func AlertSubscribeGetsByCluster(cluster string) ([]*AlertSubscribe, error)

func (*AlertSubscribe) Add

func (s *AlertSubscribe) Add() error

func (*AlertSubscribe) FillRuleName

func (s *AlertSubscribe) FillRuleName(cache map[int64]string) error

func (*AlertSubscribe) FillUserGroups

func (s *AlertSubscribe) FillUserGroups(cache map[int64]*UserGroup) error

func (*AlertSubscribe) IsDisabled added in v5.11.3

func (s *AlertSubscribe) IsDisabled() bool

func (*AlertSubscribe) MatchCluster added in v5.15.0

func (s *AlertSubscribe) MatchCluster(cluster string) bool

func (*AlertSubscribe) ModifyEvent added in v5.15.0

func (s *AlertSubscribe) ModifyEvent(event *AlertCurEvent)

func (*AlertSubscribe) Parse

func (s *AlertSubscribe) Parse() error

func (*AlertSubscribe) TableName

func (s *AlertSubscribe) TableName() string

func (*AlertSubscribe) Update

func (s *AlertSubscribe) Update(selectField interface{}, selectFields ...interface{}) error

func (*AlertSubscribe) Verify

func (s *AlertSubscribe) Verify() error

type AlertingEngines added in v5.11.0

type AlertingEngines struct {
	Id       int64  `json:"id" gorm:"primaryKey"`
	Instance string `json:"instance"`
	Cluster  string `json:"cluster"` // reader cluster
	Clock    int64  `json:"clock"`
}

func AlertingEngineGet added in v5.11.0

func AlertingEngineGet(where string, args ...interface{}) (*AlertingEngines, error)

func AlertingEngineGets added in v5.11.0

func AlertingEngineGets(where string, args ...interface{}) ([]*AlertingEngines, error)

AlertingEngineGets 拉取列表数据,用户要在页面上看到所有 n9e-server 实例列表,然后为其分配 cluster

func (*AlertingEngines) TableName added in v5.11.0

func (e *AlertingEngines) TableName() string

func (*AlertingEngines) UpdateCluster added in v5.11.0

func (e *AlertingEngines) UpdateCluster(c string) error

UpdateCluster 页面上用户会给各个n9e-server分配要关联的目标集群是什么

type Board added in v5.8.0

type Board struct {
	Id       int64  `json:"id" gorm:"primaryKey"`
	GroupId  int64  `json:"group_id"`
	Name     string `json:"name"`
	Ident    string `json:"ident"`
	Tags     string `json:"tags"`
	CreateAt int64  `json:"create_at"`
	CreateBy string `json:"create_by"`
	UpdateAt int64  `json:"update_at"`
	UpdateBy string `json:"update_by"`
	Configs  string `json:"configs" gorm:"-"`
	Public   int    `json:"public"` // 0: false, 1: true
}

func BoardGet added in v5.8.0

func BoardGet(where string, args ...interface{}) (*Board, error)

BoardGet for detail page

func BoardGetByID added in v5.9.7

func BoardGetByID(id int64) (*Board, error)

func BoardGets added in v5.8.0

func BoardGets(groupId int64, query string) ([]Board, error)

BoardGets for list page

func (*Board) Add added in v5.8.0

func (b *Board) Add() error

func (*Board) CanRenameIdent added in v5.13.1

func (b *Board) CanRenameIdent(ident string) (bool, error)

func (*Board) Del added in v5.8.0

func (b *Board) Del() error

func (*Board) TableName added in v5.8.0

func (b *Board) TableName() string

func (*Board) Update added in v5.8.0

func (b *Board) Update(selectField interface{}, selectFields ...interface{}) error

func (*Board) Verify added in v5.8.0

func (b *Board) Verify() error

type BoardPayload added in v5.8.0

type BoardPayload struct {
	Id      int64  `json:"id" gorm:"primaryKey"`
	Payload string `json:"payload"`
}

func BoardPayloadGets added in v5.8.0

func BoardPayloadGets(ids []int64) ([]*BoardPayload, error)

func (*BoardPayload) TableName added in v5.8.0

func (p *BoardPayload) TableName() string

func (*BoardPayload) Update added in v5.8.0

func (p *BoardPayload) Update(selectField interface{}, selectFields ...interface{}) error

type BusiGroup

type BusiGroup struct {
	Id          int64                   `json:"id" gorm:"primaryKey"`
	Name        string                  `json:"name"`
	LabelEnable int                     `json:"label_enable"`
	LabelValue  string                  `json:"label_value"`
	CreateAt    int64                   `json:"create_at"`
	CreateBy    string                  `json:"create_by"`
	UpdateAt    int64                   `json:"update_at"`
	UpdateBy    string                  `json:"update_by"`
	UserGroups  []UserGroupWithPermFlag `json:"user_groups" gorm:"-"`
}

func BusiGroupGet

func BusiGroupGet(where string, args ...interface{}) (*BusiGroup, error)

func BusiGroupGetById

func BusiGroupGetById(id int64) (*BusiGroup, error)

func (*BusiGroup) AddMembers

func (bg *BusiGroup) AddMembers(members []BusiGroupMember, username string) error

func (*BusiGroup) Del

func (bg *BusiGroup) Del() error

func (*BusiGroup) DelMembers

func (bg *BusiGroup) DelMembers(members []BusiGroupMember, username string) error

func (*BusiGroup) FillUserGroups

func (bg *BusiGroup) FillUserGroups() error

func (*BusiGroup) TableName

func (bg *BusiGroup) TableName() string

func (*BusiGroup) Update

func (bg *BusiGroup) Update(name string, labelEnable int, labelValue string, updateBy string) error

type BusiGroupMember

type BusiGroupMember struct {
	BusiGroupId int64  `json:"busi_group_id"`
	UserGroupId int64  `json:"user_group_id"`
	PermFlag    string `json:"perm_flag"`
}

func BusiGroupMemberGet

func BusiGroupMemberGet(where string, args ...interface{}) (*BusiGroupMember, error)

func BusiGroupMemberGets

func BusiGroupMemberGets(where string, args ...interface{}) ([]BusiGroupMember, error)

func BusiGroupMemberGetsByBusiGroupId

func BusiGroupMemberGetsByBusiGroupId(busiGroupId int64) ([]BusiGroupMember, error)

func (BusiGroupMember) TableName

func (BusiGroupMember) TableName() string

type Chart

type Chart struct {
	Id      int64  `json:"id" gorm:"primaryKey"`
	GroupId int64  `json:"group_id"`
	Configs string `json:"configs"`
	Weight  int    `json:"weight"`
}

func ChartsOf

func ChartsOf(chartGroupId int64) ([]Chart, error)

func (*Chart) Add

func (c *Chart) Add() error

func (*Chart) Del

func (c *Chart) Del() error

func (*Chart) TableName

func (c *Chart) TableName() string

func (*Chart) Update

func (c *Chart) Update(selectField interface{}, selectFields ...interface{}) error

type ChartGroup

type ChartGroup struct {
	Id          int64  `json:"id" gorm:"primaryKey"`
	DashboardId int64  `json:"dashboard_id"`
	Name        string `json:"name"`
	Weight      int    `json:"weight"`
}

func ChartGroupsOf

func ChartGroupsOf(dashId int64) ([]ChartGroup, error)

func (*ChartGroup) Add

func (cg *ChartGroup) Add() error

func (*ChartGroup) Del

func (cg *ChartGroup) Del() error

func (*ChartGroup) TableName

func (cg *ChartGroup) TableName() string

func (*ChartGroup) Update

func (cg *ChartGroup) Update(selectField interface{}, selectFields ...interface{}) error

func (*ChartGroup) Verify

func (cg *ChartGroup) Verify() error

type ChartShare

type ChartShare struct {
	Id       int64  `json:"id" gorm:"primaryKey"`
	Cluster  string `json:"cluster"`
	Configs  string `json:"configs"`
	CreateBy string `json:"create_by"`
	CreateAt int64  `json:"create_at"`
}

func ChartShareGetsByIds

func ChartShareGetsByIds(ids []int64) ([]ChartShare, error)

func (*ChartShare) Add

func (cs *ChartShare) Add() error

func (*ChartShare) TableName

func (cs *ChartShare) TableName() string

type Configs

type Configs struct {
	Id   int64 `gorm:"primaryKey"`
	Ckey string
	Cval string
}

func ConfigGet added in v5.11.4

func ConfigGet(id int64) (*Configs, error)

func ConfigsGets

func ConfigsGets(prefix string, limit, offset int) ([]*Configs, error)

func (*Configs) Add added in v5.11.4

func (c *Configs) Add() error

func (Configs) TableName

func (Configs) TableName() string

func (*Configs) Update added in v5.11.4

func (c *Configs) Update() error

type Dashboard

type Dashboard struct {
	Id       int64    `json:"id" gorm:"primaryKey"`
	GroupId  int64    `json:"group_id"`
	Name     string   `json:"name"`
	Tags     string   `json:"-"`
	TagsLst  []string `json:"tags" gorm:"-"`
	Configs  string   `json:"configs"`
	CreateAt int64    `json:"create_at"`
	CreateBy string   `json:"create_by"`
	UpdateAt int64    `json:"update_at"`
	UpdateBy string   `json:"update_by"`
}

func DashboardGet

func DashboardGet(where string, args ...interface{}) (*Dashboard, error)

func DashboardGetAll added in v5.8.0

func DashboardGetAll() ([]Dashboard, error)

func DashboardGets

func DashboardGets(groupId int64, query string) ([]Dashboard, error)

func DashboardGetsByIds

func DashboardGetsByIds(ids []int64) ([]Dashboard, error)

func (*Dashboard) Add

func (d *Dashboard) Add() error

func (*Dashboard) Del

func (d *Dashboard) Del() error

func (*Dashboard) TableName

func (d *Dashboard) TableName() string

func (*Dashboard) Update

func (d *Dashboard) Update(selectField interface{}, selectFields ...interface{}) error

func (*Dashboard) Verify

func (d *Dashboard) Verify() error

type LabelBuilder added in v5.11.0

type LabelBuilder struct {
	LabelSet map[string]string
}

type MetricDescription

type MetricDescription struct {
	Id          int64  `json:"id"`
	Metric      string `json:"metric"`
	Description string `json:"description"`
	UpdateAt    int64  `json:"update_at"`
}

func MetricDescGetAll

func MetricDescGetAll() ([]MetricDescription, error)

func MetricDescriptionGet

func MetricDescriptionGet(where string, args ...interface{}) (*MetricDescription, error)

func MetricDescriptionGets

func MetricDescriptionGets(query string, limit, offset int) ([]MetricDescription, error)

func (*MetricDescription) TableName

func (md *MetricDescription) TableName() string

func (*MetricDescription) Update

func (md *MetricDescription) Update(desn string, now int64) error

type MetricView added in v5.5.0

type MetricView struct {
	Id       int64  `json:"id" gorm:"primaryKey"`
	Name     string `json:"name"`
	Cate     int    `json:"cate"`
	Configs  string `json:"configs"`
	CreateAt int64  `json:"create_at"`
	CreateBy int64  `json:"create_by"`
	UpdateAt int64  `json:"update_at"`
}

MetricView 在告警聚合视图查看的时候,要存储一些聚合规则

func MetricViewGet added in v5.5.0

func MetricViewGet(where string, args ...interface{}) (*MetricView, error)

func MetricViewGets added in v5.5.0

func MetricViewGets(createBy interface{}) ([]MetricView, error)

func (*MetricView) Add added in v5.5.0

func (v *MetricView) Add() error

func (*MetricView) TableName added in v5.5.0

func (v *MetricView) TableName() string

func (*MetricView) Update added in v5.5.0

func (v *MetricView) Update(name, configs string, cate int, createBy int64) error

func (*MetricView) Verify added in v5.5.0

func (v *MetricView) Verify() error

type RecordingRule added in v5.9.5

type RecordingRule struct {
	Id               int64    `json:"id" gorm:"primaryKey"`
	GroupId          int64    `json:"group_id"`             // busi group id
	Cluster          string   `json:"cluster"`              // take effect by cluster, seperated by space
	Name             string   `json:"name"`                 // new metric name
	Note             string   `json:"note"`                 // note
	Disabled         int      `json:"disabled"`             // 0: enabled, 1: disabled
	PromQl           string   `json:"prom_ql"`              // just one ql for promql
	PromEvalInterval int      `json:"prom_eval_interval"`   // unit:s
	AppendTags       string   `json:"-"`                    // split by space: service=n9e mod=api
	AppendTagsJSON   []string `json:"append_tags" gorm:"-"` // for fe
	CreateAt         int64    `json:"create_at"`
	CreateBy         string   `json:"create_by"`
	UpdateAt         int64    `json:"update_at"`
	UpdateBy         string   `json:"update_by"`
}

A RecordingRule records its vector expression into new timeseries.

func RecordingRuleGet added in v5.9.5

func RecordingRuleGet(where string, regs ...interface{}) (*RecordingRule, error)

func RecordingRuleGetById added in v5.9.5

func RecordingRuleGetById(id int64) (*RecordingRule, error)

func RecordingRuleGets added in v5.9.5

func RecordingRuleGets(groupId int64) ([]RecordingRule, error)

func RecordingRuleGetsByCluster added in v5.9.5

func RecordingRuleGetsByCluster(cluster string) ([]*RecordingRule, error)

func (*RecordingRule) Add added in v5.9.5

func (re *RecordingRule) Add() error

func (*RecordingRule) DB2FE added in v5.9.5

func (re *RecordingRule) DB2FE()

func (*RecordingRule) FE2DB added in v5.9.5

func (re *RecordingRule) FE2DB()

func (*RecordingRule) TableName added in v5.9.5

func (re *RecordingRule) TableName() string

func (*RecordingRule) Update added in v5.9.5

func (re *RecordingRule) Update(ref RecordingRule) error

func (*RecordingRule) UpdateFieldsMap added in v5.9.5

func (re *RecordingRule) UpdateFieldsMap(fields map[string]interface{}) error

func (*RecordingRule) Verify added in v5.9.5

func (re *RecordingRule) Verify() error

type Regexp added in v5.11.0

type Regexp struct {
	*regexp.Regexp
}

func MustNewRegexp added in v5.11.0

func MustNewRegexp(s string) Regexp

func NewRegexp added in v5.11.0

func NewRegexp(s string) (Regexp, error)

type RelabelConfig added in v5.11.0

type RelabelConfig struct {
	SourceLabels model.LabelNames
	Separator    string
	Regex        interface{}
	Modulus      uint64
	TargetLabel  string
	Replacement  string
	Action       Action
}

type Role

type Role struct {
	Id   int64  `json:"id" gorm:"primaryKey"`
	Name string `json:"name"`
	Note string `json:"note"`
}

func RoleGets

func RoleGets(where string, args ...interface{}) ([]Role, error)

func RoleGetsAll

func RoleGetsAll() ([]Role, error)

func (Role) TableName

func (Role) TableName() string

type RoleOperation

type RoleOperation struct {
	RoleName  string
	Operation string
}

func (RoleOperation) TableName

func (RoleOperation) TableName() string

type Statistics

type Statistics struct {
	Total       int64 `gorm:"total"`
	LastUpdated int64 `gorm:"last_updated"`
}

func AlertMuteStatistics

func AlertMuteStatistics(cluster string) (*Statistics, error)

func AlertRuleStatistics

func AlertRuleStatistics(cluster string) (*Statistics, error)

func AlertSubscribeStatistics

func AlertSubscribeStatistics(cluster string) (*Statistics, error)

func BusiGroupStatistics added in v5.5.0

func BusiGroupStatistics() (*Statistics, error)

func MetricDescStatistics

func MetricDescStatistics() (*Statistics, error)

func RecordingRuleStatistics added in v5.9.5

func RecordingRuleStatistics(cluster string) (*Statistics, error)

func TargetStatistics

func TargetStatistics(cluster string) (*Statistics, error)

func UserGroupStatistics

func UserGroupStatistics() (*Statistics, error)

func UserStatistics

func UserStatistics() (*Statistics, error)

type TagFilter

type TagFilter struct {
	Key    string              `json:"key"`   // tag key
	Func   string              `json:"func"`  // `==` | `=~` | `in` | `!=` | `!~` | `not in`
	Value  string              `json:"value"` // tag value
	Regexp *regexp.Regexp      // parse value to regexp if func = '=~' or '!~'
	Vset   map[string]struct{} // parse value to regexp if func = 'in' or 'not in'
}

type Target

type Target struct {
	Id       int64             `json:"id" gorm:"primaryKey"`
	GroupId  int64             `json:"group_id"`
	GroupObj *BusiGroup        `json:"group_obj" gorm:"-"`
	Cluster  string            `json:"cluster"`
	Ident    string            `json:"ident"`
	Note     string            `json:"note"`
	Tags     string            `json:"-"`
	TagsJSON []string          `json:"tags" gorm:"-"`
	TagsMap  map[string]string `json:"-" gorm:"-"` // internal use, append tags to series
	UpdateAt int64             `json:"update_at"`

	TargetUp    float64 `json:"target_up" gorm:"-"`
	LoadPerCore float64 `json:"load_per_core" gorm:"-"`
	MemUtil     float64 `json:"mem_util" gorm:"-"`
	DiskUtil    float64 `json:"disk_util" gorm:"-"`
}

func TargetGet

func TargetGet(where string, args ...interface{}) (*Target, error)

func TargetGetById

func TargetGetById(id int64) (*Target, error)

func TargetGetByIdent

func TargetGetByIdent(ident string) (*Target, error)

func TargetGets

func TargetGets(bgid int64, clusters []string, query string, limit, offset int) ([]*Target, error)

func TargetGetsByCluster

func TargetGetsByCluster(cluster string) ([]*Target, error)

func (*Target) Add

func (t *Target) Add() error

func (*Target) AddTags

func (t *Target) AddTags(tags []string) error

func (*Target) DelTags

func (t *Target) DelTags(tags []string) error

func (*Target) FillGroup

func (t *Target) FillGroup(cache map[int64]*BusiGroup) error

func (*Target) TableName

func (t *Target) TableName() string

type TaskRecord

type TaskRecord struct {
	Id           int64  `json:"id" gorm:"primaryKey"`
	GroupId      int64  `json:"group_id"`
	IbexAddress  string `json:"ibex_address"`
	IbexAuthUser string `json:"ibex_auth_user"`
	IbexAuthPass string `json:"ibex_auth_pass"`
	Title        string `json:"title"`
	Account      string `json:"account"`
	Batch        int    `json:"batch"`
	Tolerance    int    `json:"tolerance"`
	Timeout      int    `json:"timeout"`
	Pause        string `json:"pause"`
	Script       string `json:"script"`
	Args         string `json:"args"`
	CreateAt     int64  `json:"create_at"`
	CreateBy     string `json:"create_by"`
}

func TaskRecordGets

func TaskRecordGets(bgid, beginTime int64, createBy, query string, limit, offset int) ([]*TaskRecord, error)

func (*TaskRecord) Add

func (r *TaskRecord) Add() error

create task

func (*TaskRecord) TableName

func (r *TaskRecord) TableName() string

func (*TaskRecord) UpdateIsDone

func (r *TaskRecord) UpdateIsDone(isDone int) error

update is_done field

type TaskTpl

type TaskTpl struct {
	Id        int64    `json:"id" gorm:"primaryKey"`
	GroupId   int64    `json:"group_id"`
	Title     string   `json:"title"`
	Batch     int      `json:"batch"`
	Tolerance int      `json:"tolerance"`
	Timeout   int      `json:"timeout"`
	Pause     string   `json:"pause"`
	Script    string   `json:"script"`
	Args      string   `json:"args"`
	Tags      string   `json:"-"`
	TagsJSON  []string `json:"tags" gorm:"-"`
	Account   string   `json:"account"`
	CreateAt  int64    `json:"create_at"`
	CreateBy  string   `json:"create_by"`
	UpdateAt  int64    `json:"update_at"`
	UpdateBy  string   `json:"update_by"`
}

func TaskTplGet

func TaskTplGet(where string, args ...interface{}) (*TaskTpl, error)

func TaskTplGets

func TaskTplGets(groupId int64, query string, limit, offset int) ([]TaskTpl, error)

func (*TaskTpl) AddTags

func (t *TaskTpl) AddTags(tags []string, updateBy string) error

func (*TaskTpl) CleanFields

func (t *TaskTpl) CleanFields() error

func (*TaskTpl) Del

func (t *TaskTpl) Del() error

func (*TaskTpl) DelTags

func (t *TaskTpl) DelTags(tags []string, updateBy string) error

func (*TaskTpl) Hosts

func (t *TaskTpl) Hosts() ([]string, error)

func (*TaskTpl) Save

func (t *TaskTpl) Save(hosts []string) error

func (*TaskTpl) TableName

func (t *TaskTpl) TableName() string

func (*TaskTpl) Update

func (t *TaskTpl) Update(hosts []string) error

func (*TaskTpl) UpdateGroup

func (t *TaskTpl) UpdateGroup(groupId int64, updateBy string) error

type User

type User struct {
	Id         int64        `json:"id" gorm:"primaryKey"`
	Username   string       `json:"username"`
	Nickname   string       `json:"nickname"`
	Password   string       `json:"-"`
	Phone      string       `json:"phone"`
	Email      string       `json:"email"`
	Portrait   string       `json:"portrait"`
	Roles      string       `json:"-"`              // 这个字段写入数据库
	RolesLst   []string     `json:"roles" gorm:"-"` // 这个字段和前端交互
	Contacts   ormx.JSONObj `json:"contacts"`       // 内容为 map[string]string 结构
	Maintainer int          `json:"maintainer"`     // 是否给管理员发消息 0:not send 1:send
	CreateAt   int64        `json:"create_at"`
	CreateBy   string       `json:"create_by"`
	UpdateAt   int64        `json:"update_at"`
	UpdateBy   string       `json:"update_by"`
	Admin      bool         `json:"admin" gorm:"-"` // 方便前端使用
}

func LdapLogin

func LdapLogin(username, pass string) (*User, error)

func PassLogin

func PassLogin(username, pass string) (*User, error)

func UserGet

func UserGet(where string, args ...interface{}) (*User, error)

func UserGetAll

func UserGetAll() ([]*User, error)

func UserGetById

func UserGetById(id int64) (*User, error)

func UserGetByUsername

func UserGetByUsername(username string) (*User, error)

func UserGets

func UserGets(query string, limit, offset int) ([]User, error)

func UserGetsByIds

func UserGetsByIds(ids []int64) ([]User, error)

func (*User) Add

func (u *User) Add() error

func (*User) BusiGroups

func (u *User) BusiGroups(limit int, query string, all ...bool) ([]BusiGroup, error)

我是管理员,返回所有 或者我是成员

func (*User) CanDoBusiGroup

func (u *User) CanDoBusiGroup(bg *BusiGroup, permFlag ...string) (bool, error)

func (*User) CanModifyUserGroup

func (u *User) CanModifyUserGroup(ug *UserGroup) (bool, error)

func (*User) ChangePassword

func (u *User) ChangePassword(oldpass, newpass string) error

func (*User) CheckPerm

func (u *User) CheckPerm(operation string) (bool, error)

func (*User) Del

func (u *User) Del() error

func (*User) ExtractAllToken added in v5.15.0

func (u *User) ExtractAllToken() map[string]string

func (*User) ExtractToken added in v5.15.0

func (u *User) ExtractToken(key string) (string, bool)

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) NopriIdents

func (u *User) NopriIdents(idents []string) ([]string, error)

func (*User) TableName

func (u *User) TableName() string

func (*User) Update added in v5.5.0

func (u *User) Update(selectField interface{}, selectFields ...interface{}) error

func (*User) UpdateAllFields

func (u *User) UpdateAllFields() error

func (*User) UpdatePassword

func (u *User) UpdatePassword(password, updateBy string) error

func (*User) UserGroups added in v5.3.4

func (u *User) UserGroups(limit int, query string) ([]UserGroup, error)

func (*User) Verify

func (u *User) Verify() error

type UserGroup

type UserGroup struct {
	Id       int64   `json:"id" gorm:"primaryKey"`
	Name     string  `json:"name"`
	Note     string  `json:"note"`
	CreateAt int64   `json:"create_at"`
	CreateBy string  `json:"create_by"`
	UpdateAt int64   `json:"update_at"`
	UpdateBy string  `json:"update_by"`
	UserIds  []int64 `json:"-" gorm:"-"`
}

func UserGroupGet

func UserGroupGet(where string, args ...interface{}) (*UserGroup, error)

func UserGroupGetAll

func UserGroupGetAll() ([]*UserGroup, error)

func UserGroupGetById

func UserGroupGetById(id int64) (*UserGroup, error)

func UserGroupGetByIds

func UserGroupGetByIds(ids []int64) ([]UserGroup, error)

func (*UserGroup) Add

func (ug *UserGroup) Add() error

func (*UserGroup) AddMembers

func (ug *UserGroup) AddMembers(userIds []int64) error

func (*UserGroup) Del

func (ug *UserGroup) Del() error

func (*UserGroup) DelMembers

func (ug *UserGroup) DelMembers(userIds []int64) error

func (*UserGroup) TableName

func (ug *UserGroup) TableName() string

func (*UserGroup) Update

func (ug *UserGroup) Update(selectField interface{}, selectFields ...interface{}) error

func (*UserGroup) Verify

func (ug *UserGroup) Verify() error

type UserGroupMember

type UserGroupMember struct {
	GroupId int64
	UserId  int64
}

func UserGroupMemberGetAll

func UserGroupMemberGetAll() ([]UserGroupMember, error)

func (UserGroupMember) TableName

func (UserGroupMember) TableName() string

type UserGroupWithPermFlag

type UserGroupWithPermFlag struct {
	UserGroup *UserGroup `json:"user_group"`
	PermFlag  string     `json:"perm_flag"`
}

Jump to

Keyboard shortcuts

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