mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 18:10:25 +08:00
[边缘节点]可以同时通过关键词搜索集群和节点
This commit is contained in:
@@ -167,16 +167,25 @@ func (this *NodeClusterDAO) UpdateCluster(clusterId int64, name string, grantId
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 计算所有集群数量
|
// 计算所有集群数量
|
||||||
func (this *NodeClusterDAO) CountAllEnabledClusters() (int64, error) {
|
func (this *NodeClusterDAO) CountAllEnabledClusters(keyword string) (int64, error) {
|
||||||
return this.Query().
|
query := this.Query().
|
||||||
State(NodeClusterStateEnabled).
|
State(NodeClusterStateEnabled)
|
||||||
Count()
|
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) {
|
func (this *NodeClusterDAO) ListEnabledClusters(keyword string, offset, size int64) (result []*NodeCluster, err error) {
|
||||||
_, err = this.Query().
|
query := this.Query().
|
||||||
State(NodeClusterStateEnabled).
|
State(NodeClusterStateEnabled)
|
||||||
|
if len(keyword) > 0 {
|
||||||
|
query.Where("(name LIKE :keyword OR dnsName like :keyword)").
|
||||||
|
Param("keyword", "%"+keyword+"%")
|
||||||
|
}
|
||||||
|
_, err = query.
|
||||||
Offset(offset).
|
Offset(offset).
|
||||||
Limit(size).
|
Limit(size).
|
||||||
Slice(&result).
|
Slice(&result).
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/rpc"
|
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils"
|
"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/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "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().
|
query := this.Query().
|
||||||
State(ServerStateEnabled)
|
State(ServerStateEnabled)
|
||||||
if groupId > 0 {
|
if groupId > 0 {
|
||||||
@@ -574,7 +574,7 @@ func (this *ServerDAO) CountAllEnabledServersMatch(groupId int64, keyword string
|
|||||||
if clusterId > 0 {
|
if clusterId > 0 {
|
||||||
query.Attr("clusterId", clusterId)
|
query.Attr("clusterId", clusterId)
|
||||||
}
|
}
|
||||||
if auditingFlag == rpc.BoolFlagTrue {
|
if auditingFlag == configutils.BoolStateYes {
|
||||||
query.Attr("isAuditing", true)
|
query.Attr("isAuditing", true)
|
||||||
}
|
}
|
||||||
return query.Count()
|
return query.Count()
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package rpc
|
|
||||||
|
|
||||||
type BoolFlag = int32
|
|
||||||
|
|
||||||
const (
|
|
||||||
BoolFlagNone BoolFlag = 0
|
|
||||||
BoolFlagTrue BoolFlag = 1
|
|
||||||
BoolFlagFalse BoolFlag = 2
|
|
||||||
)
|
|
||||||
@@ -162,14 +162,18 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dnsDomainId := int64(clusterDNS.DnsDomainId)
|
|
||||||
|
dnsDomainId := int64(0)
|
||||||
domainRoutes := []*dnsclients.Route{}
|
domainRoutes := []*dnsclients.Route{}
|
||||||
|
if clusterDNS != nil {
|
||||||
|
dnsDomainId = int64(clusterDNS.DnsDomainId)
|
||||||
if clusterDNS.DnsDomainId > 0 {
|
if clusterDNS.DnsDomainId > 0 {
|
||||||
domainRoutes, err = models.SharedDNSDomainDAO.FindDomainRoutes(dnsDomainId)
|
domainRoutes, err = models.SharedDNSDomainDAO.FindDomainRoutes(dnsDomainId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nodes, err := models.SharedNodeDAO.ListEnabledNodesMatch(req.Offset, req.Size, req.NodeClusterId, configutils.ToBoolState(req.InstallState), configutils.ToBoolState(req.ActiveState), req.Keyword, req.GroupId, req.RegionId)
|
nodes, err := models.SharedNodeDAO.ListEnabledNodesMatch(req.Offset, req.Size, req.NodeClusterId, configutils.ToBoolState(req.InstallState), configutils.ToBoolState(req.ActiveState), req.Keyword, req.GroupId, req.RegionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -285,7 +289,6 @@ func (this *NodeService) FindAllEnabledNodesWithClusterId(ctx context.Context, r
|
|||||||
// TODO 检查权限
|
// TODO 检查权限
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithClusterId(req.NodeClusterId)
|
nodes, err := models.SharedNodeDAO.FindAllEnabledNodesWithClusterId(req.NodeClusterId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ func (this *NodeClusterService) CountAllEnabledNodeClusters(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
count, err := models.SharedNodeClusterDAO.CountAllEnabledClusters()
|
count, err := models.SharedNodeClusterDAO.CountAllEnabledClusters(req.Keyword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ func (this *NodeClusterService) ListEnabledNodeClusters(ctx context.Context, req
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
clusters, err := models.SharedNodeClusterDAO.ListEnabledClusters(req.Offset, req.Size)
|
clusters, err := models.SharedNodeClusterDAO.ListEnabledClusters(req.Keyword, req.Offset, req.Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServerService struct {
|
type ServerService struct {
|
||||||
@@ -454,7 +455,7 @@ func (this *ServerService) CountAllEnabledServersMatch(ctx context.Context, req
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
count, err := models.SharedServerDAO.CountAllEnabledServersMatch(req.GroupId, req.Keyword, req.UserId, req.ClusterId, req.AuditingFlag)
|
count, err := models.SharedServerDAO.CountAllEnabledServersMatch(req.GroupId, req.Keyword, req.UserId, req.ClusterId, types.Int8(req.AuditingFlag))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package services
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/rpc"
|
|
||||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
"time"
|
"time"
|
||||||
@@ -283,7 +283,7 @@ func (this *UserService) ComposeUserDashboard(ctx context.Context, req *pb.Compo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 网站数量
|
// 网站数量
|
||||||
countServers, err := models.SharedServerDAO.CountAllEnabledServersMatch(0, "", req.UserId, 0, rpc.BoolFlagNone)
|
countServers, err := models.SharedServerDAO.CountAllEnabledServersMatch(0, "", req.UserId, 0, configutils.BoolStateAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user