47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
// 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()
|
|
}
|