mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 18:10:25 +08:00
增加计算WAF动作数量API
This commit is contained in:
@@ -153,6 +153,14 @@ func (this *NodeClusterFirewallActionDAO) ComposeFirewallActionConfig(tx *dbs.Tx
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// 计算动作数量
|
||||
func (this *NodeClusterFirewallActionDAO) CountAllEnabledFirewallActions(tx *dbs.Tx, clusterId int64) (int64, error) {
|
||||
return this.Query(tx).
|
||||
State(NodeClusterFirewallActionStateEnabled).
|
||||
Attr("clusterId", clusterId).
|
||||
Count()
|
||||
}
|
||||
|
||||
// 通知更新
|
||||
func (this *NodeClusterFirewallActionDAO) NotifyUpdate(tx *dbs.Tx, actionId int64) error {
|
||||
clusterId, err := this.Query(tx).
|
||||
|
||||
@@ -124,3 +124,18 @@ func (this *NodeClusterFirewallActionService) FindEnabledNodeClusterFirewallActi
|
||||
ParamsJSON: []byte(action.Params),
|
||||
}}, nil
|
||||
}
|
||||
|
||||
// 计算动作数量
|
||||
func (this *NodeClusterFirewallActionService) CountAllEnabledNodeClusterFirewallActions(ctx context.Context, req *pb.CountAllEnabledNodeClusterFirewallActionsRequest) (*pb.RPCCountResponse, error) {
|
||||
_, err := this.ValidateAdmin(ctx, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tx = this.NullTx()
|
||||
count, err := models.SharedNodeClusterFirewallActionDAO.CountAllEnabledFirewallActions(tx, req.NodeClusterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return this.SuccessCount(count)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user