mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-28 08:26:36 +08:00
增加节点同步状态提示和任务列表
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
@@ -144,3 +145,58 @@ func (this *IPListDAO) CheckUserIPList(tx *dbs.Tx, userId int64, listId int64) e
|
||||
}
|
||||
return ErrNotFound
|
||||
}
|
||||
|
||||
// 通知更新
|
||||
func (this *IPListDAO) NotifyUpdate(tx *dbs.Tx, listId int64, taskType NodeTaskType) error {
|
||||
httpFirewallPolicyIds, err := SharedHTTPFirewallPolicyDAO.FindEnabledFirewallPolicyIdsWithIPListId(tx, listId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resultClusterIds := []int64{}
|
||||
for _, policyId := range httpFirewallPolicyIds {
|
||||
// 集群
|
||||
clusterIds, err := SharedNodeClusterDAO.FindAllEnabledNodeClusterIdsWithHTTPFirewallPolicyId(tx, policyId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, clusterId := range clusterIds {
|
||||
if !lists.ContainsInt64(resultClusterIds, clusterId) {
|
||||
resultClusterIds = append(resultClusterIds, clusterId)
|
||||
}
|
||||
}
|
||||
|
||||
// 服务
|
||||
webIds, err := SharedHTTPWebDAO.FindAllWebIdsWithHTTPFirewallPolicyId(tx, policyId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(webIds) > 0 {
|
||||
for _, webId := range webIds {
|
||||
serverId, err := SharedServerDAO.FindEnabledServerIdWithWebId(tx, webId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if serverId > 0 {
|
||||
clusterId, err := SharedServerDAO.FindServerClusterId(tx, serverId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !lists.ContainsInt64(resultClusterIds, clusterId) {
|
||||
resultClusterIds = append(resultClusterIds, clusterId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(resultClusterIds) > 0 {
|
||||
for _, clusterId := range resultClusterIds {
|
||||
err = SharedNodeTaskDAO.CreateClusterTask(tx, clusterId, taskType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user