Documentation ¶
Overview ¶
base.go file contains : - public function of Models; - public const variables.
Index ¶
- Constants
- Variables
- func CheckIfOperationCodeValid(opCodes []uint) (err error)
- func ConvertRuleToDriverRule(r *Rule) *driver.Rule
- func GetConfigurableOperationCodeList() []uint
- func GetDb() *gorm.DB
- func GetOperationCodeDesc(opCode uint) string
- func GetRoleIDsFromRoles(roles []*Role) (roleIDs []uint)
- func GetRuleMapFromAllArray(allRules ...[]Rule) map[string]Rule
- func GetSqlxDb() *sqlx.DB
- func InitMockStorage(db *sql.DB)
- func InitStorage(s *Storage)
- func IsDefaultAdminUser(user string) bool
- func IsValidOperationCode(opCode uint) bool
- func UpdateStorage(newStorage *Storage)
- type AuditPlan
- type AuditPlanListDetail
- type AuditPlanReportListDetail
- type AuditPlanReportSQLListDetail
- type AuditPlanReportSQLV2
- type AuditPlanReportV2
- type AuditPlanSQLListDetail
- type AuditPlanSQLV2
- type BaseSQL
- type ExecuteSQL
- type Instance
- type InstanceDetail
- type JSON
- type LDAPConfiguration
- type License
- type Model
- type Oauth2Configuration
- type Period
- type Periods
- type Role
- type RoleDetail
- type RoleOperation
- type RollbackSQL
- type RowList
- type Rule
- type RuleTemplate
- type RuleTemplateDetail
- type RuleTemplateRule
- type SMTPConfiguration
- type SqlQueryConfig
- type SqlQueryExecutionSql
- type SqlQueryHistory
- type SqlWhitelist
- type Storage
- func (s *Storage) AutoMigrate() error
- func (s *Storage) CheckUserCanCreateAuditPlan(user *User, instName, dbType string) (bool, error)
- func (s *Storage) CheckUserHasOpToInstance(user *User, instance *Instance, ops []uint) (bool, error)
- func (s *Storage) CloneRuleTemplateRules(source, destination *RuleTemplate) error
- func (s *Storage) Create(model interface{}) error
- func (s *Storage) CreateAdminUser() error
- func (s *Storage) CreateDefaultTemplate(rules map[string][]*driver.Rule) error
- func (s *Storage) CreateDefaultWorkflowTemplate() error
- func (s *Storage) CreateRulesIfNotExist(rules map[string][]*driver.Rule) error
- func (s *Storage) CreateWorkflow(subject, desc string, user *User, task *Task, ...) error
- func (s *Storage) Delete(model interface{}) error
- func (s *Storage) DeleteRoleAndAssociations(role *Role) error
- func (s *Storage) DeleteRoleOperationByRoleID(roleID uint) (err error)
- func (s *Storage) DeleteTask(task *Task) error
- func (s *Storage) DeleteWorkflow(workflow *Workflow) error
- func (s *Storage) Exist(model interface{}) (bool, error)
- func (s *Storage) GetAllInstanceCount() (int64, error)
- func (s *Storage) GetAllInstanceTips(dbType string) (instances []*Instance, err error)
- func (s *Storage) GetAllRoleTip() ([]*Role, error)
- func (s *Storage) GetAllRule() ([]*Rule, error)
- func (s *Storage) GetAllRuleByDBType(dbType string) ([]*Rule, error)
- func (s *Storage) GetAllUserCount() (int64, error)
- func (s *Storage) GetAllUserGroupTip() ([]*UserGroup, error)
- func (s *Storage) GetAllUserTip() ([]*User, error)
- func (s *Storage) GetAndCheckInstanceExist(instanceNames []string) (instances []*Instance, err error)
- func (s *Storage) GetAndCheckRoleExist(roleNames []string) (roles []*Role, err error)
- func (s *Storage) GetAndCheckRuleExist(ruleNames []string, dbType string) (map[string]Rule, error)
- func (s *Storage) GetAndCheckRuleTemplateExist(templateNames []string) (ruleTemplates []*RuleTemplate, err error)
- func (s *Storage) GetAndCheckUserExist(userNames []string) (users []*User, err error)
- func (s *Storage) GetAndCheckUserGroupExist(userGroupNames []string) (ugs []*UserGroup, err error)
- func (s *Storage) GetAuditPlanByName(name string) (*AuditPlan, bool, error)
- func (s *Storage) GetAuditPlanReportByID(id uint) (*AuditPlanReportV2, bool, error)
- func (s *Storage) GetAuditPlanReportSQLV2ByReportIDAndNumber(reportId, number uint) (auditPlanReportSQLV2 *AuditPlanReportSQLV2, exist bool, err error)
- func (s *Storage) GetAuditPlanReportSQLsByReq(data map[string]interface{}) (list []*AuditPlanReportSQLListDetail, count uint64, err error)
- func (s *Storage) GetAuditPlanReportsByReq(data map[string]interface{}) (list []*AuditPlanReportListDetail, count uint64, err error)
- func (s *Storage) GetAuditPlanSQLs(name string) ([]*AuditPlanSQLV2, error)
- func (s *Storage) GetAuditPlanSQLsByReq(data map[string]interface{}) (list []*AuditPlanSQLListDetail, count uint64, err error)
- func (s *Storage) GetAuditPlans() ([]*AuditPlan, error)
- func (s *Storage) GetAuditPlansByReq(data map[string]interface{}) (list []*AuditPlanListDetail, count uint64, err error)
- func (s *Storage) GetDefaultRuleTemplateName(dbType string) string
- func (s *Storage) GetExpiredTasks(start time.Time) ([]*Task, error)
- func (s *Storage) GetExpiredWorkflows(start time.Time) ([]*Workflow, error)
- func (s *Storage) GetInstanceById(id string) (*Instance, bool, error)
- func (s *Storage) GetInstanceByName(name string) (*Instance, bool, error)
- func (s *Storage) GetInstanceByWorkflowID(workflowID uint) (*Instance, error)
- func (s *Storage) GetInstanceDetailByName(name string) (*Instance, bool, error)
- func (s *Storage) GetInstanceNamesByWorkflowTemplateId(id uint) ([]string, error)
- func (s *Storage) GetInstanceTipsByUser(user *User, dbType string) (instances []*Instance, err error)
- func (s *Storage) GetInstanceTipsByUserAndOperation(user *User, dbType string, opCode ...int) (instances []*Instance, err error)
- func (s *Storage) GetInstanceTipsByUserViaRoles(user *User, dbType string) (instances []*Instance, err error)
- func (s *Storage) GetInstancesByNames(names []string) ([]*Instance, error)
- func (s *Storage) GetInstancesByReq(data map[string]interface{}, user *User) (result []*InstanceDetail, count uint64, err error)
- func (s *Storage) GetLDAPConfiguration() (*LDAPConfiguration, bool, error)
- func (s *Storage) GetLastWorkflow() (*Workflow, bool, error)
- func (s *Storage) GetLicense() (*License, bool, error)
- func (s *Storage) GetNeedScheduledWorkflows() ([]*Workflow, error)
- func (s *Storage) GetOauth2Configuration() (*Oauth2Configuration, bool, error)
- func (s *Storage) GetRelatedDDLTask(task *Task) ([]Task, error)
- func (s *Storage) GetRoleByName(name string) (*Role, bool, error)
- func (s *Storage) GetRoleOperationsByRoleID(roleID uint) (roleOps []*RoleOperation, err error)
- func (s *Storage) GetRolesByNames(names []string) ([]*Role, error)
- func (s *Storage) GetRolesByReq(data map[string]interface{}) (result []*RoleDetail, count uint64, err error)
- func (s *Storage) GetRolesByUserID(userID int) (roles []*Role, err error)
- func (s *Storage) GetRule(name, dbType string) (*Rule, bool, error)
- func (s *Storage) GetRuleTemplateByName(name string) (*RuleTemplate, bool, error)
- func (s *Storage) GetRuleTemplateDetailByName(name string) (*RuleTemplate, bool, error)
- func (s *Storage) GetRuleTemplateTips(dbType string) ([]*RuleTemplate, error)
- func (s *Storage) GetRuleTemplatesByInstance(inst *Instance) ([]RuleTemplate, error)
- func (s *Storage) GetRuleTemplatesByNames(names []string) ([]*RuleTemplate, error)
- func (s *Storage) GetRuleTemplatesByReq(data map[string]interface{}) (result []*RuleTemplateDetail, count uint64, err error)
- func (s *Storage) GetRulesByInstanceId(instanceId string) ([]*Rule, error)
- func (s *Storage) GetRulesByNames(names []string, dbType string) ([]Rule, error)
- func (s *Storage) GetRulesFromRuleTemplateByName(name string) ([]*Rule, error)
- func (s *Storage) GetSMTPConfiguration() (*SMTPConfiguration, bool, error)
- func (s *Storage) GetSqlWhitelist(pageIndex, pageSize uint32) ([]SqlWhitelist, uint32, error)
- func (s *Storage) GetSqlWhitelistById(sqlWhiteId string) (*SqlWhitelist, bool, error)
- func (s *Storage) GetTaskById(taskId string) (*Task, bool, error)
- func (s *Storage) GetTaskByInstanceId(instanceId uint) ([]Task, error)
- func (s *Storage) GetTaskDetailById(taskId string) (*Task, bool, error)
- func (s *Storage) GetTaskExecuteSQLContent(taskId string) ([]byte, error)
- func (s *Storage) GetTaskSQLByNumber(taskId, number string) (*ExecuteSQL, bool, error)
- func (s *Storage) GetTaskSQLCountByTaskID(taskId uint) (int64, error)
- func (s *Storage) GetTaskSQLsByReq(data map[string]interface{}) (result []*TaskSQLDetail, count uint64, err error)
- func (s *Storage) GetUserByID(id uint) (*User, bool, error)
- func (s *Storage) GetUserByName(name string) (*User, bool, error)
- func (s *Storage) GetUserByThirdPartyUserID(thirdPartyUserID string) (*User, bool, error)
- func (s *Storage) GetUserCanOpInstances(user *User, ops []uint) (instances []*Instance, err error)
- func (s *Storage) GetUserDetailByName(name string) (*User, bool, error)
- func (s *Storage) GetUserGroupByName(name string) (userGroup *UserGroup, isExist bool, err error)
- func (s *Storage) GetUserGroupsByNames(names []string) (ugs []*UserGroup, err error)
- func (s *Storage) GetUserGroupsByReq(data map[string]interface{}) (results []*UserGroupDetail, count uint64, err error)
- func (s *Storage) GetUsersByNames(names []string) ([]*User, error)
- func (s *Storage) GetUsersByOperationCode(instance *Instance, opCode ...int) (users []*User, err error)
- func (s *Storage) GetUsersByReq(data map[string]interface{}) (result []*UserDetail, count uint64, err error)
- func (s *Storage) GetWeChatConfiguration() (*WeChatConfiguration, bool, error)
- func (s *Storage) GetWorkflowBySubject(subject string) (*Workflow, bool, error)
- func (s *Storage) GetWorkflowByTaskId(id uint) (*Workflow, bool, error)
- func (s *Storage) GetWorkflowCountByReq(data map[string]interface{}) (uint64, error)
- func (s *Storage) GetWorkflowDetailById(id string) (*Workflow, bool, error)
- func (s *Storage) GetWorkflowExpiredHoursOrDefault() (int64, error)
- func (s *Storage) GetWorkflowHistoryById(id string) ([]*WorkflowRecord, error)
- func (s *Storage) GetWorkflowRecordByTaskId(id string) (*WorkflowRecord, bool, error)
- func (s *Storage) GetWorkflowStepsByTemplateId(id uint) ([]*WorkflowStepTemplate, error)
- func (s *Storage) GetWorkflowStepsDetailByTemplateId(id uint) ([]*WorkflowStepTemplate, error)
- func (s *Storage) GetWorkflowTemplateById(id uint) (*WorkflowTemplate, bool, error)
- func (s *Storage) GetWorkflowTemplateByName(name string) (*WorkflowTemplate, bool, error)
- func (s *Storage) GetWorkflowTemplateTip() ([]*WorkflowTemplate, error)
- func (s *Storage) GetWorkflowTemplatesByReq(data map[string]interface{}) (result []*WorkflowTemplateDetail, count uint64, err error)
- func (s *Storage) GetWorkflowsByReq(data map[string]interface{}, user *User) (result []*WorkflowListDetail, count uint64, err error)
- func (s *Storage) HardDelete(model interface{}) error
- func (s *Storage) OverrideAuditPlanSQLs(apName string, sqls []*AuditPlanSQLV2) error
- func (s *Storage) ReplaceRoleOperationsByOpCodes(roleID uint, opCodes []uint) (err error)
- func (s *Storage) Save(model interface{}) error
- func (s *Storage) SaveRoleAndAssociations(role *Role, instances []*Instance, opCodes []uint, us []*User, ...) (err error)
- func (s *Storage) SaveUserAndAssociations(user *User, roles []*Role, userGroups []*UserGroup) (err error)
- func (s *Storage) SaveUserGroupAndAssociations(ug *UserGroup, us []*User, rs []*Role) (err error)
- func (s *Storage) SaveWorkflowTemplate(template *WorkflowTemplate) error
- func (s *Storage) TaskWorkflowIsRunning(taskIds []uint) (bool, error)
- func (s *Storage) Tx(fn func(txDB *gorm.DB) error) (err error)
- func (s *Storage) TxExec(fn func(tx *sql.Tx) error) error
- func (s *Storage) Update(model interface{}, attrs ...interface{}) error
- func (s *Storage) UpdateAuditPlanByName(name string, attrs map[string]interface{}) error
- func (s *Storage) UpdateDefaultAuditPlanSQLs(apName string, sqls []*AuditPlanSQLV2) error
- func (s *Storage) UpdateExecuteSQLById(executeSQLId string, attrs ...interface{}) error
- func (s *Storage) UpdateExecuteSQLStatusByTaskId(task *Task, status string) error
- func (s *Storage) UpdateExecuteSQLs(ExecuteSQLs []*ExecuteSQL) error
- func (s *Storage) UpdateExecuteSqlStatus(baseSQL *BaseSQL, status, result string) error
- func (s *Storage) UpdateInstanceById(InstanceId uint, attrs ...interface{}) error
- func (s *Storage) UpdateInstanceRoles(instance *Instance, rs ...*Role) error
- func (s *Storage) UpdateInstanceRuleTemplates(instance *Instance, ts ...*RuleTemplate) error
- func (s *Storage) UpdatePassword(user *User, newPassword string) error
- func (s *Storage) UpdateRoleInstances(role *Role, instances ...*Instance) error
- func (s *Storage) UpdateRoleUsers(role *Role, users ...*User) error
- func (s *Storage) UpdateRollbackSQLById(rollbackSQLId string, attrs ...interface{}) error
- func (s *Storage) UpdateRollbackSQLs(rollbackSQLs []*RollbackSQL) error
- func (s *Storage) UpdateRollbackSqlStatus(baseSQL *BaseSQL, status, result string) error
- func (s *Storage) UpdateRuleTemplateInstances(tpl *RuleTemplate, instances ...*Instance) error
- func (s *Storage) UpdateRuleTemplateRules(tpl *RuleTemplate, rules ...RuleTemplateRule) error
- func (s *Storage) UpdateTask(task *Task, attrs ...interface{}) error
- func (s *Storage) UpdateTaskStatusById(taskId uint, status string) error
- func (s *Storage) UpdateUserAuthenticationTypeByName(name string, tp UserAuthenticationType) error
- func (s *Storage) UpdateUserRoles(user *User, rs ...*Role) error
- func (s *Storage) UpdateWorkflowRecord(w *Workflow, task *Task) error
- func (s *Storage) UpdateWorkflowSchedule(w *Workflow, userId uint, scheduleTime *time.Time) error
- func (s *Storage) UpdateWorkflowStatus(w *Workflow, operateStep *WorkflowStep) error
- func (s *Storage) UpdateWorkflowTemplateInstances(workflowTemplate *WorkflowTemplate, instances ...*Instance) error
- func (s *Storage) UpdateWorkflowTemplateSteps(templateId uint, steps []*WorkflowStepTemplate) error
- func (s *Storage) UserCanAccessInstance(user *User, instance *Instance) (ok bool, err error)
- func (s *Storage) UserCanAccessWorkflow(user *User, workflow *Workflow) (bool, error)
- func (s *Storage) UserHasBindWorkflowTemplate(user *User) (bool, error)
- func (s *Storage) UserHasRunningWorkflow(userId uint) (bool, error)
- type SystemVariable
- type Task
- type TaskSQLDetail
- type User
- type UserAuthenticationType
- type UserDetail
- type UserGroup
- type UserGroupDetail
- type WeChatConfiguration
- type Workflow
- func (w *Workflow) CreateUserName() string
- func (w *Workflow) CurrentAssigneeUser() []*User
- func (w *Workflow) CurrentStep() *WorkflowStep
- func (w *Workflow) FinalStep() *WorkflowStep
- func (w *Workflow) IsFirstRecord(record *WorkflowRecord) bool
- func (w *Workflow) IsOperationUser(user *User) bool
- func (w *Workflow) NextStep() *WorkflowStep
- type WorkflowListDetail
- type WorkflowRecord
- type WorkflowStep
- type WorkflowStepTemplate
- type WorkflowTemplate
- type WorkflowTemplateDetail
Constants ¶
const ( // used by Model: // User, UserGroup Enabled = 0 Disabled = 1 )
const ( // Workflow:工单 20000-29999 // NOTE: 用户默认可以查看自己创建的工单,无需定义此项动作权限 OP_WORKFLOW_VIEW_OTHERS = 20100 OP_WORKFLOW_SAVE = 20200 // including "CREATE" and "UPDATE" OP_WORKFLOW_AUDIT = 20300 // including "PASSED" and "REJECT" // AuditPlan: 审核计划 reserved 30000-39999 // NOTE: 用户默认可以查看自己创建的审核任务,无需定义此项动作权限 OP_AUDIT_PLAN_VIEW_OTHERS = 30100 OP_AUDIT_PLAN_SAVE = 30200 // including "CREATE" and "UPDATE" )
const ( SQLWhitelistExactMatch = "exact_match" SQLWhitelistFPMatch = "fp_match" )
const ( TaskStatusInit = "initialized" TaskStatusAudited = "audited" TaskStatusExecuting = "executing" TaskStatusExecuteSucceeded = "exec_succeeded" TaskStatusExecuteFailed = "exec_failed" )
const ( TaskSQLSourceFromFormData = "form_data" TaskSQLSourceFromSQLFile = "sql_file" TaskSQLSourceFromMyBatisXMLFile = "mybatis_xml_file" TaskSQLSourceFromAuditPlan = "audit_plan" )
const ( SQLAuditStatusInitialized = "initialized" SQLAuditStatusDoing = "doing" SQLAuditStatusFinished = "finished" )
const ( SQLExecuteStatusInitialized = "initialized" SQLExecuteStatusDoing = "doing" SQLExecuteStatusFailed = "failed" SQLExecuteStatusSucceeded = "succeeded" )
const ( WorkflowStepTypeSQLReview = "sql_review" WorkflowStepTypeSQLExecute = "sql_execute" WorkflowStepTypeCreateWorkflow = "create_workflow" WorkflowStepTypeUpdateWorkflow = "update_workflow" )
const ( WorkflowStatusRunning = "on_process" WorkflowStatusReject = "rejected" WorkflowStatusCancel = "canceled" WorkflowStatusExecScheduled = "exec_scheduled" WorkflowStatusExecuting = "executing" WorkflowStatusExecFailed = "exec_failed" WorkflowStatusFinish = "finished" )
const ( WorkflowStepStateInit = "initialized" WorkflowStepStateApprove = "approved" WorkflowStepStateReject = "rejected" )
const (
DefaultAdminUser = "admin"
)
const FormatHourAndMinute = "15:04"
const (
SystemVariableWorkflowExpiredHours = "system_variable_workflow_expired_hours"
)
const TaskExecResultOK = "OK"
Variables ¶
var DefaultWorkflowTemplate = "default"
var MockTime, _ = time.Parse("0000-00-00 00:00:00.0000000", "0000-00-00 00:00:00.0000000")
Functions ¶
func CheckIfOperationCodeValid ¶ added in v1.2202.0
func ConvertRuleToDriverRule ¶ added in v1.2112.0
func GetConfigurableOperationCodeList ¶ added in v1.2202.0
func GetConfigurableOperationCodeList() []uint
func GetOperationCodeDesc ¶ added in v1.2202.0
func GetRoleIDsFromRoles ¶ added in v1.2202.0
func GetRuleMapFromAllArray ¶
func InitMockStorage ¶
func InitStorage ¶
func InitStorage(s *Storage)
func IsDefaultAdminUser ¶ added in v1.2202.0
func IsValidOperationCode ¶ added in v1.2202.0
func UpdateStorage ¶
func UpdateStorage(newStorage *Storage)
Types ¶
type AuditPlan ¶
type AuditPlan struct { Model Name string `json:"name" gorm:"not null;index"` CronExpression string `json:"cron_expression" gorm:"not null"` DBType string `json:"db_type" gorm:"not null"` Token string `json:"token" gorm:"not null"` InstanceName string `json:"instance_name"` CreateUserID uint InstanceDatabase string `json:"instance_database"` Type string `json:"type"` Params params.Params `json:"params" gorm:"type:varchar(1000)"` NotifyInterval int `json:"notify_interval" gorm:"default:10"` NotifyLevel string `json:"notify_level" gorm:"default:'warn'"` EnableEmailNotify bool `json:"enable_email_notify"` EnableWebHookNotify bool `json:"enable_web_hook_notify"` WebHookURL string `json:"web_hook_url"` WebHookTemplate string `json:"web_hook_template"` CreateUser *User `gorm:"foreignkey:CreateUserId"` Instance *Instance `gorm:"foreignkey:InstanceName;association_foreignkey:Name"` AuditPlanSQLs []*AuditPlanSQLV2 `gorm:"foreignkey:AuditPlanID"` }
type AuditPlanListDetail ¶
type AuditPlanListDetail struct { Name string `json:"name"` Cron string `json:"cron_expression"` DBType string `json:"db_type"` Token string `json:"token"` InstanceName string `json:"instance_name"` InstanceDatabase string `json:"instance_database"` Type sql.NullString `json:"type"` Params params.Params `json:"params"` }
type AuditPlanReportListDetail ¶
type AuditPlanReportListDetail struct { ID string `json:"id"` AuditLevel sql.NullString `json:"audit_level"` Score sql.NullInt32 `json:"score"` PassRate sql.NullFloat64 `json:"pass_rate"` CreateAt string `json:"created_at"` }
type AuditPlanReportSQLV2 ¶ added in v1.2202.0
type AuditPlanReportSQLV2 struct { Model AuditPlanReportID uint `json:"audit_plan_report_id" gorm:"index"` SQL string `json:"sql" gorm:"type:text;not null"` Number uint `json:"number"` AuditResult string `json:"audit_result" gorm:"type:text"` AuditPlanReport *AuditPlanReportV2 `gorm:"foreignkey:AuditPlanReportID"` }
func (AuditPlanReportSQLV2) TableName ¶ added in v1.2202.0
func (a AuditPlanReportSQLV2) TableName() string
type AuditPlanReportV2 ¶ added in v1.2202.0
type AuditPlanReportV2 struct { Model AuditPlanID uint `json:"audit_plan_id" gorm:"index"` AuditPlan *AuditPlan `gorm:"foreignkey:AuditPlanID"` AuditPlanReportSQLs []*AuditPlanReportSQLV2 `gorm:"foreignkey:AuditPlanReportID"` PassRate float64 `json:"pass_rate"` Score int32 `json:"score"` AuditLevel string `json:"audit_level"` }
func (AuditPlanReportV2) TableName ¶ added in v1.2202.0
func (a AuditPlanReportV2) TableName() string
type AuditPlanSQLListDetail ¶
type AuditPlanSQLV2 ¶ added in v1.2202.0
type AuditPlanSQLV2 struct { Model // add unique index on fingerprint and audit_plan_id // it's done by AutoMigrate() because gorm can't create index on TEXT column directly by tag. AuditPlanID uint `json:"audit_plan_id" gorm:"not null"` Fingerprint string `json:"fingerprint" gorm:"type:text;not null"` FingerprintMD5 string `json:"fingerprint_md5" gorm:"column:fingerprint_md5;not null"` SQLContent string `json:"sql" gorm:"type:text;not null"` Info JSON `gorm:"type:json"` }
func (*AuditPlanSQLV2) BeforeSave ¶ added in v1.2203.0
func (a *AuditPlanSQLV2) BeforeSave() error
BeforeSave is a hook implement gorm model before exec create.
func (*AuditPlanSQLV2) GetFingerprintMD5 ¶ added in v1.2203.0
func (a *AuditPlanSQLV2) GetFingerprintMD5() string
func (AuditPlanSQLV2) TableName ¶ added in v1.2202.0
func (a AuditPlanSQLV2) TableName() string
type BaseSQL ¶
type BaseSQL struct { Model TaskId uint `json:"-" gorm:"index"` Number uint `json:"number"` // Content store single SQL or batch SQLs // // Content may store batch SQLs When BaseSQL embed to RollbackSQL. // Split Content to single SQL before execute RollbackSQL. Content string `json:"sql" gorm:"type:longtext"` Description string `json:"description" gorm:"type:text"` StartBinlogFile string `json:"start_binlog_file"` StartBinlogPos int64 `json:"start_binlog_pos"` EndBinlogFile string `json:"end_binlog_file"` EndBinlogPos int64 `json:"end_binlog_pos"` RowAffects int64 `json:"row_affects"` ExecStatus string `json:"exec_status" gorm:"default:\"initialized\""` ExecResult string `json:"exec_result" gorm:"type:text"` }
func (*BaseSQL) GetExecStatusDesc ¶
type ExecuteSQL ¶
type ExecuteSQL struct { BaseSQL AuditStatus string `json:"audit_status" gorm:"default:\"initialized\""` AuditResult string `json:"audit_result" gorm:"type:text"` // AuditFingerprint generate from SQL and SQL audit result use MD5 hash algorithm, // it used for deduplication in one audit task. AuditFingerprint string `json:"audit_fingerprint" gorm:"index;type:char(32)"` // AuditLevel has four level: error, warn, notice, normal. AuditLevel string `json:"audit_level"` }
func (*ExecuteSQL) GetAuditResultDesc ¶
func (s *ExecuteSQL) GetAuditResultDesc() string
func (*ExecuteSQL) GetAuditStatusDesc ¶
func (s *ExecuteSQL) GetAuditStatusDesc() string
func (ExecuteSQL) TableName ¶
func (s ExecuteSQL) TableName() string
type Instance ¶
type Instance struct { Model // has created composite index: [id, name] by gorm#AddIndex Name string `json:"name" gorm:"not null;index" example:""` DbType string `json:"db_type" gorm:"column:db_type; not null" example:"mysql"` Host string `json:"host" gorm:"column:db_host; not null" example:"10.10.10.10"` Port string `json:"port" gorm:"column:db_port; not null" example:"3306"` User string `json:"user" gorm:"column:db_user; not null" example:"root"` Password string `json:"-" gorm:"-"` SecretPassword string `json:"secret_password" gorm:"column:db_password; not null"` Desc string `json:"desc" example:"this is a instance"` WorkflowTemplateId uint `json:"workflow_template_id"` AdditionalParams params.Params `json:"additional_params" gorm:"type:text"` MaintenancePeriod Periods `json:"maintenance_period" gorm:"type:text"` SqlQueryConfig SqlQueryConfig `json:"sql_query_config" gorm:"type:varchar(255); default:'{\"max_pre_query_rows\":100,\"query_timeout_second\":10}'"` // relation table Roles []*Role `json:"-" gorm:"many2many:instance_role;"` RuleTemplates []RuleTemplate `json:"-" gorm:"many2many:instance_rule_template"` WorkflowTemplate *WorkflowTemplate `gorm:"foreignkey:WorkflowTemplateId"` }
Instance is a table for database info
func (*Instance) AfterFind ¶
AfterFind is a hook implement gorm model after query, ignore err if query from db
func (*Instance) BeforeSave ¶
BeforeSave is a hook implement gorm model before exec create
type InstanceDetail ¶
type InstanceDetail struct { Name string `json:"name"` Desc string `json:"desc"` Host string `json:"db_host"` Port string `json:"db_port"` User string `json:"db_user"` MaintenancePeriod Periods `json:"maintenance_period" gorm:"text"` WorkflowTemplateName sql.NullString `json:"workflow_template_name"` RoleNames RowList `json:"role_names"` RuleTemplateNames RowList `json:"rule_template_names"` SqlQueryConfig SqlQueryConfig `json:"sql_query_config"` }
type JSON ¶ added in v1.2202.0
type JSON json.RawMessage
type LDAPConfiguration ¶ added in v1.2111.0
type LDAPConfiguration struct { Model // whether the ldap is enabled Enable bool `json:"enable" gorm:"not null"` // whether the ssl is enabled EnableSSL bool `json:"enable_ssl" gorm:"not null"` // ldap server's ip Host string `json:"host" gorm:"not null"` // ldap server's port Port string `json:"port" gorm:"not null"` // the DN of the ldap administrative user for verification ConnectDn string `json:"connect_dn" gorm:"not null"` // the password of the ldap administrative user for verification ConnectPassword string `json:"-" gorm:"-"` // the secret password of the ldap administrative user for verification ConnectSecretPassword string `json:"connect_secret_password" gorm:"not null"` // base dn used for ldap verification BaseDn string `json:"base_dn" gorm:"not null"` // the key corresponding to the user name in ldap UserNameRdnKey string `json:"ldap_user_name_rdn_key" gorm:"not null"` // the key corresponding to the user email in ldap UserEmailRdnKey string `json:"ldap_user_email_rdn_key" gorm:"not null"` }
LDAPConfiguration store ldap server configuration.
func (*LDAPConfiguration) AfterFind ¶ added in v1.2111.0
func (i *LDAPConfiguration) AfterFind() error
AfterFind is a hook implement gorm model after query, ignore err if query from db
func (*LDAPConfiguration) BeforeSave ¶ added in v1.2111.0
func (i *LDAPConfiguration) BeforeSave() error
BeforeSave is a hook implement gorm model before exec create
func (*LDAPConfiguration) TableName ¶ added in v1.2111.0
func (i *LDAPConfiguration) TableName() string
type Model ¶
type Model struct { ID uint `json:"id" gorm:"primary_key" example:"1"` CreatedAt time.Time `json:"created_at" gorm:"default:current_timestamp" example:"2018-10-21T16:40:23+08:00"` UpdatedAt time.Time `json:"updated_at" gorm:"default:current_timestamp on update current_timestamp" example:"2018-10-21T16:40:23+08:00"` DeletedAt *time.Time `json:"-" sql:"index"` }
type Oauth2Configuration ¶ added in v1.2205.0
type Oauth2Configuration struct { Model EnableOauth2 bool `json:"enable_oauth2" gorm:"column:enable_oauth2"` ClientID string `json:"client_id" gorm:"column:client_id"` ClientKey string `json:"-" gorm:"-"` ClientSecret string `json:"client_secret" gorm:"client_secret"` ClientHost string `json:"client_host" gorm:"column:client_host"` ServerAuthUrl string `json:"server_auth_url" gorm:"column:server_auth_url"` ServerTokenUrl string `json:"server_token_url" gorm:"column:server_token_url"` ServerUserIdUrl string `json:"server_user_id_url" gorm:"column:server_user_id_url"` Scopes string `json:"scopes" gorm:"column:scopes"` AccessTokenTag string `json:"access_token_tag" gorm:"column:access_token_tag"` UserIdTag string `json:"user_id_tag" gorm:"column:user_id_tag"` LoginTip string `json:"login_tip" gorm:"column:login_tip; default:'使用第三方账户登录'"` }
Oauth2Configuration store ldap server configuration.
func (*Oauth2Configuration) AfterFind ¶ added in v1.2205.0
func (i *Oauth2Configuration) AfterFind() error
AfterFind is a hook implement gorm model after query, ignore err if query from db
func (*Oauth2Configuration) BeforeSave ¶ added in v1.2205.0
func (i *Oauth2Configuration) BeforeSave() error
BeforeSave is a hook implement gorm model before exec create
func (*Oauth2Configuration) GetScopes ¶ added in v1.2205.0
func (i *Oauth2Configuration) GetScopes() []string
func (*Oauth2Configuration) SetScopes ¶ added in v1.2205.0
func (i *Oauth2Configuration) SetScopes(s []string)
func (*Oauth2Configuration) TableName ¶ added in v1.2205.0
func (i *Oauth2Configuration) TableName() string
type Periods ¶ added in v1.2203.0
type Periods []*Period
func (*Periods) IsWithinScope ¶ added in v1.2203.0
type Role ¶
type Role struct { Model Name string `gorm:"index"` Desc string Stat uint `json:"stat" gorm:"not null; default: 0; comment:'0:正常 1:被禁用'"` Users []*User `gorm:"many2many:user_role;"` Instances []*Instance `gorm:"many2many:instance_role; comment:'关联实例'"` UserGroups []*UserGroup `gorm:"many2many:user_group_roles; comment:'关联用户组'"` }
NOTE: related model: - RoleOperation
type RoleDetail ¶
type RoleDetail struct { Id int Name string `json:"name"` Desc string `json:"desc"` UserNames RowList `json:"user_names"` InstanceNames RowList `json:"instance_names"` // New fields: Stat, UserGroupNames, OperationsCodes // Issue: https://github.com/actiontech/sqle/issues/228 // Version: >= sqle-v1.2202.0 Stat int `json:"stat"` UserGroupNames RowList `json:"user_group_names"` OperationsCodes RowList `json:"operations_codes"` }
func (*RoleDetail) IsDisabled ¶ added in v1.2202.0
func (rd *RoleDetail) IsDisabled() bool
type RoleOperation ¶ added in v1.2202.0
type RoleOperation struct { Model RoleID uint `json:"role_id" gorm:"index"` Code uint `json:"op_code" gorm:"column:op_code; comment:'动作权限'"` }
NOTE: related model: - model.Role
type RollbackSQL ¶
func (RollbackSQL) TableName ¶
func (s RollbackSQL) TableName() string
type Rule ¶
type Rule struct { Name string `json:"name" gorm:"primary_key; not null"` DBType string `json:"db_type" gorm:"primary_key; not null; default:\"mysql\""` Desc string `json:"desc"` Level string `json:"level" example:"error"` // notice, warn, error Typ string `json:"type" gorm:"column:type; not null"` Params params.Params `json:"params" gorm:"type:varchar(1000)"` }
func GenerateRuleByDriverRule ¶ added in v1.2112.0
type RuleTemplate ¶
type RuleTemplate struct { Model Name string `json:"name"` Desc string `json:"desc"` DBType string `json:"db_type"` Instances []Instance `json:"instance_list" gorm:"many2many:instance_rule_template"` RuleList []RuleTemplateRule `json:"rule_list" gorm:"foreignkey:rule_template_id;association_foreignkey:id"` }
type RuleTemplateDetail ¶
type RuleTemplateRule ¶
type RuleTemplateRule struct { RuleTemplateId uint `json:"rule_template_id" gorm:"primary_key;auto_increment:false;"` RuleName string `json:"name" gorm:"primary_key;"` RuleLevel string `json:"level" gorm:"column:level;"` RuleParams params.Params `json:"value" gorm:"column:rule_params;type:varchar(1000)"` Rule *Rule `json:"-" gorm:"foreignkey:Name,DBType;association_foreignkey:RuleName,RuleDBType"` }
func NewRuleTemplateRule ¶
func NewRuleTemplateRule(t *RuleTemplate, r *Rule) RuleTemplateRule
func (*RuleTemplateRule) GetRule ¶ added in v1.2112.0
func (rtr *RuleTemplateRule) GetRule() *Rule
func (*RuleTemplateRule) TableName ¶
func (rtr *RuleTemplateRule) TableName() string
type SMTPConfiguration ¶
type SMTPConfiguration struct { Model EnableSMTPNotify sql.NullBool `json:"enable_smtp_notify" gorm:"default:true"` Host string `json:"smtp_host" gorm:"column:smtp_host; not null"` Port string `json:"smtp_port" gorm:"column:smtp_port; not null"` Username string `json:"smtp_username" gorm:"column:smtp_username; not null"` Password string `json:"-"` SecretPassword string `json:"secret_smtp_password" gorm:"column:secret_smtp_password; not null"` }
SMTPConfiguration store SMTP server configuration.
func (*SMTPConfiguration) AfterFind ¶
func (i *SMTPConfiguration) AfterFind() error
AfterFind is a hook implement gorm model after query, ignore err if query from db.
func (*SMTPConfiguration) BeforeSave ¶
func (i *SMTPConfiguration) BeforeSave() error
BeforeSave is a hook implement gorm model before exec create.
func (*SMTPConfiguration) TableName ¶
func (i *SMTPConfiguration) TableName() string
type SqlQueryConfig ¶ added in v1.2205.0
type SqlQueryConfig struct { MaxPreQueryRows int `json:"max_pre_query_rows"` QueryTimeoutSecond int `json:"query_timeout_second"` AuditEnabled bool `json:"audit_enabled"` AllowQueryWhenLessThanAuditLevel string `json:"allow_query_when_less_than_audit_level"` }
func (*SqlQueryConfig) Scan ¶ added in v1.2205.0
func (c *SqlQueryConfig) Scan(value interface{}) error
Scan impl sql.Scanner interface
type SqlQueryExecutionSql ¶ added in v1.2205.0
type SqlQueryExecutionSql struct { Model SqlQueryHistoryId uint `json:"sql_query_history_id" gorm:"not null"` Sql string `json:"sql" gorm:"type:text;not null"` ExecStartAt *time.Time `json:"exec_start_at"` ExecEndAt *time.Time `json:"exec_end_at"` ExecResult string `json:"exec_result" gorm:"type:text"` }
type SqlQueryHistory ¶ added in v1.2205.0
type SqlQueryHistory struct { Model CreateUserId uint `json:"create_user_id" gorm:"not null;index"` InstanceId uint `json:"instance_id" gorm:"not null;index"` Schema string `json:"schema"` RawSql string `json:"raw_sql" gorm:"type:text;not null"` ExecSQLs []*SqlQueryExecutionSql `json:"-" gorm:"foreignkey:SqlQueryHistoryId"` }
type SqlWhitelist ¶
type SqlWhitelist struct { Model // Value store SQL text. Value string `json:"value" gorm:"not null;type:text"` CapitalizedValue string `json:"-" gorm:"-"` Desc string `json:"desc"` // MessageDigest deprecated after 1.1.0, keep it for compatibility. MessageDigest string `json:"message_digest" gorm:"type:char(32) not null comment 'md5 data';" ` MatchType string `json:"match_type" gorm:"default:\"exact_match\""` }
func (*SqlWhitelist) AfterFind ¶
func (s *SqlWhitelist) AfterFind() error
AfterFind is a hook implement gorm model after query, ignore err if query from db
func (*SqlWhitelist) BeforeSave ¶
func (s *SqlWhitelist) BeforeSave() error
BeforeSave is a hook implement gorm model before exec create
func (SqlWhitelist) TableName ¶
func (s SqlWhitelist) TableName() string
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func GetStorage ¶
func GetStorage() *Storage
func NewStorage ¶
func (*Storage) AutoMigrate ¶
func (*Storage) CheckUserCanCreateAuditPlan ¶ added in v1.2204.0
func (*Storage) CheckUserHasOpToInstance ¶ added in v1.2202.0
func (*Storage) CloneRuleTemplateRules ¶
func (s *Storage) CloneRuleTemplateRules(source, destination *RuleTemplate) error
func (*Storage) CreateAdminUser ¶
func (*Storage) CreateDefaultTemplate ¶
func (*Storage) CreateDefaultWorkflowTemplate ¶
func (*Storage) CreateRulesIfNotExist ¶
func (*Storage) CreateWorkflow ¶
func (*Storage) DeleteRoleAndAssociations ¶ added in v1.2202.0
func (*Storage) DeleteRoleOperationByRoleID ¶ added in v1.2202.0
func (*Storage) DeleteTask ¶
func (*Storage) DeleteWorkflow ¶
func (*Storage) GetAllInstanceCount ¶ added in v1.2203.0
func (*Storage) GetAllInstanceTips ¶ added in v1.2202.0
func (*Storage) GetAllRoleTip ¶
func (*Storage) GetAllRule ¶
func (*Storage) GetAllRuleByDBType ¶
func (*Storage) GetAllUserCount ¶ added in v1.2203.0
func (*Storage) GetAllUserGroupTip ¶ added in v1.2202.0
func (*Storage) GetAllUserTip ¶
func (*Storage) GetAndCheckInstanceExist ¶
func (*Storage) GetAndCheckRoleExist ¶
func (*Storage) GetAndCheckRuleExist ¶
func (*Storage) GetAndCheckRuleTemplateExist ¶
func (s *Storage) GetAndCheckRuleTemplateExist(templateNames []string) (ruleTemplates []*RuleTemplate, err error)
func (*Storage) GetAndCheckUserExist ¶
func (*Storage) GetAndCheckUserGroupExist ¶ added in v1.2202.0
func (*Storage) GetAuditPlanByName ¶
func (*Storage) GetAuditPlanReportByID ¶ added in v1.2204.0
func (s *Storage) GetAuditPlanReportByID(id uint) (*AuditPlanReportV2, bool, error)
func (*Storage) GetAuditPlanReportSQLV2ByReportIDAndNumber ¶ added in v1.2206.0
func (s *Storage) GetAuditPlanReportSQLV2ByReportIDAndNumber(reportId, number uint) ( auditPlanReportSQLV2 *AuditPlanReportSQLV2, exist bool, err error)
func (*Storage) GetAuditPlanReportSQLsByReq ¶
func (s *Storage) GetAuditPlanReportSQLsByReq(data map[string]interface{}) ( list []*AuditPlanReportSQLListDetail, count uint64, err error)
func (*Storage) GetAuditPlanReportsByReq ¶
func (s *Storage) GetAuditPlanReportsByReq(data map[string]interface{}) ( list []*AuditPlanReportListDetail, count uint64, err error)
func (*Storage) GetAuditPlanSQLs ¶
func (s *Storage) GetAuditPlanSQLs(name string) ([]*AuditPlanSQLV2, error)
func (*Storage) GetAuditPlanSQLsByReq ¶
func (s *Storage) GetAuditPlanSQLsByReq(data map[string]interface{}) ( list []*AuditPlanSQLListDetail, count uint64, err error)
func (*Storage) GetAuditPlans ¶
func (*Storage) GetAuditPlansByReq ¶
func (s *Storage) GetAuditPlansByReq(data map[string]interface{}) ( list []*AuditPlanListDetail, count uint64, err error)
func (*Storage) GetDefaultRuleTemplateName ¶ added in v1.2111.0
func (*Storage) GetExpiredTasks ¶
func (*Storage) GetExpiredWorkflows ¶
func (*Storage) GetInstanceById ¶
func (*Storage) GetInstanceByName ¶
func (*Storage) GetInstanceByWorkflowID ¶ added in v1.2202.0
func (*Storage) GetInstanceDetailByName ¶
func (*Storage) GetInstanceNamesByWorkflowTemplateId ¶
func (*Storage) GetInstanceTipsByUser ¶ added in v1.2202.0
func (*Storage) GetInstanceTipsByUserAndOperation ¶ added in v1.2204.0
func (*Storage) GetInstanceTipsByUserViaRoles ¶ added in v1.2202.0
func (*Storage) GetInstancesByNames ¶
func (*Storage) GetInstancesByReq ¶
func (*Storage) GetLDAPConfiguration ¶ added in v1.2111.0
func (s *Storage) GetLDAPConfiguration() (*LDAPConfiguration, bool, error)
func (*Storage) GetLicense ¶ added in v1.2203.0
func (*Storage) GetNeedScheduledWorkflows ¶ added in v1.2112.0
func (*Storage) GetOauth2Configuration ¶ added in v1.2205.0
func (s *Storage) GetOauth2Configuration() (*Oauth2Configuration, bool, error)
func (*Storage) GetRoleOperationsByRoleID ¶ added in v1.2202.0
func (s *Storage) GetRoleOperationsByRoleID(roleID uint) (roleOps []*RoleOperation, err error)
func (*Storage) GetRolesByNames ¶
func (*Storage) GetRolesByReq ¶
func (s *Storage) GetRolesByReq(data map[string]interface{}) ( result []*RoleDetail, count uint64, err error)
func (*Storage) GetRolesByUserID ¶ added in v1.2202.0
func (*Storage) GetRuleTemplateByName ¶
func (s *Storage) GetRuleTemplateByName(name string) (*RuleTemplate, bool, error)
func (*Storage) GetRuleTemplateDetailByName ¶
func (s *Storage) GetRuleTemplateDetailByName(name string) (*RuleTemplate, bool, error)
func (*Storage) GetRuleTemplateTips ¶
func (s *Storage) GetRuleTemplateTips(dbType string) ([]*RuleTemplate, error)
func (*Storage) GetRuleTemplatesByInstance ¶
func (s *Storage) GetRuleTemplatesByInstance(inst *Instance) ([]RuleTemplate, error)
func (*Storage) GetRuleTemplatesByNames ¶
func (s *Storage) GetRuleTemplatesByNames(names []string) ([]*RuleTemplate, error)
func (*Storage) GetRuleTemplatesByReq ¶
func (s *Storage) GetRuleTemplatesByReq(data map[string]interface{}) ( result []*RuleTemplateDetail, count uint64, err error)
func (*Storage) GetRulesByInstanceId ¶
func (*Storage) GetRulesByNames ¶
func (*Storage) GetRulesFromRuleTemplateByName ¶
func (*Storage) GetSMTPConfiguration ¶
func (s *Storage) GetSMTPConfiguration() (*SMTPConfiguration, bool, error)
func (*Storage) GetSqlWhitelist ¶
func (s *Storage) GetSqlWhitelist(pageIndex, pageSize uint32) ([]SqlWhitelist, uint32, error)
func (*Storage) GetSqlWhitelistById ¶
func (s *Storage) GetSqlWhitelistById(sqlWhiteId string) (*SqlWhitelist, bool, error)
func (*Storage) GetTaskByInstanceId ¶
func (*Storage) GetTaskDetailById ¶
func (*Storage) GetTaskExecuteSQLContent ¶
func (*Storage) GetTaskSQLByNumber ¶ added in v1.2201.0
func (s *Storage) GetTaskSQLByNumber(taskId, number string) (*ExecuteSQL, bool, error)
func (*Storage) GetTaskSQLCountByTaskID ¶ added in v1.2203.0
func (*Storage) GetTaskSQLsByReq ¶
func (s *Storage) GetTaskSQLsByReq(data map[string]interface{}) ( result []*TaskSQLDetail, count uint64, err error)
func (*Storage) GetUserByID ¶ added in v1.2204.0
func (*Storage) GetUserByThirdPartyUserID ¶ added in v1.2205.0
func (*Storage) GetUserCanOpInstances ¶ added in v1.2202.0
func (*Storage) GetUserDetailByName ¶
func (*Storage) GetUserGroupByName ¶ added in v1.2202.0
func (*Storage) GetUserGroupsByNames ¶ added in v1.2202.0
func (*Storage) GetUserGroupsByReq ¶ added in v1.2202.0
func (s *Storage) GetUserGroupsByReq(data map[string]interface{}) ( results []*UserGroupDetail, count uint64, err error)
func (*Storage) GetUsersByNames ¶
func (*Storage) GetUsersByOperationCode ¶ added in v1.2204.0
func (s *Storage) GetUsersByOperationCode(instance *Instance, opCode ...int) (users []*User, err error)
GetUsersByOperationCode will return admin user if no qualified user is found, preventing the process from being stuck because no user can operate
func (*Storage) GetUsersByReq ¶
func (s *Storage) GetUsersByReq(data map[string]interface{}) ( result []*UserDetail, count uint64, err error)
func (*Storage) GetWeChatConfiguration ¶ added in v1.2203.0
func (s *Storage) GetWeChatConfiguration() (*WeChatConfiguration, bool, error)
func (*Storage) GetWorkflowBySubject ¶
func (*Storage) GetWorkflowByTaskId ¶
func (*Storage) GetWorkflowCountByReq ¶
func (*Storage) GetWorkflowDetailById ¶
func (*Storage) GetWorkflowExpiredHoursOrDefault ¶
func (*Storage) GetWorkflowHistoryById ¶
func (s *Storage) GetWorkflowHistoryById(id string) ([]*WorkflowRecord, error)
func (*Storage) GetWorkflowRecordByTaskId ¶
func (s *Storage) GetWorkflowRecordByTaskId(id string) (*WorkflowRecord, bool, error)
TODO: args `id` using uint
func (*Storage) GetWorkflowStepsByTemplateId ¶
func (s *Storage) GetWorkflowStepsByTemplateId(id uint) ([]*WorkflowStepTemplate, error)
func (*Storage) GetWorkflowStepsDetailByTemplateId ¶
func (s *Storage) GetWorkflowStepsDetailByTemplateId(id uint) ([]*WorkflowStepTemplate, error)
func (*Storage) GetWorkflowTemplateById ¶
func (s *Storage) GetWorkflowTemplateById(id uint) (*WorkflowTemplate, bool, error)
func (*Storage) GetWorkflowTemplateByName ¶
func (s *Storage) GetWorkflowTemplateByName(name string) (*WorkflowTemplate, bool, error)
func (*Storage) GetWorkflowTemplateTip ¶
func (s *Storage) GetWorkflowTemplateTip() ([]*WorkflowTemplate, error)
func (*Storage) GetWorkflowTemplatesByReq ¶
func (s *Storage) GetWorkflowTemplatesByReq(data map[string]interface{}) ( result []*WorkflowTemplateDetail, count uint64, err error)
func (*Storage) GetWorkflowsByReq ¶
func (*Storage) HardDelete ¶
func (*Storage) OverrideAuditPlanSQLs ¶
func (s *Storage) OverrideAuditPlanSQLs(apName string, sqls []*AuditPlanSQLV2) error
func (*Storage) ReplaceRoleOperationsByOpCodes ¶ added in v1.2202.0
func (*Storage) SaveRoleAndAssociations ¶ added in v1.2202.0
func (*Storage) SaveUserAndAssociations ¶ added in v1.2202.0
func (s *Storage) SaveUserAndAssociations( user *User, roles []*Role, userGroups []*UserGroup) (err error)
NOTE: parameter: roles([]*Users) and userGroups([]*Role) need to be distinguished as nil or zero length slice.
func (*Storage) SaveUserGroupAndAssociations ¶ added in v1.2202.0
NOTE: parameter: us([]*Users) and rs([]*Role) need to be distinguished as nil or zero length slice.
func (*Storage) SaveWorkflowTemplate ¶
func (s *Storage) SaveWorkflowTemplate(template *WorkflowTemplate) error
func (*Storage) TaskWorkflowIsRunning ¶
func (*Storage) UpdateAuditPlanByName ¶
func (*Storage) UpdateDefaultAuditPlanSQLs ¶ added in v1.2202.0
func (s *Storage) UpdateDefaultAuditPlanSQLs(apName string, sqls []*AuditPlanSQLV2) error
func (*Storage) UpdateExecuteSQLById ¶
func (*Storage) UpdateExecuteSQLStatusByTaskId ¶
func (*Storage) UpdateExecuteSQLs ¶
func (s *Storage) UpdateExecuteSQLs(ExecuteSQLs []*ExecuteSQL) error
func (*Storage) UpdateExecuteSqlStatus ¶
func (*Storage) UpdateInstanceById ¶
func (*Storage) UpdateInstanceRoles ¶
func (*Storage) UpdateInstanceRuleTemplates ¶
func (s *Storage) UpdateInstanceRuleTemplates(instance *Instance, ts ...*RuleTemplate) error
func (*Storage) UpdatePassword ¶
func (*Storage) UpdateRoleInstances ¶
func (*Storage) UpdateRoleUsers ¶
func (*Storage) UpdateRollbackSQLById ¶
func (*Storage) UpdateRollbackSQLs ¶
func (s *Storage) UpdateRollbackSQLs(rollbackSQLs []*RollbackSQL) error
func (*Storage) UpdateRollbackSqlStatus ¶
func (*Storage) UpdateRuleTemplateInstances ¶
func (s *Storage) UpdateRuleTemplateInstances(tpl *RuleTemplate, instances ...*Instance) error
func (*Storage) UpdateRuleTemplateRules ¶
func (s *Storage) UpdateRuleTemplateRules(tpl *RuleTemplate, rules ...RuleTemplateRule) error
func (*Storage) UpdateTask ¶
func (*Storage) UpdateTaskStatusById ¶
func (*Storage) UpdateUserAuthenticationTypeByName ¶ added in v1.2205.0
func (s *Storage) UpdateUserAuthenticationTypeByName(name string, tp UserAuthenticationType) error
func (*Storage) UpdateWorkflowRecord ¶
func (*Storage) UpdateWorkflowSchedule ¶ added in v1.2112.0
func (*Storage) UpdateWorkflowStatus ¶
func (s *Storage) UpdateWorkflowStatus(w *Workflow, operateStep *WorkflowStep) error
func (*Storage) UpdateWorkflowTemplateInstances ¶
func (s *Storage) UpdateWorkflowTemplateInstances(workflowTemplate *WorkflowTemplate, instances ...*Instance) error
func (*Storage) UpdateWorkflowTemplateSteps ¶
func (s *Storage) UpdateWorkflowTemplateSteps(templateId uint, steps []*WorkflowStepTemplate) error
func (*Storage) UserCanAccessInstance ¶
func (*Storage) UserCanAccessWorkflow ¶
func (*Storage) UserHasBindWorkflowTemplate ¶
type SystemVariable ¶
SystemVariable store misc K-V.
type Task ¶
type Task struct { Model InstanceId uint `json:"instance_id"` Schema string `json:"instance_schema" gorm:"column:instance_schema" example:"db1"` PassRate float64 `json:"pass_rate"` Score int32 `json:"score"` AuditLevel string `json:"audit_level"` SQLSource string `json:"sql_source" gorm:"column:sql_source"` DBType string `json:"db_type" gorm:"default:'mysql'" example:"mysql"` Status string `json:"status" gorm:"default:\"initialized\""` CreateUserId uint ExecStartAt *time.Time ExecEndAt *time.Time CreateUser *User `gorm:"foreignkey:CreateUserId"` Instance *Instance `json:"-" gorm:"foreignkey:InstanceId"` ExecuteSQLs []*ExecuteSQL `json:"-" gorm:"foreignkey:TaskId"` RollbackSQLs []*RollbackSQL `json:"-" gorm:"foreignkey:TaskId"` }
func (*Task) HasDoingAudit ¶
func (*Task) HasDoingExecute ¶
func (*Task) HasDoingRollback ¶
func (*Task) InstanceName ¶
func (*Task) IsExecuteFailed ¶
type TaskSQLDetail ¶
type TaskSQLDetail struct { Number uint `json:"number"` Description string `json:"description"` ExecSQL string `json:"exec_sql"` AuditResult string `json:"audit_result"` AuditLevel string `json:"audit_level"` AuditStatus string `json:"audit_status"` ExecResult string `json:"exec_result"` ExecStatus string `json:"exec_status"` RollbackSQL sql.NullString `json:"rollback_sql"` }
type User ¶
type User struct { Model // has created composite index: [id, login_name] by gorm#AddIndex Name string `gorm:"index;column:login_name"` Email string WeChatID string `json:"wechat_id" gorm:"column:wechat_id"` Password string `json:"-" gorm:"-"` SecretPassword string `json:"secret_password" gorm:"not null;column:password"` UserAuthenticationType UserAuthenticationType `json:"user_authentication_type" gorm:"not null"` Roles []*Role `gorm:"many2many:user_role;"` UserGroups []*UserGroup `gorm:"many2many:user_group_users"` Stat uint `json:"stat" gorm:"not null; default: 0; comment:'0:正常 1:被禁用'"` ThirdPartyUserID string `json:"third_party_user_id"` WorkflowStepTemplates []*WorkflowStepTemplate `gorm:"many2many:workflow_step_template_user"` }
func (*User) AfterFind ¶
AfterFind is a hook implement gorm model after query, ignore err if query from db
func (*User) BeforeSave ¶
BeforeSave is a hook implement gorm model before exec create
func (*User) IsDisabled ¶ added in v1.2202.0
type UserAuthenticationType ¶ added in v1.2111.0
type UserAuthenticationType string
const ( UserAuthenticationTypeLDAP UserAuthenticationType = "ldap" // user verify through ldap UserAuthenticationTypeSQLE UserAuthenticationType = "sqle" //user verify through sqle UserAuthenticationTypeOAUTH2 UserAuthenticationType = "oauth2" //user verify through oauth2 )
type UserDetail ¶
type UserDetail struct { Id int Name string `json:"login_name"` Email string WeChatID sql.NullString `json:"wechat_id"` LoginType string `json:"user_authentication_type"` Stat int `json:"stat"` RoleNames RowList `json:"role_names"` UserGroupNames RowList `json:"user_group_names"` }
func (*UserDetail) IsDisabled ¶ added in v1.2202.0
func (u *UserDetail) IsDisabled() bool
type UserGroup ¶ added in v1.2202.0
type UserGroup struct { Model Name string `json:"name" gorm:"index"` Desc string `json:"desc" gorm:"column:description"` Users []*User `gorm:"many2many:user_group_users"` Stat uint `json:"stat" gorm:"comment:'0:active,1:disabled'"` Roles []*Role `gorm:"many2many:user_group_roles"` }
func (*UserGroup) IsDisabled ¶ added in v1.2202.0
type UserGroupDetail ¶ added in v1.2202.0
type UserGroupDetail struct { Id int Name string `json:"name"` Desc string `json:"description"` Stat uint `json:"stat"` UserNames RowList `json:"user_names"` RoleNames RowList `json:"role_names"` }
func (*UserGroupDetail) IsDisabled ¶ added in v1.2202.0
func (ugd *UserGroupDetail) IsDisabled() bool
type WeChatConfiguration ¶ added in v1.2203.0
type WeChatConfiguration struct { Model EnableWeChatNotify bool `json:"enable_wechat_notify" gorm:"not null"` CorpID string `json:"corp_id" gorm:"not null"` CorpSecret string `json:"-" gorm:"-"` EncryptedCorpSecret string `json:"encrypted_corp_secret" gorm:"not null"` AgentID int `json:"agent_id" gorm:"not null"` SafeEnabled bool `json:"safe_enabled" gorm:"not null"` ProxyIP string `json:"proxy_ip"` }
WeChatConfiguration store WeChat configuration.
func (*WeChatConfiguration) AfterFind ¶ added in v1.2203.0
func (i *WeChatConfiguration) AfterFind() error
AfterFind is a hook implement gorm model after query, ignore err if query from db.
func (*WeChatConfiguration) BeforeSave ¶ added in v1.2203.0
func (i *WeChatConfiguration) BeforeSave() error
BeforeSave is a hook implement gorm model before exec create.
func (*WeChatConfiguration) TableName ¶ added in v1.2203.0
func (i *WeChatConfiguration) TableName() string
type Workflow ¶
type Workflow struct { Model Subject string Desc string CreateUserId uint WorkflowRecordId uint CreateUser *User `gorm:"foreignkey:CreateUserId"` Record *WorkflowRecord `gorm:"foreignkey:WorkflowRecordId"` RecordHistory []*WorkflowRecord `gorm:"many2many:workflow_record_history;"` }
func (*Workflow) CreateUserName ¶
func (*Workflow) CurrentAssigneeUser ¶
func (*Workflow) CurrentStep ¶
func (w *Workflow) CurrentStep() *WorkflowStep
func (*Workflow) FinalStep ¶
func (w *Workflow) FinalStep() *WorkflowStep
func (*Workflow) IsFirstRecord ¶
func (w *Workflow) IsFirstRecord(record *WorkflowRecord) bool
IsFirstRecord check the record is the first record in workflow; you must load record history first and then use it.
func (*Workflow) IsOperationUser ¶
func (*Workflow) NextStep ¶
func (w *Workflow) NextStep() *WorkflowStep
type WorkflowListDetail ¶
type WorkflowListDetail struct { Id uint `json:"workflow_id"` Subject string `json:"subject"` Desc string `json:"desc"` TaskPassRate float64 `json:"task_pass_rate"` TaskScore sql.NullInt32 `json:"task_score"` TaskInstance sql.NullString `json:"task_instance_name"` TaskInstanceDeletedAt *time.Time `json:"task_instance_deleted_at"` TaskInstanceSchema string `json:"task_instance_schema"` TaskStatus string `json:"task_status"` CreateUser sql.NullString `json:"create_user_name"` CreateUserDeletedAt *time.Time `json:"create_user_deleted_at"` CreateTime *time.Time `json:"create_time"` CurrentStepType sql.NullString `json:"current_step_type" enums:"sql_review,sql_execute"` CurrentStepAssigneeUser RowList `json:"current_step_assignee_user_name_list"` Status string `json:"status"` ScheduleTime *time.Time `json:"schedule_time"` }
type WorkflowRecord ¶
type WorkflowRecord struct { Model TaskId uint `gorm:"index"` CurrentWorkflowStepId uint Status string `gorm:"default:\"on_process\""` ScheduledAt *time.Time ScheduleUserId uint CurrentStep *WorkflowStep `gorm:"foreignkey:CurrentWorkflowStepId"` Steps []*WorkflowStep `gorm:"foreignkey:WorkflowRecordId"` }
type WorkflowStep ¶
type WorkflowStep struct { Model OperationUserId uint OperateAt *time.Time WorkflowId uint `gorm:"index; not null"` WorkflowRecordId uint `gorm:"index; not null"` WorkflowStepTemplateId uint `gorm:"index; not null"` State string `gorm:"default:\"initialized\""` Reason string Assignees []*User `gorm:"many2many:workflow_step_user"` Template *WorkflowStepTemplate `gorm:"foreignkey:WorkflowStepTemplateId"` OperationUser *User `gorm:"foreignkey:OperationUserId"` }
type WorkflowStepTemplate ¶
type WorkflowStepTemplate struct { Model Number uint `gorm:"index; column:step_number"` WorkflowTemplateId int `gorm:"index"` Typ string `gorm:"column:type; not null"` Desc string ApprovedByAuthorized sql.NullBool `gorm:"column:approved_by_authorized"` Users []*User `gorm:"many2many:workflow_step_template_user"` }
type WorkflowTemplate ¶
type WorkflowTemplateDetail ¶
Source Files ¶
- audit_plan.go
- audit_plan_list.go
- audit_plan_report.go
- audit_plan_report_list.go
- base.go
- configuration.go
- instance.go
- instance_list.go
- operation.go
- operation_ce.go
- period.go
- role.go
- role_list.go
- rule.go
- rule_list.go
- sql_query.go
- sql_whitelist.go
- task.go
- user.go
- user_group.go
- user_list.go
- utils.go
- workflow.go
- workflow_list.go