From 6c4cf4eb3096c1193f952c007b5b43f8c0f486b9 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 2 Feb 2021 16:22:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0WAF=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/models/http_firewall_policy_dao.go | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/internal/db/models/http_firewall_policy_dao.go b/internal/db/models/http_firewall_policy_dao.go index c36b537c..8093f082 100644 --- a/internal/db/models/http_firewall_policy_dao.go +++ b/internal/db/models/http_firewall_policy_dao.go @@ -52,12 +52,16 @@ func (this *HTTPFirewallPolicyDAO) EnableHTTPFirewallPolicy(tx *dbs.Tx, id int64 } // 禁用条目 -func (this *HTTPFirewallPolicyDAO) DisableHTTPFirewallPolicy(tx *dbs.Tx, id int64) error { +func (this *HTTPFirewallPolicyDAO) DisableHTTPFirewallPolicy(tx *dbs.Tx, policyId int64) error { _, err := this.Query(tx). - Pk(id). + Pk(policyId). Set("state", HTTPFirewallPolicyStateDisabled). Update() - return err + if err != nil { + return err + } + + return this.NotifyUpdate(tx, policyId) } // 查找启用中的条目 @@ -127,7 +131,11 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInboundAndOutbound(tx *db op.Outbound = "null" } err := this.Save(tx, op) - return err + if err != nil { + return err + } + + return this.NotifyUpdate(tx, policyId) } // 修改策略的Inbound @@ -143,7 +151,11 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInbound(tx *dbs.Tx, polic op.Inbound = "null" } err := this.Save(tx, op) - return err + if err != nil { + return err + } + + return this.NotifyUpdate(tx, policyId) } // 修改策略 @@ -170,7 +182,11 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicy(tx *dbs.Tx, policyId int op.BlockOptions = blockOptionsJSON } err := this.Save(tx, op) - return err + if err != nil { + return err + } + + return this.NotifyUpdate(tx, policyId) } // 计算所有可用的策略数量 @@ -329,7 +345,7 @@ func (this *HTTPFirewallPolicyDAO) FindEnabledFirewallPolicyIdWithRuleGroupId(tx // 设置某个策略所属的服务ID func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyServerId(tx *dbs.Tx, policyId int64, serverId int64) error { - _, err := this.Query(tx). + _, err := this.Query(tx). Pk(policyId). Set("serverId", serverId). Update()