mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-09 20:10:25 +08:00
阶段性提交
This commit is contained in:
@@ -36,3 +36,37 @@ func (this *NodeClusterService) FindAllEnabledClusters(ctx context.Context, req
|
||||
Clusters: result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 查找所有变更的集群
|
||||
func (this *NodeClusterService) FindAllChangedClusters(ctx context.Context, req *pb.FindAllChangedClustersRequest) (*pb.FindAllChangedClustersResponse, error) {
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
clusterIds, err := models.SharedNodeDAO.FindChangedClusterIds()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(clusterIds) == 0 {
|
||||
return &pb.FindAllChangedClustersResponse{
|
||||
Clusters: []*pb.NodeCluster{},
|
||||
}, nil
|
||||
}
|
||||
result := []*pb.NodeCluster{}
|
||||
for _, clusterId := range clusterIds {
|
||||
cluster, err := models.SharedNodeClusterDAO.FindEnabledNodeCluster(clusterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cluster == nil {
|
||||
continue
|
||||
}
|
||||
result = append(result, &pb.NodeCluster{
|
||||
Id: int64(cluster.Id),
|
||||
Name: cluster.Name,
|
||||
CreatedAt: int64(cluster.CreatedAt),
|
||||
})
|
||||
}
|
||||
return &pb.FindAllChangedClustersResponse{Clusters: result}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user