feat: 服务器批量导入全栈实现 + SQL审计模型修复 + 审批流程增强
服务器批量导入: - 后端 BatchCreateServers handler: 逐条校验/查重/GB→MB转换/错误明细 - 前端 CSV 解析器 + IP校验 + 模板下载 + 真实API导入 - 删除孤立占位组件 BatchImport.tsx SQL审计: - 修复 TableName 字段与 GORM 接口冲突 → TargetTable - 补全路由注册 + AutoMigrate + 种子数据 审批流程增强 + 告警/菜单微调 // Logan.Li
This commit is contained in:
1 parent
6545597412
commit
77c33a6fee
16 files changed
+863
-573
No files matched your search
@@ -55,4 +55,59 @@ func seedData(db *gorm.DB) {
|
||||
zap.L().Info("seeded default LDAP config (8.217.205.92:389)")
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 创建默认审批模板(资源申请)
|
||||
var tplCount int64
|
||||
db.Model(&models.ApprovalTemplate{}).Count(&tplCount)
|
||||
if tplCount == 0 {
|
||||
templates := []models.ApprovalTemplate{
|
||||
{
|
||||
Name: "云服务器申请",
|
||||
Code: "server_apply",
|
||||
Description: "申请云服务器资源(ECS/EC2),包含规格、数量、用途等信息",
|
||||
Type: "server_apply",
|
||||
FormSchema: `{
|
||||
"fields": [
|
||||
{"key": "provider", "label": "云厂商", "type": "select", "options": ["阿里云","腾讯云","华为云","AWS"], "required": true},
|
||||
{"key": "region", "label": "地域", "type": "text", "placeholder": "如 cn-hangzhou", "required": true},
|
||||
{"key": "spec", "label": "规格", "type": "select", "options": ["2C4G","4C8G","8C16G","16C32G","32C64G"], "required": true},
|
||||
{"key": "disk", "label": "系统盘(GB)", "type": "number", "default": 40, "required": true},
|
||||
{"key": "count", "label": "数量(台)", "type": "number", "default": 1, "required": true},
|
||||
{"key": "duration", "label": "时长", "type": "select", "options": ["1个月","3个月","6个月","1年"], "required": true},
|
||||
{"key": "purpose", "label": "用途说明", "type": "textarea", "required": true}
|
||||
]
|
||||
}`,
|
||||
FlowConfig: `[{"name":"直接主管","approver_role":"team_lead"},{"name":"运维负责人","approver_role":"ops_manager"}]`,
|
||||
Enabled: true,
|
||||
},
|
||||
{
|
||||
Name: "应用部署申请",
|
||||
Code: "app_deploy",
|
||||
Description: "申请新应用部署,包含 Git 地址、端口、Nacos 等配置信息",
|
||||
Type: "app_deploy",
|
||||
FormSchema: `{
|
||||
"fields": [
|
||||
{"key": "app_name", "label": "应用名称", "type": "text", "placeholder": "如 user-service", "required": true},
|
||||
{"key": "git_url", "label": "Git 地址", "type": "text", "placeholder": "如 https://github.com/org/repo.git", "required": true},
|
||||
{"key": "branch", "label": "分支", "type": "text", "default": "main", "required": true},
|
||||
{"key": "language", "label": "开发语言", "type": "select", "options": ["Java","Go","Python","Node.js","C++"], "required": true},
|
||||
{"key": "http_port", "label": "HTTP 端口", "type": "number", "placeholder": "如 8080", "required": false},
|
||||
{"key": "grpc_port", "label": "gRPC 端口", "type": "number", "placeholder": "如 9090", "required": false},
|
||||
{"key": "nacos_addr", "label": "Nacos 地址", "type": "text", "placeholder": "如 nacos.opsx.vip:8848", "required": true},
|
||||
{"key": "nacos_namespace", "label": "Nacos 命名空间", "type": "text", "placeholder": "如 production", "required": false},
|
||||
{"key": "env", "label": "部署环境", "type": "select", "options": ["dev","staging","prod"], "required": true},
|
||||
{"key": "replicas", "label": "副本数", "type": "number", "default": 2, "required": true},
|
||||
{"key": "remark", "label": "备注", "type": "textarea", "required": false}
|
||||
]
|
||||
}`,
|
||||
FlowConfig: `[{"name":"技术负责人","approver_role":"tech_lead"},{"name":"运维负责人","approver_role":"ops_manager"}]`,
|
||||
Enabled: true,
|
||||
},
|
||||
}
|
||||
if err := db.Create(&templates).Error; err != nil {
|
||||
zap.L().Warn("failed to seed approval templates", zap.Error(err))
|
||||
} else {
|
||||
zap.L().Info("seeded default approval templates (server_apply + app_deploy)")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user