F1 告警静默规则 [done]: - 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式) - 告警引擎 isSilenced 集成 (alert_engine.go) - 前端 SilenceRuleTab + SilenceDialog - 路由 /alerts/silences 已注册 F2 审计日志导出 [done]: - 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM) - 支持 module/action/username/startTime/endTime 筛选 - 导出限制 10000 条防溢出,自动记录审计日志 - JSON 格式向后兼容 (format=json) - 前端 exportLogs 传递查询参数 同时包含累积的前期工作: - 目录重构 internal/ -> controller/model/router (v0.55-v0.57) - 后端分层架构 dto/repository/service/utils - 审计模块全功能 (终端审计/操作审计/登录日志) - asciicast v2 录制格式 - SFTP 文件浏览器 - StatStrip 紧凑统计条 - 在线会话自动刷新 - LiveMonitor WebSocket 诊断修复 验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
108 lines
4.0 KiB
Go
108 lines
4.0 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
)
|
|
|
|
// ApprovalTemplate 审批模板模型
|
|
type ApprovalTemplate struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Name string `gorm:"size:128;not null" json:"name"`
|
|
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
|
Description string `gorm:"size:500" json:"description"`
|
|
Type string `gorm:"size:32;not null" json:"type"` // release, server_apply, app_deploy, permission_request
|
|
FormSchema string `gorm:"type:text" json:"form_schema"` // JSON form fields config
|
|
FlowConfig string `gorm:"type:text" json:"flow_config"` // JSON approval flow steps
|
|
Category string `gorm:"size:32;default:resource" json:"category"` // resource, app, permission
|
|
Enabled bool `gorm:"default:true" json:"enabled"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (ApprovalTemplate) TableName() string {
|
|
return "sys_approval_templates"
|
|
}
|
|
|
|
// ApprovalProcess 审批流程模型
|
|
type ApprovalProcess struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
TemplateID uint `json:"template_id"`
|
|
Title string `gorm:"size:255;not null" json:"title"`
|
|
Applicant uint `json:"applicant"`
|
|
Status string `gorm:"size:32;default:pending" json:"status"` // pending, approved, rejected
|
|
FormData string `gorm:"type:text" json:"form_data"` // JSON
|
|
CurrentStep int `gorm:"default:0" json:"current_step"`
|
|
TotalSteps int `json:"total_steps"`
|
|
ApprovedAt *time.Time `json:"approved_at"`
|
|
RejectedAt *time.Time `json:"rejected_at"`
|
|
RejectReason string `gorm:"size:500" json:"reject_reason"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
// 关联
|
|
Template *ApprovalTemplate `gorm:"foreignKey:TemplateID" json:"template,omitempty"`
|
|
ApplicantUser *User `gorm:"foreignKey:Applicant" json:"applicant_user,omitempty"`
|
|
Steps []ApprovalStep `gorm:"foreignKey:ProcessID" json:"steps,omitempty"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (ApprovalProcess) TableName() string {
|
|
return "approval_processes"
|
|
}
|
|
|
|
// ApprovalStep 审批步骤模型
|
|
type ApprovalStep struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
ProcessID uint `json:"process_id"`
|
|
Step int `json:"step"`
|
|
Approver uint `json:"approver"`
|
|
Status string `gorm:"size:32;default:pending" json:"status"` // pending, approved, rejected
|
|
Comment string `gorm:"size:500" json:"comment"`
|
|
ApprovedAt *time.Time `json:"approved_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
// 关联
|
|
ApproverUser *User `gorm:"foreignKey:Approver" json:"approver_user,omitempty"`
|
|
}
|
|
|
|
// TableName 表名
|
|
func (ApprovalStep) TableName() string {
|
|
return "approval_steps"
|
|
}
|
|
|
|
// CreateApprovalTemplateRequest 创建审批模板请求
|
|
type CreateApprovalTemplateRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Code string `json:"code" binding:"required"`
|
|
Description string `json:"description"`
|
|
Type string `json:"type" binding:"required,oneof=server_apply app_deploy permission_request"`
|
|
Category string `json:"category"` // resource, app, permission
|
|
FormSchema string `json:"form_schema"`
|
|
FlowConfig string `json:"flow_config"`
|
|
}
|
|
|
|
// CreateApprovalProcessRequest 创建审批流程请求
|
|
type CreateApprovalProcessRequest struct {
|
|
TemplateID uint `json:"template_id" binding:"required"`
|
|
Title string `json:"title" binding:"required"`
|
|
FormData string `json:"form_data"`
|
|
}
|
|
|
|
// ApproveRequest 审批请求
|
|
type ApproveRequest struct {
|
|
Status string `json:"status"`
|
|
Comment string `json:"comment"`
|
|
}
|
|
|
|
// ApprovalStats 审批统计
|
|
type ApprovalStats struct {
|
|
Pending int64 `json:"pending"`
|
|
Approved int64 `json:"approved"`
|
|
Rejected int64 `json:"rejected"`
|
|
Total int64 `json:"total"`
|
|
MyPending int64 `json:"my_pending"`
|
|
}
|