c402ea0070
21B — DB & model: - licenses: 扩展 license_key 为 2048 字节(容纳 Ed25519 JWT), 新增 max_devices INT DEFAULT 3,device_id/activated_at 标为 deprecated - 新增 license_devices 表(license_id+device_id 唯一索引) - model/license_device.go:LicenseDevice struct - main.go AutoMigrate 加入 LicenseDevice - testutil/setup.go 同步 SQLite DDL 21C — trial at register: - config: 新增 Ed25519PrivateKey 配置项(LICENSE_ED25519_PRIVATE_KEY 环境变量) - service/license.go: createTrialLicense(tx, shopID) — 签发 30d trial, 私钥未配置时静默跳过(开发/测试不影响) - service/auth.go: Register 事务末尾调用 createTrialLicense Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
18 lines
735 B
Go
18 lines
735 B
Go
package model
|
|
|
|
import "time"
|
|
|
|
type License struct {
|
|
Base
|
|
ShopID uint64 `gorm:"not null;index" json:"shop_id"`
|
|
LicenseKey string `gorm:"size:2048;uniqueIndex" json:"license_key"`
|
|
Type string `gorm:"type:enum('trial','monthly','annual','lifetime');default:'trial'" json:"type"`
|
|
ExpiresAt *time.Time `json:"expires_at"`
|
|
IsActive bool `gorm:"default:true" json:"is_active"`
|
|
MaxDevices int `gorm:"default:3" json:"max_devices"`
|
|
Features JSON `gorm:"type:json" json:"features,omitempty"`
|
|
// Deprecated: device binding is now tracked in license_devices table.
|
|
DeviceID string `gorm:"size:255" json:"device_id,omitempty"`
|
|
ActivatedAt *time.Time `json:"activated_at,omitempty"`
|
|
}
|