1.4.5.2
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package antiddos
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
type UpdatePricesPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdatePricesPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdatePricesPopupAction) RunGet(params struct {
|
||||
PackageId int64
|
||||
}) {
|
||||
// 高防产品信息
|
||||
packageResp, err := this.RPC().ADPackageRPC().FindADPackage(this.AdminContext(), &pb.FindADPackageRequest{AdPackageId: params.PackageId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var p = packageResp.AdPackage
|
||||
if p == nil {
|
||||
this.NotFound("adPackage", params.PackageId)
|
||||
return
|
||||
}
|
||||
this.Data["package"] = maps.Map{
|
||||
"id": p.Id,
|
||||
"protectionBandwidthSize": p.ProtectionBandwidthSize,
|
||||
"protectionBandwidthUnit": p.ProtectionBandwidthUnit,
|
||||
"serverBandwidthSize": p.ServerBandwidthSize,
|
||||
"serverBandwidthUnit": p.ServerBandwidthUnit,
|
||||
}
|
||||
|
||||
// 有效期选项
|
||||
periodsResp, err := this.RPC().ADPackagePeriodRPC().FindAllAvailableADPackagePeriods(this.AdminContext(), &pb.FindAllAvailableADPackagePeriodsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var periodMaps = []maps.Map{}
|
||||
for _, period := range periodsResp.AdPackagePeriods {
|
||||
periodMaps = append(periodMaps, maps.Map{
|
||||
"id": period.Id,
|
||||
"count": period.Count,
|
||||
"unit": period.Unit,
|
||||
"name": types.String(period.Count) + userconfigs.ADPackagePeriodUnitName(period.Unit),
|
||||
})
|
||||
}
|
||||
this.Data["periods"] = periodMaps
|
||||
|
||||
// 所有价格
|
||||
pricesResp, err := this.RPC().ADPackagePriceRPC().FindADPackagePrices(this.AdminContext(), &pb.FindADPackagePricesRequest{AdPackageId: params.PackageId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var priceMap = map[string]float64{} // periodIdString => price
|
||||
for _, price := range pricesResp.AdPackagePrices {
|
||||
priceMap[types.String(price.AdPackagePeriodId)] = price.Price
|
||||
}
|
||||
|
||||
this.Data["prices"] = priceMap
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user