api-platform/internal/entity/Package.go
2024-11-24 01:38:32 +08:00

44 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
}