mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	优化API命名
This commit is contained in:
		@@ -4,6 +4,7 @@ package nameservers
 | 
			
		||||
type NSNode struct {
 | 
			
		||||
	Id        uint32 `field:"id"`        // ID
 | 
			
		||||
	ClusterId uint32 `field:"clusterId"` // 集群ID
 | 
			
		||||
	Name      string `field:"name"`      // 节点名称
 | 
			
		||||
	IsOn      uint8  `field:"isOn"`      // 是否启用
 | 
			
		||||
	Status    string `field:"status"`    // 运行状态
 | 
			
		||||
	UniqueId  string `field:"uniqueId"`  // 节点ID
 | 
			
		||||
@@ -14,6 +15,7 @@ type NSNode struct {
 | 
			
		||||
type NSNodeOperator struct {
 | 
			
		||||
	Id        interface{} // ID
 | 
			
		||||
	ClusterId interface{} // 集群ID
 | 
			
		||||
	Name      interface{} // 节点名称
 | 
			
		||||
	IsOn      interface{} // 是否启用
 | 
			
		||||
	Status    interface{} // 运行状态
 | 
			
		||||
	UniqueId  interface{} // 节点ID
 | 
			
		||||
 
 | 
			
		||||
@@ -33,14 +33,14 @@ func (this *NodeService) CreateNode(ctx context.Context, req *pb.CreateNodeReque
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	nodeId, err := models.SharedNodeDAO.CreateNode(tx, adminId, req.Name, req.NodeClusterId, req.GroupId, req.RegionId)
 | 
			
		||||
	nodeId, err := models.SharedNodeDAO.CreateNode(tx, adminId, req.Name, req.NodeClusterId, req.NodeGroupId, req.NodeRegionId)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 增加认证相关
 | 
			
		||||
	if req.Login != nil {
 | 
			
		||||
		_, err = models.SharedNodeLoginDAO.CreateNodeLogin(tx, nodeId, req.Login.Name, req.Login.Type, req.Login.Params)
 | 
			
		||||
	if req.NodeLogin != nil {
 | 
			
		||||
		_, err = models.SharedNodeLoginDAO.CreateNodeLogin(tx, nodeId, req.NodeLogin.Name, req.NodeLogin.Type, req.NodeLogin.Params)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
@@ -133,7 +133,7 @@ func (this *NodeService) CountAllEnabledNodesMatch(ctx context.Context, req *pb.
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	count, err := models.SharedNodeDAO.CountAllEnabledNodesMatch(tx, req.NodeClusterId, configutils.ToBoolState(req.InstallState), configutils.ToBoolState(req.ActiveState), req.Keyword, req.GroupId, req.RegionId)
 | 
			
		||||
	count, err := models.SharedNodeDAO.CountAllEnabledNodesMatch(tx, req.NodeClusterId, configutils.ToBoolState(req.InstallState), configutils.ToBoolState(req.ActiveState), req.Keyword, req.NodeGroupId, req.NodeRegionId)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -166,7 +166,7 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nodes, err := models.SharedNodeDAO.ListEnabledNodesMatch(tx, 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(tx, req.Offset, req.Size, req.NodeClusterId, configutils.ToBoolState(req.InstallState), configutils.ToBoolState(req.ActiveState), req.Keyword, req.NodeGroupId, req.NodeRegionId)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -269,8 +269,8 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllEnabledNodesWithClusterId 查找一个集群下的所有节点
 | 
			
		||||
func (this *NodeService) FindAllEnabledNodesWithClusterId(ctx context.Context, req *pb.FindAllEnabledNodesWithClusterIdRequest) (*pb.FindAllEnabledNodesWithClusterIdResponse, error) {
 | 
			
		||||
// FindAllEnabledNodesWithNodeClusterId 查找一个集群下的所有节点
 | 
			
		||||
func (this *NodeService) FindAllEnabledNodesWithNodeClusterId(ctx context.Context, req *pb.FindAllEnabledNodesWithNodeClusterIdRequest) (*pb.FindAllEnabledNodesWithNodeClusterIdResponse, error) {
 | 
			
		||||
	_, userId, err := this.ValidateAdminAndUser(ctx, 0, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@@ -306,7 +306,7 @@ func (this *NodeService) FindAllEnabledNodesWithClusterId(ctx context.Context, r
 | 
			
		||||
			IsOn:                node.IsOn == 1,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindAllEnabledNodesWithClusterIdResponse{Nodes: result}, nil
 | 
			
		||||
	return &pb.FindAllEnabledNodesWithNodeClusterIdResponse{Nodes: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeleteNode 删除节点
 | 
			
		||||
@@ -363,24 +363,24 @@ func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeReque
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = models.SharedNodeDAO.UpdateNode(tx, req.NodeId, req.Name, req.NodeClusterId, req.GroupId, req.RegionId, req.MaxCPU, req.IsOn, maxCacheDiskCapacityJSON, maxCacheMemoryCapacityJSON)
 | 
			
		||||
	err = models.SharedNodeDAO.UpdateNode(tx, req.NodeId, req.Name, req.NodeClusterId, req.NodeGroupId, req.NodeRegionId, req.MaxCPU, req.IsOn, maxCacheDiskCapacityJSON, maxCacheMemoryCapacityJSON)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if req.Login == nil {
 | 
			
		||||
	if req.NodeLogin == nil {
 | 
			
		||||
		err = models.SharedNodeLoginDAO.DisableNodeLogins(tx, req.NodeId)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if req.Login.Id > 0 {
 | 
			
		||||
			err = models.SharedNodeLoginDAO.UpdateNodeLogin(tx, req.Login.Id, req.Login.Name, req.Login.Type, req.Login.Params)
 | 
			
		||||
		if req.NodeLogin.Id > 0 {
 | 
			
		||||
			err = models.SharedNodeLoginDAO.UpdateNodeLogin(tx, req.NodeLogin.Id, req.NodeLogin.Name, req.NodeLogin.Type, req.NodeLogin.Params)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			_, err = models.SharedNodeLoginDAO.CreateNodeLogin(tx, req.NodeId, req.Login.Name, req.Login.Type, req.Login.Params)
 | 
			
		||||
			_, err = models.SharedNodeLoginDAO.CreateNodeLogin(tx, req.NodeId, req.NodeLogin.Name, req.NodeLogin.Type, req.NodeLogin.Params)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
@@ -721,8 +721,8 @@ func (this *NodeService) UpdateNodeConnectedAPINodes(ctx context.Context, req *p
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountAllEnabledNodesWithGrantId 计算使用某个认证的节点数量
 | 
			
		||||
func (this *NodeService) CountAllEnabledNodesWithGrantId(ctx context.Context, req *pb.CountAllEnabledNodesWithGrantIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
// CountAllEnabledNodesWithNodeGrantId 计算使用某个认证的节点数量
 | 
			
		||||
func (this *NodeService) CountAllEnabledNodesWithNodeGrantId(ctx context.Context, req *pb.CountAllEnabledNodesWithNodeGrantIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -738,8 +738,8 @@ func (this *NodeService) CountAllEnabledNodesWithGrantId(ctx context.Context, re
 | 
			
		||||
	return this.SuccessCount(count)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllEnabledNodesWithGrantId 查找使用某个认证的所有节点
 | 
			
		||||
func (this *NodeService) FindAllEnabledNodesWithGrantId(ctx context.Context, req *pb.FindAllEnabledNodesWithGrantIdRequest) (*pb.FindAllEnabledNodesWithGrantIdResponse, error) {
 | 
			
		||||
// FindAllEnabledNodesWithNodeGrantId 查找使用某个认证的所有节点
 | 
			
		||||
func (this *NodeService) FindAllEnabledNodesWithNodeGrantId(ctx context.Context, req *pb.FindAllEnabledNodesWithNodeGrantIdRequest) (*pb.FindAllEnabledNodesWithNodeGrantIdResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -775,11 +775,11 @@ func (this *NodeService) FindAllEnabledNodesWithGrantId(ctx context.Context, req
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &pb.FindAllEnabledNodesWithGrantIdResponse{Nodes: result}, nil
 | 
			
		||||
	return &pb.FindAllEnabledNodesWithNodeGrantIdResponse{Nodes: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountAllNotInstalledNodesWithClusterId 计算没有安装的节点数量
 | 
			
		||||
func (this *NodeService) CountAllNotInstalledNodesWithClusterId(ctx context.Context, req *pb.CountAllNotInstalledNodesWithClusterIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
// CountAllNotInstalledNodesWithNodeClusterId 计算没有安装的节点数量
 | 
			
		||||
func (this *NodeService) CountAllNotInstalledNodesWithNodeClusterId(ctx context.Context, req *pb.CountAllNotInstalledNodesWithNodeClusterIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
	_, err := this.ValidateAdmin(ctx, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@@ -792,8 +792,8 @@ func (this *NodeService) CountAllNotInstalledNodesWithClusterId(ctx context.Cont
 | 
			
		||||
	return this.SuccessCount(count)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllNotInstalledNodesWithClusterId 列出所有未安装的节点
 | 
			
		||||
func (this *NodeService) FindAllNotInstalledNodesWithClusterId(ctx context.Context, req *pb.FindAllNotInstalledNodesWithClusterIdRequest) (*pb.FindAllNotInstalledNodesWithClusterIdResponse, error) {
 | 
			
		||||
// FindAllNotInstalledNodesWithNodeClusterId 列出所有未安装的节点
 | 
			
		||||
func (this *NodeService) FindAllNotInstalledNodesWithNodeClusterId(ctx context.Context, req *pb.FindAllNotInstalledNodesWithNodeClusterIdRequest) (*pb.FindAllNotInstalledNodesWithNodeClusterIdResponse, error) {
 | 
			
		||||
	_, err := this.ValidateAdmin(ctx, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@@ -871,11 +871,11 @@ func (this *NodeService) FindAllNotInstalledNodesWithClusterId(ctx context.Conte
 | 
			
		||||
			InstallStatus: pbInstallStatus,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindAllNotInstalledNodesWithClusterIdResponse{Nodes: result}, nil
 | 
			
		||||
	return &pb.FindAllNotInstalledNodesWithNodeClusterIdResponse{Nodes: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountAllUpgradeNodesWithClusterId 计算需要升级的节点数量
 | 
			
		||||
func (this *NodeService) CountAllUpgradeNodesWithClusterId(ctx context.Context, req *pb.CountAllUpgradeNodesWithClusterIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
// CountAllUpgradeNodesWithNodeClusterId 计算需要升级的节点数量
 | 
			
		||||
func (this *NodeService) CountAllUpgradeNodesWithNodeClusterId(ctx context.Context, req *pb.CountAllUpgradeNodesWithNodeClusterIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, err := this.ValidateAdmin(ctx, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -897,8 +897,8 @@ func (this *NodeService) CountAllUpgradeNodesWithClusterId(ctx context.Context,
 | 
			
		||||
	return this.SuccessCount(total)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllUpgradeNodesWithClusterId 列出所有需要升级的节点
 | 
			
		||||
func (this *NodeService) FindAllUpgradeNodesWithClusterId(ctx context.Context, req *pb.FindAllUpgradeNodesWithClusterIdRequest) (*pb.FindAllUpgradeNodesWithClusterIdResponse, error) {
 | 
			
		||||
// FindAllUpgradeNodesWithNodeClusterId 列出所有需要升级的节点
 | 
			
		||||
func (this *NodeService) FindAllUpgradeNodesWithNodeClusterId(ctx context.Context, req *pb.FindAllUpgradeNodesWithNodeClusterIdRequest) (*pb.FindAllUpgradeNodesWithNodeClusterIdResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, err := this.ValidateAdmin(ctx, 0)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -909,7 +909,7 @@ func (this *NodeService) FindAllUpgradeNodesWithClusterId(ctx context.Context, r
 | 
			
		||||
 | 
			
		||||
	// 获取当前能升级到的最新版本
 | 
			
		||||
	deployFiles := installers.SharedDeployManager.LoadFiles()
 | 
			
		||||
	result := []*pb.FindAllUpgradeNodesWithClusterIdResponse_NodeUpgrade{}
 | 
			
		||||
	result := []*pb.FindAllUpgradeNodesWithNodeClusterIdResponse_NodeUpgrade{}
 | 
			
		||||
	for _, deployFile := range deployFiles {
 | 
			
		||||
		nodes, err := models.SharedNodeDAO.FindAllLowerVersionNodesWithClusterId(tx, req.NodeClusterId, deployFile.OS, deployFile.Arch, deployFile.Version)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
@@ -989,7 +989,7 @@ func (this *NodeService) FindAllUpgradeNodesWithClusterId(ctx context.Context, r
 | 
			
		||||
				InstallStatus: pbInstallStatus,
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			result = append(result, &pb.FindAllUpgradeNodesWithClusterIdResponse_NodeUpgrade{
 | 
			
		||||
			result = append(result, &pb.FindAllUpgradeNodesWithNodeClusterIdResponse_NodeUpgrade{
 | 
			
		||||
				Os:         deployFile.OS,
 | 
			
		||||
				Arch:       deployFile.Arch,
 | 
			
		||||
				OldVersion: status.BuildVersion,
 | 
			
		||||
@@ -998,7 +998,7 @@ func (this *NodeService) FindAllUpgradeNodesWithClusterId(ctx context.Context, r
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindAllUpgradeNodesWithClusterIdResponse{
 | 
			
		||||
	return &pb.FindAllUpgradeNodesWithNodeClusterIdResponse{
 | 
			
		||||
		Nodes: result,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1042,19 +1042,19 @@ func (this *NodeService) UpdateNodeLogin(ctx context.Context, req *pb.UpdateNode
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	if req.Login.Id <= 0 {
 | 
			
		||||
		_, err := models.SharedNodeLoginDAO.CreateNodeLogin(tx, req.NodeId, req.Login.Name, req.Login.Type, req.Login.Params)
 | 
			
		||||
	if req.NodeLogin.Id <= 0 {
 | 
			
		||||
		_, err := models.SharedNodeLoginDAO.CreateNodeLogin(tx, req.NodeId, req.NodeLogin.Name, req.NodeLogin.Type, req.NodeLogin.Params)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = models.SharedNodeLoginDAO.UpdateNodeLogin(tx, req.Login.Id, req.Login.Name, req.Login.Type, req.Login.Params)
 | 
			
		||||
	err = models.SharedNodeLoginDAO.UpdateNodeLogin(tx, req.NodeLogin.Id, req.NodeLogin.Name, req.NodeLogin.Type, req.NodeLogin.Params)
 | 
			
		||||
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 计算某个节点分组内的节点数量
 | 
			
		||||
// CountAllEnabledNodesWithNodeGroupId 计算某个节点分组内的节点数量
 | 
			
		||||
func (this *NodeService) CountAllEnabledNodesWithNodeGroupId(ctx context.Context, req *pb.CountAllEnabledNodesWithNodeGroupIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
@@ -1071,8 +1071,8 @@ func (this *NodeService) CountAllEnabledNodesWithNodeGroupId(ctx context.Context
 | 
			
		||||
	return this.SuccessCount(count)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllEnabledNodesDNSWithClusterId 取得某个集群下的所有节点
 | 
			
		||||
func (this *NodeService) FindAllEnabledNodesDNSWithClusterId(ctx context.Context, req *pb.FindAllEnabledNodesDNSWithClusterIdRequest) (*pb.FindAllEnabledNodesDNSWithClusterIdResponse, error) {
 | 
			
		||||
// FindAllEnabledNodesDNSWithNodeClusterId 取得某个集群下的所有节点
 | 
			
		||||
func (this *NodeService) FindAllEnabledNodesDNSWithNodeClusterId(ctx context.Context, req *pb.FindAllEnabledNodesDNSWithNodeClusterIdRequest) (*pb.FindAllEnabledNodesDNSWithNodeClusterIdResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -1140,7 +1140,7 @@ func (this *NodeService) FindAllEnabledNodesDNSWithClusterId(ctx context.Context
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindAllEnabledNodesDNSWithClusterIdResponse{Nodes: result}, nil
 | 
			
		||||
	return &pb.FindAllEnabledNodesDNSWithNodeClusterIdResponse{Nodes: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindEnabledNodeDNS 查找单个节点的域名解析信息
 | 
			
		||||
 
 | 
			
		||||
@@ -331,8 +331,8 @@ func (this *NodeClusterService) ExecuteNodeClusterHealthCheck(ctx context.Contex
 | 
			
		||||
	return &pb.ExecuteNodeClusterHealthCheckResponse{Results: pbResults}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountAllEnabledNodeClustersWithGrantId 计算使用某个认证的集群数量
 | 
			
		||||
func (this *NodeClusterService) CountAllEnabledNodeClustersWithGrantId(ctx context.Context, req *pb.CountAllEnabledNodeClustersWithGrantIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
// CountAllEnabledNodeClustersWithNodeGrantId 计算使用某个认证的集群数量
 | 
			
		||||
func (this *NodeClusterService) CountAllEnabledNodeClustersWithNodeGrantId(ctx context.Context, req *pb.CountAllEnabledNodeClustersWithNodeGrantIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -348,8 +348,8 @@ func (this *NodeClusterService) CountAllEnabledNodeClustersWithGrantId(ctx conte
 | 
			
		||||
	return this.SuccessCount(count)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllEnabledNodeClustersWithGrantId 查找使用某个认证的所有集群
 | 
			
		||||
func (this *NodeClusterService) FindAllEnabledNodeClustersWithGrantId(ctx context.Context, req *pb.FindAllEnabledNodeClustersWithGrantIdRequest) (*pb.FindAllEnabledNodeClustersWithGrantIdResponse, error) {
 | 
			
		||||
// FindAllEnabledNodeClustersWithNodeGrantId 查找使用某个认证的所有集群
 | 
			
		||||
func (this *NodeClusterService) FindAllEnabledNodeClustersWithNodeGrantId(ctx context.Context, req *pb.FindAllEnabledNodeClustersWithNodeGrantIdRequest) (*pb.FindAllEnabledNodeClustersWithNodeGrantIdResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -373,7 +373,7 @@ func (this *NodeClusterService) FindAllEnabledNodeClustersWithGrantId(ctx contex
 | 
			
		||||
			Secret:    cluster.Secret,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindAllEnabledNodeClustersWithGrantIdResponse{NodeClusters: result}, nil
 | 
			
		||||
	return &pb.FindAllEnabledNodeClustersWithNodeGrantIdResponse{NodeClusters: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindEnabledNodeClusterDNS 查找集群的DNS配置
 | 
			
		||||
 
 | 
			
		||||
@@ -7,12 +7,12 @@ import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 节点分组相关服务
 | 
			
		||||
// NodeGroupService 节点分组相关服务
 | 
			
		||||
type NodeGroupService struct {
 | 
			
		||||
	BaseService
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 创建分组
 | 
			
		||||
// CreateNodeGroup 创建分组
 | 
			
		||||
func (this *NodeGroupService) CreateNodeGroup(ctx context.Context, req *pb.CreateNodeGroupRequest) (*pb.CreateNodeGroupResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
@@ -29,7 +29,7 @@ func (this *NodeGroupService) CreateNodeGroup(ctx context.Context, req *pb.Creat
 | 
			
		||||
	return &pb.CreateNodeGroupResponse{GroupId: groupId}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 修改分组
 | 
			
		||||
// UpdateNodeGroup 修改分组
 | 
			
		||||
func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.UpdateNodeGroupRequest) (*pb.RPCSuccess, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
@@ -47,7 +47,7 @@ func (this *NodeGroupService) UpdateNodeGroup(ctx context.Context, req *pb.Updat
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 删除分组
 | 
			
		||||
// DeleteNodeGroup 删除分组
 | 
			
		||||
func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.DeleteNodeGroupRequest) (*pb.RPCSuccess, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
@@ -65,8 +65,8 @@ func (this *NodeGroupService) DeleteNodeGroup(ctx context.Context, req *pb.Delet
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查询所有分组
 | 
			
		||||
func (this *NodeGroupService) FindAllEnabledNodeGroupsWithClusterId(ctx context.Context, req *pb.FindAllEnabledNodeGroupsWithClusterIdRequest) (*pb.FindAllEnabledNodeGroupsWithClusterIdResponse, error) {
 | 
			
		||||
// FindAllEnabledNodeGroupsWithNodeClusterId 查询所有分组
 | 
			
		||||
func (this *NodeGroupService) FindAllEnabledNodeGroupsWithNodeClusterId(ctx context.Context, req *pb.FindAllEnabledNodeGroupsWithNodeClusterIdRequest) (*pb.FindAllEnabledNodeGroupsWithNodeClusterIdResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -86,10 +86,10 @@ func (this *NodeGroupService) FindAllEnabledNodeGroupsWithClusterId(ctx context.
 | 
			
		||||
			Name: group.Name,
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
	return &pb.FindAllEnabledNodeGroupsWithClusterIdResponse{Groups: result}, nil
 | 
			
		||||
	return &pb.FindAllEnabledNodeGroupsWithNodeClusterIdResponse{Groups: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 修改分组排序
 | 
			
		||||
// UpdateNodeGroupOrders 修改分组排序
 | 
			
		||||
func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb.UpdateNodeGroupOrdersRequest) (*pb.RPCSuccess, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
@@ -106,7 +106,7 @@ func (this *NodeGroupService) UpdateNodeGroupOrders(ctx context.Context, req *pb
 | 
			
		||||
	return this.Success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查找单个分组信息
 | 
			
		||||
// FindEnabledNodeGroup 查找单个分组信息
 | 
			
		||||
func (this *NodeGroupService) FindEnabledNodeGroup(ctx context.Context, req *pb.FindEnabledNodeGroupRequest) (*pb.FindEnabledNodeGroupResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
 
 | 
			
		||||
@@ -82,7 +82,7 @@ func (this *ServerService) CreateServer(ctx context.Context, req *pb.CreateServe
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	serverId, err := models.SharedServerDAO.CreateServer(tx, req.AdminId, req.UserId, req.Type, req.Name, req.Description, serverNamesJSON, isAuditing, auditingServerNamesJSON, string(req.HttpJSON), string(req.HttpsJSON), string(req.TcpJSON), string(req.TlsJSON), string(req.UnixJSON), string(req.UdpJSON), req.WebId, req.ReverseProxyJSON, req.NodeClusterId, string(req.IncludeNodesJSON), string(req.ExcludeNodesJSON), req.GroupIds)
 | 
			
		||||
	serverId, err := models.SharedServerDAO.CreateServer(tx, req.AdminId, req.UserId, req.Type, req.Name, req.Description, serverNamesJSON, isAuditing, auditingServerNamesJSON, string(req.HttpJSON), string(req.HttpsJSON), string(req.TcpJSON), string(req.TlsJSON), string(req.UnixJSON), string(req.UdpJSON), req.WebId, req.ReverseProxyJSON, req.NodeClusterId, string(req.IncludeNodesJSON), string(req.ExcludeNodesJSON), req.ServerGroupIds)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -113,7 +113,7 @@ func (this *ServerService) UpdateServerBasic(ctx context.Context, req *pb.Update
 | 
			
		||||
		return nil, errors.New("can not find server")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = models.SharedServerDAO.UpdateServerBasic(tx, req.ServerId, req.Name, req.Description, req.NodeClusterId, req.IsOn, req.GroupIds)
 | 
			
		||||
	err = models.SharedServerDAO.UpdateServerBasic(tx, req.ServerId, req.Name, req.Description, req.NodeClusterId, req.IsOn, req.ServerGroupIds)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -479,7 +479,7 @@ func (this *ServerService) CountAllEnabledServersMatch(ctx context.Context, req
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	count, err := models.SharedServerDAO.CountAllEnabledServersMatch(tx, req.GroupId, req.Keyword, req.UserId, req.ClusterId, types.Int8(req.AuditingFlag), req.ProtocolFamily)
 | 
			
		||||
	count, err := models.SharedServerDAO.CountAllEnabledServersMatch(tx, req.ServerGroupId, req.Keyword, req.UserId, req.NodeClusterId, types.Int8(req.AuditingFlag), req.ProtocolFamily)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -497,7 +497,7 @@ func (this *ServerService) ListEnabledServersMatch(ctx context.Context, req *pb.
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	servers, err := models.SharedServerDAO.ListEnabledServersMatch(tx, req.Offset, req.Size, req.GroupId, req.Keyword, req.UserId, req.ClusterId, req.AuditingFlag, req.ProtocolFamily)
 | 
			
		||||
	servers, err := models.SharedServerDAO.ListEnabledServersMatch(tx, req.Offset, req.Size, req.ServerGroupId, req.Keyword, req.UserId, req.NodeClusterId, req.AuditingFlag, req.ProtocolFamily)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -954,8 +954,8 @@ func (this *ServerService) CountAllEnabledServersWithNodeClusterId(ctx context.C
 | 
			
		||||
	return this.SuccessCount(count)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountAllEnabledServersWithGroupId 计算使用某个分组的服务数量
 | 
			
		||||
func (this *ServerService) CountAllEnabledServersWithGroupId(ctx context.Context, req *pb.CountAllEnabledServersWithGroupIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
// CountAllEnabledServersWithServerGroupId 计算使用某个分组的服务数量
 | 
			
		||||
func (this *ServerService) CountAllEnabledServersWithServerGroupId(ctx context.Context, req *pb.CountAllEnabledServersWithServerGroupIdRequest) (*pb.RPCCountResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -964,7 +964,7 @@ func (this *ServerService) CountAllEnabledServersWithGroupId(ctx context.Context
 | 
			
		||||
 | 
			
		||||
	tx := this.NullTx()
 | 
			
		||||
 | 
			
		||||
	count, err := models.SharedServerDAO.CountAllEnabledServersWithGroupId(tx, req.GroupId)
 | 
			
		||||
	count, err := models.SharedServerDAO.CountAllEnabledServersWithGroupId(tx, req.ServerGroupId)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -995,8 +995,8 @@ func (this *ServerService) NotifyServersChange(ctx context.Context, _ *pb.Notify
 | 
			
		||||
	return &pb.NotifyServersChangeResponse{}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindAllEnabledServersDNSWithClusterId 取得某个集群下的所有服务相关的DNS
 | 
			
		||||
func (this *ServerService) FindAllEnabledServersDNSWithClusterId(ctx context.Context, req *pb.FindAllEnabledServersDNSWithClusterIdRequest) (*pb.FindAllEnabledServersDNSWithClusterIdResponse, error) {
 | 
			
		||||
// FindAllEnabledServersDNSWithNodeClusterId 取得某个集群下的所有服务相关的DNS
 | 
			
		||||
func (this *ServerService) FindAllEnabledServersDNSWithNodeClusterId(ctx context.Context, req *pb.FindAllEnabledServersDNSWithNodeClusterIdRequest) (*pb.FindAllEnabledServersDNSWithNodeClusterIdResponse, error) {
 | 
			
		||||
	// 校验请求
 | 
			
		||||
	_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@@ -1028,7 +1028,7 @@ func (this *ServerService) FindAllEnabledServersDNSWithClusterId(ctx context.Con
 | 
			
		||||
		})
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &pb.FindAllEnabledServersDNSWithClusterIdResponse{Servers: result}, nil
 | 
			
		||||
	return &pb.FindAllEnabledServersDNSWithNodeClusterIdResponse{Servers: result}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindEnabledServerDNS 查找单个服务的DNS信息
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user