chore: 并入 iotlcm-openapi 历史到 openapi/(原提交 3b05d5a)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:02 +08:00
484 changed files with 34732 additions and 0 deletions
@@ -0,0 +1,27 @@
package common
import (
"math"
"github.com/gogf/gf/v2/errors/gerror"
)
func validateTrafficCutoffConfig(status int, threshold float64) error {
if status < 0 || status > 2 {
return gerror.New("达量断网配置状态无效")
}
if threshold < 0 {
return gerror.New("达量断网阈值不能小于0")
}
if status == 0 && threshold != 0 {
return gerror.New("未配置达量断网时阈值必须为0")
}
if status == 1 && threshold <= 0 {
return gerror.New("开启达量断网时阈值必须大于0")
}
rounded := math.Round(threshold*1000) / 1000
if math.Abs(threshold-rounded) > 0.0000001 {
return gerror.New("达量断网阈值最多保留3位小数")
}
return nil
}