This commit is contained in:
Logan committed 2026-07-09 14:16:56 +08:00
1 parent 0690285147
commit 5618cd2738
154 files changed
+5021 -3161

No files matched your search

+23 -23
View File
@@ -4,33 +4,33 @@ import "time"
// LogScopeRole 日志查询范围权限(正则匹配 ES 索引 / Loki label) // Logan.Li
type LogScopeRole struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
Engine string `gorm:"size:32;default:*;comment:引擎 loki/elasticsearch/*" json:"engine"`
MatchField string `gorm:"size:32;not null;comment:匹配维度 index/app/namespace/job" json:"match_field"`
Pattern string `gorm:"size:255;not null;comment:正则表达式" json:"pattern"`
DatasourceID *uint `json:"datasource_id,omitempty"`
Role string `gorm:"size:16;default:viewer;comment:viewer/analyst" json:"role"`
Description string `gorm:"size:255" json:"description"`
Status int `gorm:"default:1;comment:0禁用1启用" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
Engine string `gorm:"size:32;default:*;comment:引擎 loki/elasticsearch/*" json:"engine"`
MatchField string `gorm:"size:32;not null;comment:匹配维度 index/app/namespace/job" json:"match_field"`
Pattern string `gorm:"size:255;not null;comment:正则表达式" json:"pattern"`
DatasourceID *uint `json:"datasource_id,omitempty"`
Role string `gorm:"size:16;default:viewer;comment:viewer/analyst" json:"role"`
Description string `gorm:"size:255" json:"description"`
Status int `gorm:"default:1;comment:0禁用1启用" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (LogScopeRole) TableName() string { return "monitor_log_scope_roles" }
func (LogScopeRole) TableName() string { return "iam_log_scope_roles" }
// UserLogScopeRole 用户 ↔ 日志范围权限 // Logan.Li
type UserLogScopeRole struct {
ID uint `gorm:"primarykey" json:"id"`
UserID uint `gorm:"uniqueIndex:idx_user_log_scope;not null" json:"user_id"`
LogScopeRoleID uint `gorm:"uniqueIndex:idx_user_log_scope;not null" json:"log_scope_role_id"`
UserID uint `gorm:"uniqueIndex:idx_iam_user_log_scope_role;not null" json:"user_id"`
LogScopeRoleID uint `gorm:"uniqueIndex:idx_iam_user_log_scope_role;not null" json:"log_scope_role_id"`
CreatedAt time.Time `json:"created_at"`
LogScopeRole *LogScopeRole `json:"log_scope_role,omitempty" gorm:"foreignKey:LogScopeRoleID"`
LogScopeRole *LogScopeRole `json:"log_scope_role,omitempty" gorm:"foreignKey:LogScopeRoleID;references:ID"`
}
func (UserLogScopeRole) TableName() string { return "monitor_user_log_scope_roles" }
func (UserLogScopeRole) TableName() string { return "iam_user_log_scope_roles" }
// CreateLogScopeRoleRequest 创建日志权限策略 // Logan.Li
type CreateLogScopeRoleRequest struct {
@@ -64,9 +64,9 @@ type AssignLogScopeRoleRequest struct {
// PreviewLogScopeRequest 命中预览 // Logan.Li
type PreviewLogScopeRequest struct {
Engine string `json:"engine" binding:"required,oneof=loki elasticsearch"`
DatasourceID uint `json:"datasource_id"`
Index string `json:"index"`
Query string `json:"query"`
SampleValue string `json:"sample_value"`
}
Engine string `json:"engine" binding:"required,oneof=loki elasticsearch"`
DatasourceID uint `json:"datasource_id"`
Index string `json:"index"`
Query string `json:"query"`
SampleValue string `json:"sample_value"`
}