feat: 清除全部mock数据,Ansible/日志/告警中心/角色权限接真实API;移除SQL审计(不属于项目定位)
This commit is contained in:
1 parent
73b5a48df9
commit
df697e0b25
12 files changed
+593
-903
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// SQLAuditRecord SQL审计记录 // Logan.Li
|
||||
type SQLAuditRecord struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
SQLContent string `gorm:"type:text;not null" json:"sql_content"`
|
||||
SQLType string `gorm:"size:50" json:"sql_type"` // DDL/DML/DQL/DCL
|
||||
DatabaseName string `gorm:"size:255" json:"database_name"`
|
||||
TableName string `gorm:"size:255" json:"table_name"`
|
||||
RiskLevel string `gorm:"size:20;default:safe" json:"risk_level"` // high/medium/low/safe
|
||||
RiskRules string `gorm:"type:text" json:"risk_rules"` // JSON 数组
|
||||
Status string `gorm:"size:20;default:pending" json:"status"` // pending/approved/rejected/executed
|
||||
Executor string `gorm:"size:255" json:"executor"`
|
||||
Approver string `gorm:"size:255" json:"approver"`
|
||||
ExecuteTime *time.Time `json:"execute_time"`
|
||||
AffectedRows int64 `gorm:"default:0" json:"affected_rows"`
|
||||
ExecutionTime int64 `gorm:"default:0" json:"execution_time"` // 毫秒
|
||||
SourceIP string `gorm:"size:100" json:"source_ip"`
|
||||
Application string `gorm:"size:255" json:"application"`
|
||||
TicketID string `gorm:"size:100" json:"ticket_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (SQLAuditRecord) TableName() string { return "sql_audit_records" }
|
||||
|
||||
// SQLAuditRule SQL审计规则 // Logan.Li
|
||||
type SQLAuditRule struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:255;not null" json:"name"`
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
Pattern string `gorm:"type:text" json:"pattern"` // 正则/关键词匹配
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
Severity string `gorm:"size:20;default:medium" json:"severity"` // high/medium/low
|
||||
Category string `gorm:"size:100" json:"category"` // DDL/DML/DROP/TRUNCATE/etc
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
func (SQLAuditRule) TableName() string { return "sql_audit_rules" }
|
||||
|
||||
// AnalyzeSQLRequest SQL分析请求 // Logan.Li
|
||||
type AnalyzeSQLRequest struct {
|
||||
SQL string `json:"sql"`
|
||||
DatabaseName string `json:"database_name"`
|
||||
Application string `json:"application"`
|
||||
}
|
||||
|
||||
// AnalyzeSQLResponse SQL分析响应 // Logan.Li
|
||||
type AnalyzeSQLResponse struct {
|
||||
ID int64 `json:"id"`
|
||||
RiskLevel string `json:"risk_level"`
|
||||
RiskRules []string `json:"risk_rules"`
|
||||
SQLType string `json:"sql_type"`
|
||||
TableName string `json:"table_name"`
|
||||
}
|
||||
Reference in new issue
Block a user