1.4.5.2
This commit is contained in:
46
EdgeUser/internal/web/actions/default/plans/delete.go
Normal file
46
EdgeUser/internal/web/actions/default/plans/delete.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package plans
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteAction) RunPost(params struct {
|
||||
UserPlanId int64
|
||||
}) {
|
||||
if !this.ValidateFeature(userconfigs.UserFeatureCodePlan, 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否可以操作套餐
|
||||
{
|
||||
priceConfig, err := configloaders.LoadUserPriceConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if priceConfig != nil && !priceConfig.ShowPlansInUserSystem {
|
||||
this.ForbidPage()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
defer this.CreateLogInfo(codes.UserPlan_LogDeleteUserPlan, params.UserPlanId)
|
||||
|
||||
_, err := this.RPC().UserPlanRPC().DeleteUserPlan(this.UserContext(), &pb.DeleteUserPlanRequest{UserPlanId: params.UserPlanId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user