Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//go:build plus
|
||||
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CreateBandwidthPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreateBandwidthPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *CreateBandwidthPopupAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreateBandwidthPopupAction) RunPost(params struct {
|
||||
Name string
|
||||
MinMB uint32
|
||||
MaxMB uint32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称")
|
||||
|
||||
if params.MinMB > params.MaxMB {
|
||||
params.MinMB, params.MaxMB = params.MaxMB, params.MinMB
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().NodePriceItemRPC().CreateNodePriceItem(this.AdminContext(), &pb.CreateNodePriceItemRequest{
|
||||
Name: params.Name,
|
||||
Type: userconfigs.PriceTypeBandwidth,
|
||||
BitsFrom: int64(params.MinMB) << 20,
|
||||
BitsTo: int64(params.MaxMB) << 20,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
defer this.CreateLogInfo(codes.NodePriceItem_LogCreateNodePriceItemBandwidth, createResp.NodePriceItemId)
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//go:build plus
|
||||
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CreateTrafficPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreateTrafficPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *CreateTrafficPopupAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreateTrafficPopupAction) RunPost(params struct {
|
||||
Name string
|
||||
MinGB uint32
|
||||
MaxGB uint32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称")
|
||||
|
||||
if params.MinGB > 0 && params.MaxGB > 0 && params.MinGB > params.MaxGB {
|
||||
params.MinGB, params.MaxGB = params.MaxGB, params.MinGB
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().NodePriceItemRPC().CreateNodePriceItem(this.AdminContext(), &pb.CreateNodePriceItemRequest{
|
||||
Name: params.Name,
|
||||
Type: userconfigs.PriceTypeTraffic,
|
||||
BitsFrom: int64(params.MinGB) << 33,
|
||||
BitsTo: int64(params.MaxGB) << 33,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
defer this.CreateLogInfo(codes.NodePriceItem_LogCreateNodePriceItemTraffic, createResp.NodePriceItemId)
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//go:build plus
|
||||
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteAction) RunPost(params struct {
|
||||
ItemId int64
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.NodePriceItem_LogDeleteNodePriceItem, params.ItemId)
|
||||
|
||||
_, err := this.RPC().NodePriceItemRPC().DeleteNodePriceItem(this.AdminContext(), &pb.DeleteNodePriceItemRequest{NodePriceItemId: params.ItemId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//go:build plus
|
||||
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeFinance)).
|
||||
Data("teaMenu", "clusters").
|
||||
Data("teaSubMenu", "region").
|
||||
Prefix("/finance/fee/items").
|
||||
GetPost("/createTrafficPopup", new(CreateTrafficPopupAction)).
|
||||
GetPost("/updateTrafficPopup", new(UpdateTrafficPopupAction)).
|
||||
GetPost("/createBandwidthPopup", new(CreateBandwidthPopupAction)).
|
||||
GetPost("/updateBandwidthPopup", new(UpdateBandwidthPopupAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//go:build plus
|
||||
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdateBandwidthPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateBandwidthPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdateBandwidthPopupAction) RunGet(params struct {
|
||||
ItemId int64
|
||||
}) {
|
||||
itemResp, err := this.RPC().NodePriceItemRPC().FindEnabledNodePriceItem(this.AdminContext(), &pb.FindEnabledNodePriceItemRequest{NodePriceItemId: params.ItemId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var item = itemResp.NodePriceItem
|
||||
if item == nil {
|
||||
this.NotFound("nodePriceItem", params.ItemId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["item"] = maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"minMB": item.BitsFrom / (1 << 20),
|
||||
"maxMB": item.BitsTo / (1 << 20),
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdateBandwidthPopupAction) RunPost(params struct {
|
||||
ItemId int64
|
||||
Name string
|
||||
MinMB uint32
|
||||
MaxMB uint32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.NodePriceItem_LogUpdateNodePriceItemBandwidth, params.ItemId)
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称")
|
||||
|
||||
if params.MinMB > 0 && params.MaxMB > 0 && params.MinMB > params.MaxMB {
|
||||
params.MinMB, params.MaxMB = params.MaxMB, params.MinMB
|
||||
}
|
||||
|
||||
_, err := this.RPC().NodePriceItemRPC().UpdateNodePriceItem(this.AdminContext(), &pb.UpdateNodePriceItemRequest{
|
||||
NodePriceItemId: params.ItemId,
|
||||
Name: params.Name,
|
||||
BitsFrom: int64(params.MinMB) << 20,
|
||||
BitsTo: int64(params.MaxMB) << 20,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//go:build plus
|
||||
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdateTrafficPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateTrafficPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdateTrafficPopupAction) RunGet(params struct {
|
||||
ItemId int64
|
||||
}) {
|
||||
itemResp, err := this.RPC().NodePriceItemRPC().FindEnabledNodePriceItem(this.AdminContext(), &pb.FindEnabledNodePriceItemRequest{NodePriceItemId: params.ItemId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var item = itemResp.NodePriceItem
|
||||
if item == nil {
|
||||
this.NotFound("nodePriceItem", params.ItemId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["item"] = maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"minGB": item.BitsFrom / (1 << 33),
|
||||
"maxGB": item.BitsTo / (1 << 33),
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdateTrafficPopupAction) RunPost(params struct {
|
||||
ItemId int64
|
||||
Name string
|
||||
MinGB uint32
|
||||
MaxGB uint32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.NodePriceItem_LogUpdateNodePriceItemTraffic, params.ItemId)
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称")
|
||||
|
||||
if params.MinGB > 0 && params.MaxGB > 0 && params.MinGB > params.MaxGB {
|
||||
params.MinGB, params.MaxGB = params.MaxGB, params.MinGB
|
||||
}
|
||||
|
||||
_, err := this.RPC().NodePriceItemRPC().UpdateNodePriceItem(this.AdminContext(), &pb.UpdateNodePriceItemRequest{
|
||||
NodePriceItemId: params.ItemId,
|
||||
Name: params.Name,
|
||||
BitsFrom: int64(params.MinGB) << 33,
|
||||
BitsTo: int64(params.MaxGB) << 33,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user