Files
aiops/backend/internal/models/ops_modules.go
T
attacker 73b5a48df9 refactor: 全局代码模块化重构 — 所有文件<700行
后端 handler 拆分:
- automation.go(1067→4文件), server.go(1011→5文件), ldap.go(815→3文件), user.go(704→2文件)

前端组件拆分:
- SystemManager(1782→569), AlertManager(1133→220), K8sClusters(1062→4文件)
- Dashboard(941→4文件), ServerManager(905→640), ApprovalFlow(830→548)
- AlertCenter(775→693), AIPredictiveAnalytics(760→670)
- CloudBilling(728→663), GrafanaDashboard(717→643), sidebar(726→689)

Mock 数据模块化:
- mocks/data.ts(2552行→barrel+11个domain模块)

新增 CLAUDE.md 项目全局开发规范

修复: AlertCenter/LogManager ListResponse.data→.list 类型不匹配
验证: go build ✅ + tsc --noEmit ✅ + npm run build ✅
2026-06-15 01:32:15 +08:00

91 lines
4.1 KiB
Go

package models
import (
"time"
"gorm.io/gorm"
)
// AnsiblePlaybook Playbook 模型 // Logan.Li
type AnsiblePlaybook struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Content string `gorm:"type:text;not null" json:"content"` // YAML 内容
Tags string `gorm:"size:500" json:"tags"` // 逗号分隔
Category string `gorm:"size:100" json:"category"` // deployment/maintenance/etc
CreatedBy string `gorm:"size:255" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (AnsiblePlaybook) TableName() string { return "ansible_playbooks" }
// AnsibleJob 执行任务记录 // Logan.Li
type AnsibleJob struct {
ID uint `gorm:"primarykey" json:"id"`
PlaybookID uint `gorm:"not null" json:"playbook_id"`
PlaybookName string `gorm:"size:255" json:"playbook_name"`
Status string `gorm:"size:20;default:pending" json:"status"` // pending/running/success/failed
TargetHosts string `gorm:"type:text" json:"target_hosts"` // JSON 数组
Variables string `gorm:"type:text" json:"variables"` // JSON
Output string `gorm:"type:text" json:"output"`
Duration int64 `gorm:"default:0" json:"duration"` // 毫秒
TriggeredBy string `gorm:"size:255" json:"triggered_by"`
StartedAt *time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (AnsibleJob) TableName() string { return "ansible_jobs" }
// AnsibleInventory 主机清单 // Logan.Li
type AnsibleInventory struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description"`
Hosts string `gorm:"type:text" json:"hosts"` // JSON 数组 [{name,ip,port,user,os}]
CreatedBy string `gorm:"size:255" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (AnsibleInventory) TableName() string { return "ansible_inventories" }
// LogSource 日志源 // Logan.Li
type LogSource struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Type string `gorm:"size:50;not null" json:"type"` // application/syslog/docker/kubernetes
Status string `gorm:"size:20;default:active" json:"status"`
Config string `gorm:"type:text" json:"config"` // JSON {path/pattern}
LogCount int64 `gorm:"default:0" json:"log_count"`
LastSeen *time.Time `json:"last_seen"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (LogSource) TableName() string { return "log_sources" }
// LogEntry 日志条目 // Logan.Li
type LogEntry struct {
ID uint `gorm:"primarykey" json:"id"`
SourceID uint `gorm:"index" json:"source_id"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
Level string `gorm:"size:20;index" json:"level"` // error/warn/info/debug
Service string `gorm:"size:255;index" json:"service"`
Host string `gorm:"size:255;index" json:"host"`
Message string `gorm:"type:text" json:"message"`
TraceID string `gorm:"size:100;index" json:"trace_id"`
Raw string `gorm:"type:text" json:"raw"`
CreatedAt time.Time `json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (LogEntry) TableName() string { return "log_entries" }