1.4.5.2
This commit is contained in:
82
EdgePlus/pkg/utils/edition.go
Normal file
82
EdgePlus/pkg/utils/edition.go
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package utils
|
||||
|
||||
type EditionDefinition struct {
|
||||
Name string `json:"name"`
|
||||
Code ComponentCode `json:"code"`
|
||||
MaxNodes int `json:"maxNodes"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
func FindAllEditions() []*EditionDefinition {
|
||||
return []*EditionDefinition{
|
||||
{
|
||||
Name: "个人商业版",
|
||||
Code: EditionBasic,
|
||||
MaxNodes: 20,
|
||||
},
|
||||
{
|
||||
Name: "专业版",
|
||||
Code: EditionPro,
|
||||
MaxNodes: 100,
|
||||
},
|
||||
{
|
||||
Name: "企业版",
|
||||
Code: EditionEnt,
|
||||
MaxNodes: 500,
|
||||
},
|
||||
{
|
||||
Name: "豪华版",
|
||||
Code: EditionMax,
|
||||
MaxNodes: 1000, // TODO 未定
|
||||
},
|
||||
{
|
||||
Name: "旗舰版",
|
||||
Code: EditionUltra,
|
||||
MaxNodes: 1000,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func CheckEdition(edition Edition) bool {
|
||||
for _, e := range FindAllEditions() {
|
||||
if e.Code == edition {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func CompareEdition(edition1 Edition, edition2 Edition) int {
|
||||
var index1 = -1
|
||||
var index2 = -1
|
||||
|
||||
for index, edition := range FindAllEditions() {
|
||||
if edition.Code == edition1 {
|
||||
index1 = index
|
||||
}
|
||||
if edition.Code == edition2 {
|
||||
index2 = index
|
||||
}
|
||||
}
|
||||
if index2 > index1 {
|
||||
return -1
|
||||
}
|
||||
if index2 == index1 {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
func EditionName(edition Edition) string {
|
||||
if len(edition) == 0 {
|
||||
return ""
|
||||
}
|
||||
for _, e := range FindAllEditions() {
|
||||
if e.Code == edition {
|
||||
return e.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user