Files
EdgeAdmin/internal/web/actions/default/servers/components/cache/delete.go

37 lines
1.0 KiB
Go
Raw Normal View History

2020-10-02 17:22:24 +08:00
package cache
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
2023-06-30 18:08:30 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
2020-10-02 17:22:24 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
func (this *DeleteAction) RunPost(params struct {
CachePolicyId int64
}) {
// 检查是否被引用
countResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClustersWithHTTPCachePolicyId(this.AdminContext(), &pb.CountAllEnabledNodeClustersWithHTTPCachePolicyIdRequest{HttpCachePolicyId: params.CachePolicyId})
2020-10-02 17:22:24 +08:00
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("此缓存策略正在被有些集群引用,请修改后再删除。")
2020-10-02 17:22:24 +08:00
}
_, err = this.RPC().HTTPCachePolicyRPC().DeleteHTTPCachePolicy(this.AdminContext(), &pb.DeleteHTTPCachePolicyRequest{HttpCachePolicyId: params.CachePolicyId})
2020-10-02 17:22:24 +08:00
if err != nil {
this.ErrorPage(err)
return
}
2020-11-10 21:37:48 +08:00
// 创建日志
2023-06-30 18:08:30 +08:00
defer this.CreateLogInfo(codes.ServerCachePolicy_LogDeleteCachePolicy, params.CachePolicyId)
2020-11-10 21:37:48 +08:00
2020-10-02 17:22:24 +08:00
this.Success()
}