init: EZOps AIOps 智能运维平台
- 前端: React 18 + TypeScript + Vite + Tailwind CSS + shadcn/ui - 后端: Go + Gin + GORM + JWT (golang-jwt/jwt/v5) - 功能: 服务器管理、K8s集群、监控告警、CI/CD、自动化运维、审批流程、审计日志 - 文档: 设计文档(ROADMAP/PDD/架构/模块)
This commit is contained in:
commit
7d6674bddd
156 files changed
+45704
No files matched your search
@@ -0,0 +1,108 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 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"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (ApprovalTemplate) TableName() string {
|
||||
return "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"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
// 关联
|
||||
Template *ApprovalTemplate `json:"template,omitempty"`
|
||||
ApplicantUser *User `json:"applicant_user,omitempty"`
|
||||
Steps []ApprovalStep `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 `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=release server 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" binding:"required,oneof=approved rejected"`
|
||||
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"`
|
||||
}
|
||||
Reference in new issue
Block a user