Jelajahi Sumber

Merge branch 'develop3.0' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0

CrazyIter 5 tahun lalu
induk
melakukan
12e35c8025

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

@@ -727,14 +727,86 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
         {
             if (DocumentCollectionDict.TryGetValue(CollectionName, out DocumentCollection collection))
             {
-              //  collection = await InitializeCollection(CollectionName, "");
-                StringBuilder sql = new StringBuilder("select * from " + CollectionName + " c where 1=1 ");
+                //  collection = await InitializeCollection(CollectionName, "");
+                /*    StringBuilder sql = new StringBuilder("select * from " + CollectionName + " c where 1=1 ");
+                    if (dict != null)
+                    {
+                        foreach (string key in dict.Keys)
+                        {
+                            sql.Append(GenSql(dict[key], key));
+                        }
+                    }*/
+                StringBuilder sql = new StringBuilder("select value(c) from c");
                 if (dict != null)
                 {
-                    foreach (string key in dict.Keys)
+
+                    string Join = " join ";
+                    string instring = "in ";
+                    Dictionary<string, string> keyValues = new Dictionary<string, string>();
+                    StringBuilder ps = new StringBuilder();
+                    int heada = 0;
+                    string[] sqlHead = new string[] { "A", "B", "C", "D", "E", "F" };
+                    int kslength = 0;
+                    foreach (KeyValuePair<string, object> item in dict)
                     {
-                        sql.Append(GenSql(dict[key], key));
+
+                        int index = 0;
+                        string[] ks = item.Key.Split("[*]");
+
+                        if (ks.Length > 1)
+                        {
+                            kslength += ks.Length;
+                            if (kslength < (7 + heada))
+                            {
+                                StringBuilder sqlitem = new StringBuilder();
+                                for (int i = 0; i < ks.Length - 1; i++)
+                                {
+
+                                    //Console.WriteLine(ks[i]);
+                                    if (i == 0)
+                                    {
+                                        sqlitem.Append(Join);
+                                        string a = sqlHead[heada] + index;
+                                        sqlitem.Append(a + " ");
+                                        //keyValues.Add(ks[i], a);
+                                        keyValues[ks[i]] = a;
+                                        sqlitem.Append(instring);
+                                        sqlitem.Append("c.");
+                                        sqlitem.Append(ks[i]);
+                                    }
+                                    else
+                                    {
+                                        sqlitem.Append(Join + " ");
+                                        string a = sqlHead[heada] + index;
+                                        sqlitem.Append(a + " ");
+                                        //keyValues.Add(ks[i], a);
+                                        keyValues[ks[i]] = a;
+                                        sqlitem.Append(instring);
+                                        sqlitem.Append(keyValues[ks[i - 1]]);
+                                        sqlitem.Append(ks[i]);
+                                    }
+                                    index += 1;
+                                }
+                                // Console.WriteLine(sqlitem);
+                                sql.Append(sqlitem);
+                                string s;
+                                s = "and " + sqlHead[heada] + (ks.Length - 2) + ks[index] + " = " + "\"" + item.Value.ToString() + "\"";
+                                ps.Append(s);
+                            }
+                            else
+                            {
+                                 throw new BizException("数组总共深度不能超过5层",ResponseCode.PARAMS_ERROR);
+                                
+                            }
+
+                        }
+                        else
+                        {
+                            ps.Append(GenSql(dict[item.Key], item.Key));
+                        }
+                        heada += 1;
                     }
+                    sql.Append(" where 1=1 ").Append(ps);
                 }
                 FeedOptions queryOptions;
                 if (collection.PartitionKey.Paths.Count > 0)

+ 16 - 1
TEAMModelOS/Controllers/Syllabus/KnowledgeController.cs

@@ -9,7 +9,6 @@ using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.JsonHelper;
-using TEAMModelOS.SDK.Helper.Security.ShaHash;
 using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
 using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
 using TEAMModelOS.Service.Models.Core;
@@ -405,5 +404,21 @@ namespace TEAMModelOS.Controllers.Syllabus
                 builder.Error(false, ResponseCode.NOT_FOUND, "未找到对应知识块");
             }
         }
+
+
+      
+        [HttpPost("Test")]
+        public async Task<BaseJosnRPCResponse> Test(JosnRPCRequest<Dictionary<string, object>> request)
+        {
+            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
+            if (request.@params != null)
+            {
+                IQueryable<dynamic> data = _cosmos.FindByDict("SchoolBlock", request.@params);
+                return builder.Data(data).build();
+
+            }
+            else return builder.Error(false, ResponseCode.PARAMS_ERROR, "参数为空").build();
+        }
+
     }
 }

+ 2 - 0
TEAMModelOS/Controllers/Syllabus/SyllabusController.cs

@@ -43,7 +43,9 @@ namespace TEAMModelOS.Controllers.Syllabus
         }
         public static List<SyllabusNode> TreeToList(List<SyllabusTree> trees, List<SyllabusNode> nodes)
         {
+            trees = trees.OrderBy(x => x.order).ToList(); 
             nodes.AddRange(trees.ToJson().FromJson<List<SyllabusNode>>());
+
             foreach (SyllabusTree tree in trees)
             {
                 if (null != tree.children && tree.children.Count > 0)