feat(backend): license_devices 表 + 注册自动签发 trial (21B+21C)
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>
This commit is contained in:
@@ -90,9 +90,21 @@ func SetupTestDB() *gorm.DB {
|
||||
type TEXT DEFAULT 'trial',
|
||||
expires_at DATETIME,
|
||||
is_active INTEGER DEFAULT 1,
|
||||
max_devices INTEGER DEFAULT 3,
|
||||
features TEXT,
|
||||
activated_at DATETIME
|
||||
)`,
|
||||
`CREATE TABLE IF NOT EXISTS license_devices (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
license_id INTEGER NOT NULL,
|
||||
shop_id INTEGER NOT NULL,
|
||||
device_id TEXT NOT NULL,
|
||||
device_name TEXT,
|
||||
platform TEXT,
|
||||
activated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_seen_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(license_id, device_id)
|
||||
)`,
|
||||
`CREATE TABLE IF NOT EXISTS product_categories (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
created_at DATETIME,
|
||||
|
||||
Reference in New Issue
Block a user