Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
//go:build plus
package userconfigs
import (
"strings"
)
type ADPackagePeriod = string
const (
ADPackagePeriodMonth ADPackagePeriod = "month"
ADPackagePeriodYear ADPackagePeriod = "year"
)
func IsValidADPackagePeriod(period string) bool {
return period == ADPackagePeriodMonth || period == ADPackagePeriodYear
}
func ADPackagePeriodToMonths(count int32, unit ADPackagePeriod) int32 {
if count < 0 {
return count
}
switch unit {
case ADPackagePeriodMonth:
return count
case ADPackagePeriodYear:
return count * 12
}
return 0
}
func ADPackagePeriodUnitName(unit ADPackagePeriod) string {
switch unit {
case ADPackagePeriodMonth:
return "个月"
case ADPackagePeriodYear:
return "年"
}
return ""
}
type ADPackageSizeUnit = string
const (
ADPackageSizeUnitMb ADPackageSizeUnit = "mb"
ADPackageSizeUnitGb ADPackageSizeUnit = "gb"
ADPackageSizeUnitTb ADPackageSizeUnit = "tb"
)
func IsValidADPackageSizeUnit(unit string) bool {
return unit == ADPackageSizeUnitMb || unit == ADPackageSizeUnitGb || unit == ADPackageSizeUnitTb
}
func ADPackageSizeFullUnit(unit ADPackageSizeUnit) string {
if len(unit) != 2 {
return unit
}
return strings.ToUpper(unit[:1]) + unit[1:] + "ps"
}
func ADPackageSizeBits(count int32, unit ADPackageSizeUnit) int64 {
switch unit {
case ADPackageSizeUnitMb:
return int64(count) * (1 << 20) * 8
case ADPackageSizeUnitGb:
return int64(count) * (1 << 30) * 8
case ADPackageSizeUnitTb:
return int64(count) * (1 << 40) * 8
}
return 0
}