LicenseManger/internal/model/license.go

34 lines
1.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package model
import (
"time"
"gorm.io/gorm"
)
type LicenseCode struct {
gorm.Model
Code string `gorm:"uniqueIndex" json:"code"` // 授权码
LicenseType string `gorm:"size:20" json:"license_type"` // 授权类型time/count/permanent
Duration int `json:"duration"` // 授权时长(分钟)仅当类型为time时有效
MaxUses int `json:"max_uses"` // 最大使用次数仅当类型为count时有效
UsedCount int `gorm:"default:0" json:"used_count"` // 已使用次数
Status string `gorm:"size:20" json:"status"` // 状态unused/used/expired/revoked
UsedBy string `gorm:"index" json:"used_by"` // 使用此授权码的设备UID
UsedAt time.Time `json:"used_at"` // 使用时间
CreatedBy uint `gorm:"index" json:"created_by"` // 创建者ID
BatchNo string `gorm:"size:50;index" json:"batch_no"` // 批次号
Remark string `gorm:"size:500" json:"remark"` // 备注
BindCount int `gorm:"default:-1" json:"bind_count"` // 可绑定次数,-1表示无限制0表示不能绑定
}
type LicenseLog struct {
gorm.Model
LicenseID uint `gorm:"index" json:"license_id"` // 关联的授权码ID
DeviceUID string `gorm:"index" json:"device_uid"` // 设备UID
Action string `gorm:"size:20" json:"action"` // 操作类型create/use/verify
IP string `gorm:"size:50" json:"ip"` // 操作IP
Status string `gorm:"size:20" json:"status"` // 状态success/failed
Message string `gorm:"size:500" json:"message"` // 详细信息
}