Initial commit (code only without large binaries)
This commit is contained in:
80
EdgeAPI/internal/db/models/plan_model_ext_plus.go
Normal file
80
EdgeAPI/internal/db/models/plan_model_ext_plus.go
Normal file
@@ -0,0 +1,80 @@
|
||||
//go:build plus
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
)
|
||||
|
||||
// DecodeTrafficPrice 解析流量价格配置
|
||||
func (this *Plan) DecodeTrafficPrice() *serverconfigs.PlanTrafficPriceConfig {
|
||||
var config = &serverconfigs.PlanTrafficPriceConfig{}
|
||||
|
||||
if len(this.TrafficPrice) == 0 {
|
||||
return config
|
||||
}
|
||||
|
||||
err := json.Unmarshal(this.TrafficPrice, config)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
// DecodeBandwidthPrice 解析带宽价格配置
|
||||
func (this *Plan) DecodeBandwidthPrice() *serverconfigs.PlanBandwidthPriceConfig {
|
||||
var config = &serverconfigs.PlanBandwidthPriceConfig{}
|
||||
|
||||
if len(this.BandwidthPrice) == 0 {
|
||||
return config
|
||||
}
|
||||
|
||||
err := json.Unmarshal(this.BandwidthPrice, config)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
// DecodeTrafficLimit 解析流量限制
|
||||
func (this *Plan) DecodeTrafficLimit() *serverconfigs.TrafficLimitConfig {
|
||||
if IsNull(this.TrafficLimit) {
|
||||
return nil
|
||||
}
|
||||
var trafficLimitConfig = &serverconfigs.TrafficLimitConfig{}
|
||||
err := json.Unmarshal(this.TrafficLimit, trafficLimitConfig)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
return trafficLimitConfig
|
||||
}
|
||||
|
||||
// DecodeBandwidthLimitPerNode 解析单节点流量限制
|
||||
func (this *Plan) DecodeBandwidthLimitPerNode() *shared.BitSizeCapacity {
|
||||
if IsNull(this.BandwidthLimitPerNode) {
|
||||
return nil
|
||||
}
|
||||
var capacity = &shared.BitSizeCapacity{}
|
||||
err := json.Unmarshal(this.BandwidthLimitPerNode, capacity)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
return capacity
|
||||
}
|
||||
|
||||
// DecodeMaxUploadSize 解析文件上传最大尺寸
|
||||
func (this *Plan) DecodeMaxUploadSize() *shared.SizeCapacity {
|
||||
var size = &shared.SizeCapacity{Unit: shared.SizeCapacityUnitGB}
|
||||
if IsNotNull(this.MaxUploadSize) {
|
||||
err := json.Unmarshal(this.MaxUploadSize, size)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
}
|
||||
return size
|
||||
}
|
||||
Reference in New Issue
Block a user