Explorar o código

调整Common/DataDefault 接口输出

CrazyIter %!s(int64=5) %!d(string=hai) anos
pai
achega
368be0388f

+ 2 - 0
TEAMModelOS.SDK/Module/AzureCosmosDB/Implements/AzureCosmosDBRepository.cs

@@ -11,6 +11,7 @@ using TEAMModelOS.SDK.Context.Exception;
 using Microsoft.Azure.Documents.Linq;
 using TEAMModelOS.SDK.Helper.Query.LinqHelper;
 using System.Reflection;
+using Microsoft.Azure.Cosmos;
 using Microsoft.Azure.CosmosDB.BulkExecutor;
 using Microsoft.Azure.CosmosDB.BulkExecutor.BulkImport;
 using System.Threading;
@@ -62,6 +63,7 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
                 CollectionThroughput = options.CollectionThroughput;
                 CosmosClient.CreateDatabaseIfNotExistsAsync(new Database { Id = Database });
                 // _connectionString = options.ConnectionString;
+               // CosmosSerializer
 
                 //获取数据库所有的表
                 FeedResponse<DocumentCollection> collections = CosmosClient.ReadDocumentCollectionFeedAsync(UriFactory.CreateDatabaseUri(Database)).GetAwaiter().GetResult();

+ 8 - 0
TEAMModelOS.Service/Models/Syllabus/SyllabusNode.cs

@@ -21,6 +21,14 @@ namespace TEAMModelOS.Service.Models.Syllabus
         /// </summary>
         public bool expand { get; set; }
         /// <summary>
+        /// 是否编辑
+        /// </summary>
+        public bool editable { get; set; } = true;
+        /// <summary>
+        /// 版本
+        /// </summary>
+        public string  version { get; set; } 
+        /// <summary>
         /// 排序
         /// </summary>
         [Required(ErrorMessage = "{0} 必须填写")]

+ 51 - 6
TEAMModelOS/Controllers/Core/CommonController.cs

@@ -1,5 +1,6 @@
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -41,26 +42,70 @@ namespace TEAMModelOS.Controllers.Syllabus
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             string contentRootPath = webHostEnvironment.ContentRootPath;
             JsonDocument document = await GetJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
+
+            string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
+
+            JArray parsedJson = JArray.Parse(data);
             if (!request.@params)
             {
-                List<JsonElement> jsonElements = new List<JsonElement>();
-                foreach (JsonElement element in document.RootElement.EnumerateArray())
+            
+                List<JObject> jsonElements = new List<JObject>();
+                foreach (JObject element in parsedJson )
                 {
-                    if (element.TryGetProperty("lang", out JsonElement json))
+                    if (element.TryGetValue("lang", out JToken json))
                     {
-                        if (json.GetString().Equals(request.lang))
+                        if (json.ToString().Equals(request.lang))
                         {
                             jsonElements.Add(element);
                         }
                     }
                 }
+                //foreach (JsonElement element in document.RootElement.EnumerateArray())
+                //{
+                //    if (element.TryGetProperty("lang", out JsonElement json))
+                //    {
+                //        if (json.GetString().Equals(request.lang))
+                //        {
+                //            jsonElements.Add(element);
+                //        }
+                //    }
+                //}
                 return builder.Data(jsonElements).build();
             }
             else
             {
-                return builder.Data(document.RootElement).build();
+                return builder.Data(parsedJson).build();
             }
-        } 
+        }
+
+
+        public static string getJson(string contentRootPath, string name)
+        {
+            //string webRootPath = _hostingEnvironment.WebRootPath;
+
+            try
+            {
+                String path = contentRootPath + name;
+                //获取正在占用的文件
+                FileStream fs = new FileStream(path, System.IO.FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+                StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
+                String line;
+                StringBuilder builder = new StringBuilder();
+                while ((line = sr.ReadLine()) != null)
+                {
+                    builder.Append(line.ToString());
+                }
+
+                sr.Close();
+                string log = builder.ToString();
+                return log;
+            }
+            catch (Exception e)
+            {
+                var s = e.Message;
+                return s;
+            }
+        }
         public static async Task<JsonDocument> GetJson(string contentRootPath, string name)
         {
             try

+ 14 - 0
TEAMModelOS/JsonFile/Core/cosmosdb.cer

@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICGzCCAYSgAwIBAgIQTM27yJ7IJI9BJoKCaO4jbTANBgkqhkiG9w0BAQUFADAU
+MRIwEAYDVQQDEwlsb2NhbGhvc3QwHhcNMTkxMTE4MDMwMDAyWhcNMjQxMTE2MDMw
+MDAyWjAUMRIwEAYDVQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0A
+MIGJAoGBAPQEcozqL9uY8/qFdcOJLH7KsSNdQNDGhf+f7DtxfFrL7etKcLBhfAc8
+4r4mIZ2V9JRGx077uRcjcx7+juxWMvPWWzC2W9SfkwKrxQzBfXagQs9mShMpMPGU
+qD4typ4ZfH/Rl3/WJpDttb0I1t5WZlsHQ+zjPqN8scOm0AJWK0URAgMBAAGjbjBs
+MGoGA1UdEQEB/wRgMF6CD0RFU0tUT1AtMFZWRDMzUYIJbG9jYWxob3N0hwTAqAiA
+hwR/AAABgg0xOTIuMTY4LjguMTI4ggkxMjcuMC4wLjGCCzE5Mi4xNjguOC4xgg0x
+OTIuMTY4LjguMTkyMA0GCSqGSIb3DQEBBQUAA4GBAE8ZpiQJf/chU50tzJ9ijw0V
+ZghvKob3BzXaJ6W5jpJWG9Z/P0BZe+a93tSxjhSUUslZfaTas0Vlivs/bnQH82G8
+nduEWVyMRUHXcYPAt0wsmtLCTPmiIl5sqGlzIm6svPG7Ko2111ELy4XjoKpiD43X
+KK60NuHYP80ZoVOwoDPB
+-----END CERTIFICATE-----