基于 opsx-web-lite 框架(Go+Gin+Vue3+Element Plus)构建许可证管理服务器,
业务域参考 Licence 服务器 Web 版。
【后端 - 4层架构】
- 认证:单 Admin 表 + JWT(HS256)
- 核心授权域:Product / Customer / License / Activation
· License 生成/验证/激活/机器绑定/心跳/续期/吊销
· 客户端契约接口:/api/v1/license/{verify,activate,deactivate,heartbeat}
- 定价订单:Plan / Order / 支付网关配置
- 防重复购买:CustomerEntitlement + 幂等支付 webhook + 手动发放
- 分析审计:Dashboard 统计 / Analytics / AuditLog / Setting 管理
【前端】
- Dashboard(ECharts 图表)、产品、客户、License、计划、订单、权益、日志、设置
- 9 个完整 CRUD 业务页面 + 登录/布局
【部署】
- SQLite + 单二进制(//go:embed 嵌入前端)
- 开发:./run.sh start(前端5181/后端9001)
- 生产:./run.sh build && ./run.sh binary start
- 默认账号:admin/admin
Author: Logan.Li
104 lines
3.8 KiB
Go
104 lines
3.8 KiB
Go
package dto
|
|
|
|
// LicenseCreate 创建 License 请求 // Logan.Li
|
|
type LicenseCreate struct {
|
|
CustomerID uint `json:"customer_id" binding:"required"`
|
|
ProductID uint `json:"product_id" binding:"required"`
|
|
Duration int `json:"duration" binding:"required"` // 30/90/180/365/730/1095/1825/0(永久)
|
|
MaxActivations int `json:"max_activations"`
|
|
IsTrial bool `json:"is_trial"`
|
|
TrialDays int `json:"trial_days"`
|
|
Notes string `json:"notes"`
|
|
Count int `json:"count"` // 批量生成数量
|
|
}
|
|
|
|
// LicenseRenew 续期请求 // Logan.Li
|
|
type LicenseRenew struct {
|
|
Duration int `json:"duration" binding:"required"`
|
|
}
|
|
|
|
// LicenseRevoke 吊销请求 // Logan.Li
|
|
type LicenseRevoke struct {
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
// LicenseResponse License 响应 // Logan.Li
|
|
type LicenseResponse struct {
|
|
ID uint `json:"id"`
|
|
LicenseKey string `json:"license_key"`
|
|
CustomerID uint `json:"customer_id"`
|
|
CustomerName string `json:"customer_name"`
|
|
ProductID uint `json:"product_id"`
|
|
ProductName string `json:"product_name"`
|
|
Status string `json:"status"`
|
|
StartDate string `json:"start_date"`
|
|
EndDate string `json:"end_date"`
|
|
Duration int `json:"duration"`
|
|
MaxActivations int `json:"max_activations"`
|
|
CurrentActivations int `json:"current_activations"`
|
|
IsTrial bool `json:"is_trial"`
|
|
DaysLeft int `json:"days_left"`
|
|
Notes string `json:"notes"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
// ============ 客户端授权契约(无需认证) ============
|
|
|
|
// LicenseVerifyRequest 验证请求(客户端调用) // Logan.Li
|
|
type LicenseVerifyRequest struct {
|
|
LicenseKey string `json:"license_key" binding:"required"`
|
|
DeviceID string `json:"device_id"`
|
|
DeviceName string `json:"device_name"`
|
|
DeviceInfo string `json:"device_info"`
|
|
ProductID uint `json:"product_id"`
|
|
}
|
|
|
|
// LicenseVerifyResponse 验证响应 // Logan.Li
|
|
type LicenseVerifyResponse struct {
|
|
Valid bool `json:"valid"`
|
|
LicenseKey string `json:"license_key,omitempty"`
|
|
ProductID uint `json:"product_id,omitempty"`
|
|
ProductName string `json:"product_name,omitempty"`
|
|
ProductCode string `json:"product_code,omitempty"`
|
|
Features []string `json:"features,omitempty"`
|
|
Status string `json:"status,omitempty"`
|
|
ExpiresAt string `json:"expires_at,omitempty"`
|
|
DaysLeft int `json:"days_left,omitempty"`
|
|
MaxDevices int `json:"max_devices,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
// LicenseActivateRequest 激活请求(客户端调用) // Logan.Li
|
|
type LicenseActivateRequest struct {
|
|
LicenseKey string `json:"license_key" binding:"required"`
|
|
DeviceID string `json:"device_id" binding:"required"`
|
|
DeviceName string `json:"device_name"`
|
|
DeviceInfo string `json:"device_info"`
|
|
}
|
|
|
|
// LicenseDeactivateRequest 停用请求(客户端调用) // Logan.Li
|
|
type LicenseDeactivateRequest struct {
|
|
LicenseKey string `json:"license_key" binding:"required"`
|
|
DeviceID string `json:"device_id" binding:"required"`
|
|
}
|
|
|
|
// LicenseHeartbeatRequest 心跳请求(客户端调用) // Logan.Li
|
|
type LicenseHeartbeatRequest struct {
|
|
LicenseKey string `json:"license_key" binding:"required"`
|
|
DeviceID string `json:"device_id" binding:"required"`
|
|
}
|
|
|
|
// ActivationResponse 激活记录响应 // Logan.Li
|
|
type ActivationResponse struct {
|
|
ID uint `json:"id"`
|
|
LicenseID uint `json:"license_id"`
|
|
DeviceID string `json:"device_id"`
|
|
DeviceName string `json:"device_name"`
|
|
DeviceInfo string `json:"device_info"`
|
|
IP string `json:"ip"`
|
|
Status string `json:"status"`
|
|
IsOnline bool `json:"is_online"`
|
|
ActivatedAt string `json:"activated_at"`
|
|
LastSeenAt string `json:"last_seen_at"`
|
|
}
|