完善定价与套餐关联表结构

This commit is contained in:
2026-03-24 16:25:21 +08:00
parent c9995ef566
commit 5ffa151f58
28 changed files with 1550 additions and 112 deletions

View File

@@ -11,10 +11,12 @@ type Resource struct {
ResourceNo *string `json:"resource_no,omitempty" gorm:"column:resource_no"` // 套餐编号
Active bool `json:"active" gorm:"column:active"` // 套餐状态
Type ResourceType `json:"type" gorm:"column:type"` // 套餐类型1-短效动态2-长效动态
Code string `json:"code" gorm:"column:code"` // 产品编码
User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
Short *ResourceShort `json:"short,omitempty" gorm:"foreignKey:ResourceID"`
Long *ResourceLong `json:"long,omitempty" gorm:"foreignKey:ResourceID"`
User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
Short *ResourceShort `json:"short,omitempty" gorm:"foreignKey:ResourceID"`
Long *ResourceLong `json:"long,omitempty" gorm:"foreignKey:ResourceID"`
Product *Product `json:"product,omitempty" gorm:"foreignKey:Code;references:Code"`
}
// ResourceType 套餐类型枚举
@@ -25,7 +27,18 @@ const (
ResourceTypeLong ResourceType = 2 // 长效动态
)
// ResourceLongType 套餐计费模式枚举
func (t ResourceType) Code() string {
switch t {
case ResourceTypeShort:
return "short"
case ResourceTypeLong:
return "long"
default:
return "unknown"
}
}
// ResourceMode 套餐计费模式枚举
type ResourceMode int
const (