基于 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
167 lines
6.6 KiB
Go
167 lines
6.6 KiB
Go
package dto
|
|
|
|
// PlanCreate 创建定价计划请求 // Logan.Li
|
|
type PlanCreate struct {
|
|
ProductID uint `json:"product_id" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
PlanType string `json:"plan_type" binding:"required"` // perpetual / monthly / yearly / lifetime
|
|
Price float64 `json:"price" binding:"required"`
|
|
Currency string `json:"currency"`
|
|
Duration int `json:"duration"`
|
|
MaxDevices int `json:"max_devices"`
|
|
Features []string `json:"features"`
|
|
SortOrder int `json:"sort_order"`
|
|
Status *int `json:"status"`
|
|
}
|
|
|
|
// PlanUpdate 更新定价计划请求 // Logan.Li
|
|
type PlanUpdate struct {
|
|
Name string `json:"name"`
|
|
Price *float64 `json:"price"`
|
|
Currency string `json:"currency"`
|
|
Duration *int `json:"duration"`
|
|
MaxDevices *int `json:"max_devices"`
|
|
Features []string `json:"features"`
|
|
SortOrder *int `json:"sort_order"`
|
|
Status *int `json:"status"`
|
|
}
|
|
|
|
// PlanResponse 定价计划响应 // Logan.Li
|
|
type PlanResponse struct {
|
|
ID uint `json:"id"`
|
|
ProductID uint `json:"product_id"`
|
|
Name string `json:"name"`
|
|
PlanType string `json:"plan_type"`
|
|
Price float64 `json:"price"`
|
|
Currency string `json:"currency"`
|
|
Duration int `json:"duration"`
|
|
MaxDevices int `json:"max_devices"`
|
|
Features []string `json:"features"`
|
|
SortOrder int `json:"sort_order"`
|
|
Status int `json:"status"`
|
|
}
|
|
|
|
// OrderResponse 订单响应 // Logan.Li
|
|
type OrderResponse struct {
|
|
ID uint `json:"id"`
|
|
OrderNo string `json:"order_no"`
|
|
CustomerID uint `json:"customer_id"`
|
|
CustomerName string `json:"customer_name"`
|
|
ProductID uint `json:"product_id"`
|
|
ProductName string `json:"product_name"`
|
|
PlanID uint `json:"plan_id"`
|
|
PlanName string `json:"plan_name"`
|
|
LicenseID uint `json:"license_id"`
|
|
Amount float64 `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
Status string `json:"status"`
|
|
PaymentGateway string `json:"payment_gateway"`
|
|
CreatedAt string `json:"created_at"`
|
|
PaidAt string `json:"paid_at,omitempty"`
|
|
}
|
|
|
|
// CreateOrderRequest 创建订单请求(客户端购买入口) // Logan.Li
|
|
type CreateOrderRequest struct {
|
|
CustomerEmail string `json:"customer_email" binding:"required,email"`
|
|
CustomerName string `json:"customer_name"`
|
|
ProductID uint `json:"product_id" binding:"required"`
|
|
PlanID uint `json:"plan_id" binding:"required"`
|
|
DeviceID string `json:"device_id"`
|
|
ReturnURL string `json:"return_url"`
|
|
CancelURL string `json:"cancel_url"`
|
|
}
|
|
|
|
// CreateOrderResponse 创建订单响应 // Logan.Li
|
|
type CreateOrderResponse struct {
|
|
OrderNo string `json:"order_no"`
|
|
CheckoutURL string `json:"checkout_url"`
|
|
Amount float64 `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
Status string `json:"status"`
|
|
Gateway string `json:"gateway"`
|
|
ExpiresAt string `json:"expires_at"`
|
|
}
|
|
|
|
// PaymentWebhookRequest 支付回调请求 // Logan.Li
|
|
type PaymentWebhookRequest struct {
|
|
EventType string `json:"event_type" binding:"required"`
|
|
OrderNo string `json:"order_no" binding:"required"`
|
|
GatewayOrderNo string `json:"gateway_order_no"`
|
|
Status string `json:"status" binding:"required"` // paid / failed / refunded
|
|
Amount float64 `json:"amount"`
|
|
Currency string `json:"currency"`
|
|
CustomerEmail string `json:"customer_email"`
|
|
Gateway string `json:"gateway" binding:"required"`
|
|
Signature string `json:"signature"`
|
|
Payload string `json:"payload"`
|
|
}
|
|
|
|
// ManualGrantRequest 手动发放 License 请求(管理后台) // Logan.Li
|
|
type ManualGrantRequest struct {
|
|
CustomerEmail string `json:"customer_email" binding:"required,email"`
|
|
CustomerName string `json:"customer_name"`
|
|
ProductID uint `json:"product_id" binding:"required"`
|
|
PlanID uint `json:"plan_id" binding:"required"`
|
|
DeviceID string `json:"device_id"`
|
|
Notes string `json:"notes"`
|
|
}
|
|
|
|
// EntitlementResponse 客户权益响应 // Logan.Li
|
|
type EntitlementResponse struct {
|
|
ID uint `json:"id"`
|
|
CustomerID uint `json:"customer_id"`
|
|
CustomerName string `json:"customer_name"`
|
|
ProductID uint `json:"product_id"`
|
|
ProductName string `json:"product_name"`
|
|
PlanID uint `json:"plan_id"`
|
|
PlanName string `json:"plan_name"`
|
|
PlanType string `json:"plan_type"`
|
|
LicenseKey string `json:"license_key"`
|
|
Status string `json:"status"`
|
|
ValidFrom string `json:"valid_from"`
|
|
ValidUntil *string `json:"valid_until,omitempty"`
|
|
DaysLeft int `json:"days_left"`
|
|
Renewable bool `json:"renewable"`
|
|
MaxDevices int `json:"max_devices"`
|
|
CurrentDevices int `json:"current_devices"`
|
|
}
|
|
|
|
// DuplicatePurchaseCheckRequest 防重复购买检测请求 // Logan.Li
|
|
type DuplicatePurchaseCheckRequest struct {
|
|
CustomerEmail string `json:"customer_email" binding:"required,email"`
|
|
ProductID uint `json:"product_id" binding:"required"`
|
|
}
|
|
|
|
// DuplicatePurchaseCheckResponse 防重复购买检测响应 // Logan.Li
|
|
type DuplicatePurchaseCheckResponse struct {
|
|
AllowPurchase bool `json:"allow_purchase"`
|
|
Reason string `json:"reason,omitempty"`
|
|
ExistingEntitlementID uint `json:"existing_entitlement_id,omitempty"`
|
|
ExistingLicenseKey string `json:"existing_license_key,omitempty"`
|
|
ExistingPlanType string `json:"existing_plan_type,omitempty"`
|
|
CanUpgrade bool `json:"can_upgrade"`
|
|
UpgradeOptions []PlanResponse `json:"upgrade_options,omitempty"`
|
|
}
|
|
|
|
// CheckPurchaseStatusRequest 购买状态查询请求 // Logan.Li
|
|
type CheckPurchaseStatusRequest struct {
|
|
CustomerEmail string `json:"customer_email" binding:"required,email"`
|
|
ProductID uint `json:"product_id" binding:"required"`
|
|
}
|
|
|
|
// CheckPurchaseStatusResponse 购买状态查询响应 // Logan.Li
|
|
type CheckPurchaseStatusResponse struct {
|
|
Purchased bool `json:"purchased"`
|
|
HasActiveLicense bool `json:"has_active_license"`
|
|
LicenseKey string `json:"license_key,omitempty"`
|
|
LicenseStatus string `json:"license_status,omitempty"`
|
|
PlanType string `json:"plan_type,omitempty"`
|
|
ValidUntil *string `json:"valid_until,omitempty"`
|
|
DaysLeft int `json:"days_left,omitempty"`
|
|
Renewable bool `json:"renewable"`
|
|
MaxDevices int `json:"max_devices,omitempty"`
|
|
CurrentDevices int `json:"current_devices,omitempty"`
|
|
EntitlementID uint `json:"entitlement_id,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|