package entity import ( "gorm.io/gorm" "leafdev.top/Leaf/api-platform/internal/schema" "time" ) // Packages 其实不应该加 s,但是 gorm gen 生成的代码中,package 是关键字,所以只能加 s type Packages struct { Model Name string `json:"name"` Description string `json:"description"` ApiId schema.EntityId `json:"api_id"` Api *Api `json:"api"` Price float64 `json:"price"` IsHidden bool `json:"is_hidden"` IsPublished bool `json:"is_published"` CallLimit int64 `json:"call_limit"` Duration int64 `json:"duration"` IsTrial bool `json:"is_trial"` PurchaseLimit int64 `json:"purchase_limit"` DeletedAt *gorm.DeletedAt `json:"deleted_at"` } func (u *Packages) TableName() string { return "packages" } type UserPackage struct { Model UserId schema.UserId `json:"user_id"` PackageId schema.EntityId `json:"package_id"` Package *Packages `json:"api_package"` CallsLeft int64 `json:"calls_left"` IsActive bool `json:"is_active"` ExpirationAt *time.Time `json:"expiration_at"` PurchaseAt time.Time `json:"purchase_at"` } func (u *UserPackage) TableName() string { return "user_packages" }