将带宽限制改为流量限制

This commit is contained in:
GoEdgeLab
2021-11-09 17:36:54 +08:00
parent 36ce7f0acd
commit ab1686bca5
7 changed files with 169 additions and 152 deletions

View File

@@ -77,19 +77,19 @@ func (this *PlanDAO) FindPlanName(tx *dbs.Tx, id int64) (string, error) {
}
// CreatePlan 创建套餐
func (this *PlanDAO) CreatePlan(tx *dbs.Tx, name string, clusterId int64, bandwidthLimitJSON []byte, featuresJSON []byte, priceType serverconfigs.PlanPriceType, bandwidthPriceJSON []byte, monthlyPrice float32, seasonallyPrice float32, yearlyPrice float32) (int64, error) {
func (this *PlanDAO) CreatePlan(tx *dbs.Tx, name string, clusterId int64, trafficLimitJSON []byte, featuresJSON []byte, priceType serverconfigs.PlanPriceType, trafficPriceJSON []byte, monthlyPrice float32, seasonallyPrice float32, yearlyPrice float32) (int64, error) {
var op = NewPlanOperator()
op.Name = name
op.ClusterId = clusterId
if len(bandwidthLimitJSON) > 0 {
op.BandwidthLimit = bandwidthLimitJSON
if len(trafficLimitJSON) > 0 {
op.TrafficLimit = trafficLimitJSON
}
if len(featuresJSON) > 0 {
op.Features = featuresJSON
}
op.PriceType = priceType
if len(bandwidthPriceJSON) > 0 {
op.BandwidthPrice = bandwidthPriceJSON
if len(trafficPriceJSON) > 0 {
op.TrafficPrice = trafficPriceJSON
}
if monthlyPrice >= 0 {
op.MonthlyPrice = monthlyPrice
@@ -106,7 +106,7 @@ func (this *PlanDAO) CreatePlan(tx *dbs.Tx, name string, clusterId int64, bandwi
}
// UpdatePlan 修改套餐
func (this *PlanDAO) UpdatePlan(tx *dbs.Tx, planId int64, name string, isOn bool, clusterId int64, bandwidthLimitJSON []byte, featuresJSON []byte, priceType serverconfigs.PlanPriceType, bandwidthPriceJSON []byte, monthlyPrice float32, seasonallyPrice float32, yearlyPrice float32) error {
func (this *PlanDAO) UpdatePlan(tx *dbs.Tx, planId int64, name string, isOn bool, clusterId int64, trafficLimitJSON []byte, featuresJSON []byte, priceType serverconfigs.PlanPriceType, trafficPriceJSON []byte, monthlyPrice float32, seasonallyPrice float32, yearlyPrice float32) error {
if planId <= 0 {
return errors.New("invalid planId")
}
@@ -125,15 +125,15 @@ func (this *PlanDAO) UpdatePlan(tx *dbs.Tx, planId int64, name string, isOn bool
op.Name = name
op.IsOn = isOn
op.ClusterId = clusterId
if len(bandwidthLimitJSON) > 0 {
op.BandwidthLimit = bandwidthLimitJSON
if len(trafficLimitJSON) > 0 {
op.TrafficLimit = trafficLimitJSON
}
if len(featuresJSON) > 0 {
op.Features = featuresJSON
}
op.PriceType = priceType
if len(bandwidthPriceJSON) > 0 {
op.BandwidthPrice = bandwidthPriceJSON
if len(trafficPriceJSON) > 0 {
op.TrafficPrice = trafficPriceJSON
}
if monthlyPrice >= 0 {
op.MonthlyPrice = monthlyPrice