api-platform/internal/entity/Package.go

43 lines
1.2 KiB
Go
Raw Normal View History

2024-11-23 17:28:44 +00:00
package entity
import (
"gorm.io/gorm"
"leafdev.top/Leaf/api-platform/internal/schema"
"time"
)
type Package 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 *Package) TableName() string {
return "packages"
}
type UserPackage struct {
Model
UserId schema.UserId `json:"user_id"`
PackageId schema.EntityId `json:"package_id"`
Package *Package `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"
}