1.4.5.2
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
//go:build plus
|
||||
|
||||
package planutils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func InitPlan(parentAction *actionutils.ParentAction, planId int64) (*pb.Plan, error) {
|
||||
planResp, err := parentAction.RPC().PlanRPC().FindEnabledPlan(parentAction.AdminContext(), &pb.FindEnabledPlanRequest{PlanId: planId})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var plan = planResp.Plan
|
||||
if plan == nil {
|
||||
return nil, errors.New("not found")
|
||||
}
|
||||
|
||||
parentAction.Data["plan"] = maps.Map{
|
||||
"id": plan.Id,
|
||||
"name": plan.Name,
|
||||
}
|
||||
return plan, nil
|
||||
}
|
||||
Reference in New Issue
Block a user