[边缘节点]可以同时通过关键词搜索集群和节点

This commit is contained in:
GoEdgeLab
2020-12-24 19:15:17 +08:00
parent 34e6f29aae
commit fe1e99bacc
7 changed files with 34 additions and 30 deletions

View File

@@ -167,16 +167,25 @@ func (this *NodeClusterDAO) UpdateCluster(clusterId int64, name string, grantId
}
// 计算所有集群数量
func (this *NodeClusterDAO) CountAllEnabledClusters() (int64, error) {
return this.Query().
State(NodeClusterStateEnabled).
Count()
func (this *NodeClusterDAO) CountAllEnabledClusters(keyword string) (int64, error) {
query := this.Query().
State(NodeClusterStateEnabled)
if len(keyword) > 0 {
query.Where("(name LIKE :keyword OR dnsName like :keyword)").
Param("keyword", "%"+keyword+"%")
}
return query.Count()
}
// 列出单页集群
func (this *NodeClusterDAO) ListEnabledClusters(offset, size int64) (result []*NodeCluster, err error) {
_, err = this.Query().
State(NodeClusterStateEnabled).
func (this *NodeClusterDAO) ListEnabledClusters(keyword string, offset, size int64) (result []*NodeCluster, err error) {
query := this.Query().
State(NodeClusterStateEnabled)
if len(keyword) > 0 {
query.Where("(name LIKE :keyword OR dnsName like :keyword)").
Param("keyword", "%"+keyword+"%")
}
_, err = query.
Offset(offset).
Limit(size).
Slice(&result).

View File

@@ -5,8 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/TeaOSLab/EdgeAPI/internal/rpc"
"github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
_ "github.com/go-sql-driver/mysql"
@@ -557,7 +557,7 @@ func (this *ServerDAO) UpdateServerReverseProxy(serverId int64, config []byte) e
}
// 计算所有可用服务数量
func (this *ServerDAO) CountAllEnabledServersMatch(groupId int64, keyword string, userId int64, clusterId int64, auditingFlag rpc.BoolFlag) (int64, error) {
func (this *ServerDAO) CountAllEnabledServersMatch(groupId int64, keyword string, userId int64, clusterId int64, auditingFlag configutils.BoolState) (int64, error) {
query := this.Query().
State(ServerStateEnabled)
if groupId > 0 {
@@ -574,7 +574,7 @@ func (this *ServerDAO) CountAllEnabledServersMatch(groupId int64, keyword string
if clusterId > 0 {
query.Attr("clusterId", clusterId)
}
if auditingFlag == rpc.BoolFlagTrue {
if auditingFlag == configutils.BoolStateYes {
query.Attr("isAuditing", true)
}
return query.Count()