搜索节点时加入所在集群状态

This commit is contained in:
GoEdgeLab
2021-07-14 13:59:16 +08:00
parent 9c94c1df5f
commit bfbb7a3485

View File

@@ -223,6 +223,8 @@ func (this *NodeDAO) ListEnabledNodesMatch(tx *dbs.Tx,
// 集群 // 集群
if clusterId > 0 { if clusterId > 0 {
query.Attr("clusterId", clusterId) query.Attr("clusterId", clusterId)
} else {
query.Where("clusterId IN (SELECT id FROM " + SharedNodeClusterDAO.Table + " WHERE state=1)")
} }
// 安装状态 // 安装状态
@@ -330,6 +332,8 @@ func (this *NodeDAO) FindAllNodeIdsMatch(tx *dbs.Tx, clusterId int64, isOn confi
query.State(NodeStateEnabled) query.State(NodeStateEnabled)
if clusterId > 0 { if clusterId > 0 {
query.Attr("clusterId", clusterId) query.Attr("clusterId", clusterId)
} else {
query.Where("clusterId IN (SELECT id FROM " + SharedNodeClusterDAO.Table + " WHERE state=1)")
} }
if isOn == configutils.BoolStateYes { if isOn == configutils.BoolStateYes {
query.Attr("isOn", true) query.Attr("isOn", true)
@@ -387,6 +391,8 @@ func (this *NodeDAO) CountAllEnabledNodesMatch(tx *dbs.Tx,
// 集群 // 集群
if clusterId > 0 { if clusterId > 0 {
query.Attr("clusterId", clusterId) query.Attr("clusterId", clusterId)
} else {
query.Where("clusterId IN (SELECT id FROM " + SharedNodeClusterDAO.Table + " WHERE state=1)")
} }
// 安装状态 // 安装状态