Files
aiops/backend/model/log_scope_role.go
T
Logan 7e1c8f583c feat: 工具配置增强、站点拨测与日志中心多项改进
- 工具配置:新增卸载 API/UI、Go 工具链、流水线构建自动安装依赖
- 修复 ListTools VerifyTool 递归栈溢出导致获取工具配置失败
- Node.js Alpine 安装改用 unofficial-builds musl 预编译包与 index.json 解析 LTS
- 站点拨测:详情页路由、告警自动恢复、并发拨测与默认可观测频率
- 日志中心:RBAC、查询构建器、ES/Loki 增强与审计 request/response 展示
- 发布配置:构建节点、流水线远程执行、Deploy RBAC 导航拆分
2026-07-02 07:47:33 +08:00

72 lines
3.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
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"`
}
func (LogScopeRole) TableName() string { return "monitor_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"`
CreatedAt time.Time `json:"created_at"`
LogScopeRole *LogScopeRole `json:"log_scope_role,omitempty" gorm:"foreignKey:LogScopeRoleID"`
}
func (UserLogScopeRole) TableName() string { return "monitor_user_log_scope_roles" }
// CreateLogScopeRoleRequest 创建日志权限策略 // Logan.Li
type CreateLogScopeRoleRequest struct {
Name string `json:"name" binding:"required,max=64"`
Code string `json:"code" binding:"required,max=64"`
Engine string `json:"engine" binding:"omitempty,oneof=loki elasticsearch *"`
MatchField string `json:"match_field" binding:"required,oneof=index app namespace job"`
Pattern string `json:"pattern" binding:"required,max=255"`
DatasourceID *uint `json:"datasource_id"`
Role string `json:"role" binding:"omitempty,oneof=viewer analyst"`
Description string `json:"description"`
}
// UpdateLogScopeRoleRequest 更新日志权限策略 // Logan.Li
type UpdateLogScopeRoleRequest struct {
Name string `json:"name"`
Code string `json:"code"`
Engine string `json:"engine"`
MatchField string `json:"match_field"`
Pattern string `json:"pattern"`
DatasourceID *uint `json:"datasource_id"`
Role string `json:"role"`
Description string `json:"description"`
Status *int `json:"status"`
}
// AssignLogScopeRoleRequest 用户授权(user_id 取自 URL 路径)// Logan.Li
type AssignLogScopeRoleRequest struct {
LogScopeRoleID uint `json:"log_scope_role_id" binding:"required"`
}
// 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"`
}