dal-license-server/internal/model/request.go
djuka dc0114e4b7 Inicijalni commit: kompletna implementacija + dokumentacija + testovi
- Kompletna Go implementacija licencnog servera (19 Go fajlova)
- Klijentski API: activate, deactivate, validate
- Admin API: CRUD licence, stats, audit log
- Admin dashboard: htmx + Go templates
- RSA-2048 potpisivanje licencnih podataka
- Rate limiting i API key autentifikacija
- MySQL migracije i seed podaci (ESIR, ARV, LIGHT_TICKET)
- Unit testovi: keygen, crypto, model, middleware (24 testa)
- Dokumentacija: SPEC.md, ARCHITECTURE.md, SETUP.md, API.md, TESTING.md, README.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 07:42:25 +00:00

117 lines
3.7 KiB
Go

package model
import "encoding/json"
// Client API requests
type ActivateRequest struct {
LicenseKey string `json:"license_key"`
MachineFingerprint string `json:"machine_fingerprint"`
AppVersion string `json:"app_version"`
OS string `json:"os"`
Hostname string `json:"hostname"`
}
type DeactivateRequest struct {
LicenseKey string `json:"license_key"`
MachineFingerprint string `json:"machine_fingerprint"`
}
type ValidateRequest struct {
LicenseKey string `json:"license_key"`
MachineFingerprint string `json:"machine_fingerprint"`
}
// Client API responses
type ActivateResponse struct {
License LicenseData `json:"license"`
Signature string `json:"signature"`
}
type LicenseData struct {
LicenseKey string `json:"license_key"`
Product string `json:"product"`
LicenseType string `json:"license_type"`
IssuedAt string `json:"issued_at"`
ExpiresAt string `json:"expires_at"`
ActivatedAt string `json:"activated_at"`
MachineFingerprint string `json:"machine_fingerprint"`
GraceDays int `json:"grace_days"`
Limits json.RawMessage `json:"limits"`
Features json.RawMessage `json:"features"`
Customer CustomerData `json:"customer"`
}
type CustomerData struct {
Name string `json:"name"`
Email string `json:"email"`
}
type ValidateResponse struct {
Valid bool `json:"valid"`
ExpiresAt string `json:"expires_at"`
Revoked bool `json:"revoked"`
}
type DeactivateResponse struct {
Message string `json:"message"`
CanReactivate bool `json:"can_reactivate"`
}
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
Details interface{} `json:"details,omitempty"`
}
// Admin API
type CreateLicenseRequest struct {
ProductID int64 `json:"product_id"`
LicenseType string `json:"license_type"`
CustomerName string `json:"customer_name"`
CustomerPIB string `json:"customer_pib"`
CustomerEmail string `json:"customer_email"`
Limits json.RawMessage `json:"limits"`
Features json.RawMessage `json:"features"`
GraceDays int `json:"grace_days"`
Notes string `json:"notes"`
}
type UpdateLicenseRequest struct {
CustomerName string `json:"customer_name"`
CustomerPIB string `json:"customer_pib"`
CustomerEmail string `json:"customer_email"`
Limits json.RawMessage `json:"limits"`
Features json.RawMessage `json:"features"`
GraceDays int `json:"grace_days"`
ExpiresAt string `json:"expires_at"`
Notes string `json:"notes"`
}
type RevokeRequest struct {
Reason string `json:"reason"`
}
type StatsResponse struct {
TotalLicenses int `json:"total_licenses"`
ActiveLicenses int `json:"active_licenses"`
ExpiredLicenses int `json:"expired_licenses"`
RevokedLicenses int `json:"revoked_licenses"`
ActiveActivations int `json:"active_activations"`
ByProduct []ProductStats `json:"by_product"`
}
type ProductStats struct {
ProductCode string `json:"product_code"`
ProductName string `json:"product_name"`
Total int `json:"total"`
Active int `json:"active"`
Expired int `json:"expired"`
InGrace int `json:"in_grace"`
Trial int `json:"trial"`
ActiveActivations int `json:"active_activations"`
}