Files
aiops/backend/internal/models/approval.go
T
attacker 5949ec5d0c feat: Agent采集uptime, 后端持久化kernel/uptime/diskIO, 前端磁盘BPS+IOPS展示
- Agent: system.go 添加 readUptime(), SystemStat 携带 Uptime
- Backend: Server 模型新增 Kernel 字段, ReceiveReport 持久化 kernel+uptime
- Backend: /agent/latest 返回 kernel/uptime/port_info/disk_io_info/disk_total
- Frontend: 磁盘监控改为 BPS+IOPS (4张卡片), 系统信息修复内核/运行时长/监听端口/磁盘容量
- 图表单位从 MB/s 改为 KB/s, 添加 formatBPS 工具函数
2026-06-19 01:10:00 +00:00

106 lines
3.8 KiB
Go

package models
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, permission
FormSchema string `gorm:"type:text" json:"form_schema"` // JSON
FlowConfig string `gorm:"type:text" json:"flow_config"` // JSON
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"`
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"`
}