2024-11-23 17:28:44 +00:00
|
|
|
|
package entity
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
"leafdev.top/Leaf/api-platform/internal/schema"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-23 17:38:32 +00:00
|
|
|
|
// Packages 其实不应该加 s,但是 gorm gen 生成的代码中,package 是关键字,所以只能加 s
|
|
|
|
|
type Packages struct {
|
2024-11-23 17:28:44 +00:00
|
|
|
|
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"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-23 17:38:32 +00:00
|
|
|
|
func (u *Packages) TableName() string {
|
2024-11-23 17:28:44 +00:00
|
|
|
|
return "packages"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UserPackage struct {
|
|
|
|
|
Model
|
|
|
|
|
UserId schema.UserId `json:"user_id"`
|
|
|
|
|
PackageId schema.EntityId `json:"package_id"`
|
2024-11-23 17:38:32 +00:00
|
|
|
|
Package *Packages `json:"api_package"`
|
2024-11-23 17:28:44 +00:00
|
|
|
|
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"
|
|
|
|
|
}
|