优化代码

This commit is contained in:
刘祥超
2022-08-05 14:38:56 +08:00
parent 4e4d9e33f0
commit aa0c38d66f
7 changed files with 31 additions and 128 deletions

View File

@@ -1,7 +1,6 @@
package certs
import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -37,28 +36,10 @@ func (this *DeleteAction) RunPost(params struct {
this.Fail("此证书正在被某些API节点引用请先修改API节点后再删除")
}
// 是否正在被用户节点使用
if teaconst.IsPlus {
countResp, err = this.RPC().UserNodeRPC().CountAllEnabledUserNodesWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledUserNodesWithSSLCertIdRequest{SslCertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("此证书正在被某些用户节点引用,请先修改相关用户节点后再删除")
}
}
// 是否正在被NS集群使用
if teaconst.IsPlus {
countResp, err = this.RPC().NSClusterRPC().CountAllNSClustersWithSSLCertId(this.AdminContext(), &pb.CountAllNSClustersWithSSLCertIdRequest{SslCertId: params.CertId})
if err != nil {
this.ErrorPage(err)
return
}
if countResp.Count > 0 {
this.Fail("此证书正在被某些DNS集群节点引用请先修改相关DNS集群设置后再删除")
}
err = this.filterDelete(params.CertId)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().SSLCertRPC().DeleteSSLCert(this.AdminContext(), &pb.DeleteSSLCertRequest{SslCertId: params.CertId})

View File

@@ -0,0 +1,8 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
//go:build !plus
package certs
func (this *DeleteAction) filterDelete(certId int64) error {
return nil
}