浏览代码

修改通用集合查询接口

CrazyIter 5 年之前
父节点
当前提交
121d8adc6e

+ 4 - 4
TEAMModelOS.SDK/Module/AzureCosmosDB/Implements/AzureCosmosDBRepository.cs

@@ -680,11 +680,11 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
             };
         }
 
-        public async Task<IQueryable<dynamic>> FindByDict(string CollectionName, string PartitionKey, Dictionary<string, object> dict)
+        public  IQueryable<dynamic> FindByDict(string CollectionName,  Dictionary<string, object> dict)
         {
-            if (DocumentCollectionDict.TryGetValue(CollectionName, out _))
+            if (DocumentCollectionDict.TryGetValue(CollectionName, out DocumentCollection collection))
             {
-                await InitializeCollection(CollectionName, PartitionKey);
+              //  collection = await InitializeCollection(CollectionName, "");
                 StringBuilder sql = new StringBuilder("select * from " + CollectionName + " c where 1=1 ");
                 if (dict != null)
                 {
@@ -694,7 +694,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
                     }
                 }
                 FeedOptions queryOptions;
-                if (!string.IsNullOrEmpty(PartitionKey))
+                if (collection.PartitionKey.Paths.Count > 0)
                 {
                     queryOptions = new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true };
                 }

+ 1 - 1
TEAMModelOS.SDK/Module/AzureCosmosDB/Interfaces/IAzureCosmosDBRepository.cs

@@ -24,6 +24,6 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces
         Task<List<T>> SaveAll<T>(List<T> enyites);
         Task<List<T>> UpdateAll<T>(Dictionary<string, object> dict, Dictionary<string, object> updateFilters, List<string> deleteKeys = null);
         Task<List<T>> DeleteAll<T>(Dictionary<string, object> dict);
-        Task<IQueryable<dynamic>> FindByDict(string CollectionName, string PartitionKey, Dictionary<string, object> dict); 
+        IQueryable<dynamic> FindByDict(string CollectionName, Dictionary<string, object> dict); 
     }
 }

+ 2 - 2
TEAMModelOS/Controllers/Core/CommonController.cs

@@ -122,10 +122,10 @@ namespace TEAMModelOS.Controllers.Syllabus
         }
 
         [HttpPost("FindCollection")]
-        public async Task<BaseJosnRPCResponse> FindCollection(JosnRPCRequest<CommonQuery> request)
+        public  BaseJosnRPCResponse FindCollection(JosnRPCRequest<CommonQuery> request)
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            IQueryable<dynamic>  data = await azureCosmosDBRepository.FindByDict(request.@params.collectionName, request.@params.partitionKey , request.@params.queryDict);
+            IQueryable<dynamic>  data =   azureCosmosDBRepository.FindByDict(request.@params.collectionName,request.@params.queryDict);
             return builder.Data(data).build();
         }
     }

+ 0 - 1
TEAMModelOS/Models/CommonQuery.cs

@@ -8,7 +8,6 @@ namespace TEAMModelOS.Models
     public class CommonQuery
     {
         public string collectionName { get; set; }
-        public string partitionKey { get; set; }
         public Dictionary<string ,object> queryDict { get; set; }
     }
 }