删除不需要的代码

This commit is contained in:
GoEdgeLab
2022-10-14 09:57:24 +08:00
parent b602491ade
commit a8e30eec96
31 changed files with 66 additions and 1155 deletions

View File

@@ -65,34 +65,7 @@ func (this *IndexAction) RunGet(params struct {
}
// 套餐
var userPlanMap = maps.Map{"id": server.UserPlanId, "dayTo": "", "plan": maps.Map{}}
if server.UserPlanId > 0 {
userPlanResp, err := this.RPC().UserPlanRPC().FindEnabledUserPlan(this.AdminContext(), &pb.FindEnabledUserPlanRequest{UserPlanId: server.UserPlanId})
if err != nil {
this.ErrorPage(err)
return
}
var userPlan = userPlanResp.UserPlan
if userPlan != nil {
planResp, err := this.RPC().PlanRPC().FindEnabledPlan(this.AdminContext(), &pb.FindEnabledPlanRequest{PlanId: userPlan.PlanId})
if err != nil {
this.ErrorPage(err)
return
}
var plan = planResp.Plan
if plan != nil {
userPlanMap = maps.Map{
"id": userPlan.Id,
"dayTo": userPlan.DayTo,
"plan": maps.Map{
"id": plan.Id,
"name": plan.Name,
},
}
}
}
}
this.Data["userPlan"] = userPlanMap
this.initUserPlan(server)
// 集群
clusterId := int64(0)

View File

@@ -0,0 +1,14 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
//go:build !plus
package settings
import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
func (this *IndexAction) initUserPlan(server *pb.Server) {
var userPlanMap = maps.Map{"id": server.UserPlanId, "dayTo": "", "plan": maps.Map{}}
this.Data["userPlan"] = userPlanMap
}

View File

@@ -1,11 +1,10 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
//go:build !plus
package users
import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
@@ -17,33 +16,6 @@ func (this *PlansAction) RunPost(params struct {
UserId int64
ServerId int64
}) {
if !teaconst.IsPlus || params.UserId <= 0 {
this.Data["plans"] = []maps.Map{}
this.Success()
}
// TODO 优化用户套餐查询
userPlansResp, err := this.RPC().UserPlanRPC().FindAllEnabledUserPlansForServer(this.AdminContext(), &pb.FindAllEnabledUserPlansForServerRequest{
UserId: params.UserId,
ServerId: params.ServerId,
})
if err != nil {
this.ErrorPage(err)
return
}
var userPlanMaps = []maps.Map{}
for _, userPlan := range userPlansResp.UserPlans {
if userPlan.Plan == nil {
continue
}
userPlanMaps = append(userPlanMaps, maps.Map{
"id": userPlan.Id,
"name": userPlan.Plan.Name,
"dayTo": userPlan.DayTo,
})
}
this.Data["plans"] = userPlanMaps
this.Data["plans"] = []maps.Map{}
this.Success()
}