feat: 补全多云资产与账单同步
- 接入 AWS、华为云和 Azure 资产及账单 API - 按原始币种隔离统计并修正账号服务器数 - 修复侧栏菜单展开后的滚动行为
This commit is contained in:
1 parent
65e2f09b97
commit
132fe9ba97
25 files changed
+1094
-141
No files matched your search
+42
-42
@@ -2,24 +2,23 @@ package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
)
|
||||
|
||||
// CloudBilling 云账单模型 - 每日成本记录
|
||||
type CloudBilling struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CloudAccountID *uint `gorm:"index" json:"cloud_account_id"`
|
||||
AccountName string `gorm:"size:128" json:"account_name"`
|
||||
Provider string `gorm:"size:64;index" json:"provider"` // aliyun, tencent, aws, huawei, azure
|
||||
BillingDate string `gorm:"size:10;index;not null" json:"billing_date"` // YYYY-MM-DD
|
||||
Cost float64 `gorm:"type:decimal(12,2);default:0" json:"cost"` // 费用(元)
|
||||
Currency string `gorm:"size:8;default:CNY" json:"currency"` // CNY, USD
|
||||
Service string `gorm:"size:128" json:"service"` // ECS, RDS, OSS, CDN 等
|
||||
Region string `gorm:"size:64" json:"region"`
|
||||
Tags string `gorm:"type:text" json:"tags"` // JSON
|
||||
Description string `gorm:"size:500" json:"description"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CloudAccountID *uint `gorm:"index" json:"cloud_account_id"`
|
||||
AccountName string `gorm:"size:128" json:"account_name"`
|
||||
Provider string `gorm:"size:64;index" json:"provider"` // aliyun, tencent, aws, huawei, azure
|
||||
BillingDate string `gorm:"size:10;index;not null" json:"billing_date"` // YYYY-MM-DD
|
||||
Cost float64 `gorm:"type:decimal(12,2);default:0" json:"cost"` // 费用(元)
|
||||
Currency string `gorm:"size:8;default:CNY" json:"currency"` // CNY, USD
|
||||
Service string `gorm:"size:128" json:"service"` // ECS, RDS, OSS, CDN 等
|
||||
Region string `gorm:"size:64" json:"region"`
|
||||
Tags string `gorm:"type:text" json:"tags"` // JSON
|
||||
Description string `gorm:"size:500" json:"description"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (CloudBilling) TableName() string {
|
||||
@@ -28,17 +27,17 @@ func (CloudBilling) TableName() string {
|
||||
|
||||
// BillingAlertRule 账单预警规则
|
||||
type BillingAlertRule struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:128;not null" json:"name"`
|
||||
Provider string `gorm:"size:64" json:"provider"` // 空=所有云厂商
|
||||
CloudAccountID *uint `gorm:"index" json:"cloud_account_id"` // 空=所有账号
|
||||
Metric string `gorm:"size:32;default:daily" json:"metric"` // daily, monthly
|
||||
Threshold float64 `gorm:"type:decimal(12,2)" json:"threshold"` // 阈值(元)
|
||||
Operator string `gorm:"size:8;default:>" json:"operator"` // >, >=, <, <=
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
LastTriggered *time.Time `json:"last_triggered"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:128;not null" json:"name"`
|
||||
Provider string `gorm:"size:64" json:"provider"` // 空=所有云厂商
|
||||
CloudAccountID *uint `gorm:"index" json:"cloud_account_id"` // 空=所有账号
|
||||
Metric string `gorm:"size:32;default:daily" json:"metric"` // daily, monthly
|
||||
Threshold float64 `gorm:"type:decimal(12,2)" json:"threshold"` // 阈值(元)
|
||||
Operator string `gorm:"size:8;default:>" json:"operator"` // >, >=, <, <=
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
LastTriggered *time.Time `json:"last_triggered"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (BillingAlertRule) TableName() string {
|
||||
@@ -47,19 +46,20 @@ func (BillingAlertRule) TableName() string {
|
||||
|
||||
// BillingStats 账单统计
|
||||
type BillingStats struct {
|
||||
TodayCost float64 `json:"today_cost"`
|
||||
MonthCost float64 `json:"month_cost"`
|
||||
YearCost float64 `json:"year_cost"`
|
||||
YesterdayCost float64 `json:"yesterday_cost"`
|
||||
MonthTrend []DailyCost `json:"month_trend"`
|
||||
ProviderDist []ProviderCost `json:"provider_dist"`
|
||||
Alerts []BillingAlert `json:"alerts"`
|
||||
Currency string `json:"currency"`
|
||||
TodayCost float64 `json:"today_cost"`
|
||||
MonthCost float64 `json:"month_cost"`
|
||||
YearCost float64 `json:"year_cost"`
|
||||
YesterdayCost float64 `json:"yesterday_cost"`
|
||||
MonthTrend []DailyCost `json:"month_trend"`
|
||||
ProviderDist []ProviderCost `json:"provider_dist"`
|
||||
Alerts []BillingAlert `json:"alerts"`
|
||||
}
|
||||
|
||||
// DailyCost 每日成本
|
||||
type DailyCost struct {
|
||||
Date string `json:"date"`
|
||||
Cost float64 `json:"cost"`
|
||||
Date string `json:"date"`
|
||||
Cost float64 `json:"cost"`
|
||||
}
|
||||
|
||||
// ProviderCost 厂商成本分布
|
||||
@@ -82,15 +82,15 @@ type BillingAlert struct {
|
||||
|
||||
// CreateBillingRequest 创建账单记录请求
|
||||
type CreateBillingRequest struct {
|
||||
CloudAccountID *uint `json:"cloud_account_id"`
|
||||
AccountName string `json:"account_name"`
|
||||
Provider string `json:"provider" binding:"required"`
|
||||
BillingDate string `json:"billing_date" binding:"required"`
|
||||
CloudAccountID *uint `json:"cloud_account_id"`
|
||||
AccountName string `json:"account_name"`
|
||||
Provider string `json:"provider" binding:"required"`
|
||||
BillingDate string `json:"billing_date" binding:"required"`
|
||||
Cost float64 `json:"cost" binding:"required"`
|
||||
Currency string `json:"currency"`
|
||||
Service string `json:"service"`
|
||||
Region string `json:"region"`
|
||||
Description string `json:"description"`
|
||||
Currency string `json:"currency"`
|
||||
Service string `json:"service"`
|
||||
Region string `json:"region"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// CreateBillingAlertRequest 创建预警规则请求
|
||||
|
||||
Reference in new issue
Block a user