package models import "time" // License Pro 授权(离线许可码激活;无许可 = 免费版)。 // Plan: free | pro;Edition: personal(单实例/社区) | team(多实例/商业)。 type License struct { Plan string `json:"plan"` // free | pro Edition string `json:"edition"` // personal | team Seats int `json:"seats"` // 席位数(0 = 不限) Instances int `json:"instances"` // 实例数上限(team 版;0 = 不限) Customer string `json:"customer"` // 客户标识(发行时写入) // ExpiresAt 0 = 永久;否则 Unix 秒 ExpiresAt int64 `json:"expiresAt"` IssuedAt time.Time `json:"issuedAt"` ActivatedAt time.Time `json:"activatedAt"` } func (l *License) Sanitized() map[string]interface{} { if l == nil { return map[string]interface{}{"plan": "free"} } expired := l.ExpiresAt > 0 && l.ExpiresAt < time.Now().Unix() plan := l.Plan if expired { plan = "free" } return map[string]interface{}{ "plan": plan, "edition": l.Edition, "seats": l.Seats, "instances": l.Instances, "customer": l.Customer, "expiresAt": l.ExpiresAt, "expired": expired, } }