CrazyIter 5 年 前
コミット
1d68474ef8

+ 3 - 3
TEAMModelOS.API/Controllers/Core/ClassroomController.cs

@@ -24,14 +24,14 @@ namespace TEAMModelOS.API.Controllers.Core
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             
-            if (request.@params.Id != null)
+            if (request.@params.id != null)
             {
-                await cosmosrepository.ReplaceObject(request.@params, request.@params.Id, request.@params.SchoolCode);
+                await cosmosrepository.ReplaceObject(request.@params, request.@params.id, request.@params.schoolCode);
 
             }
             else
             {
-                request.@params.Id = Guid.NewGuid().ToString();
+                request.@params.id = Guid.NewGuid().ToString();
                 await cosmosrepository.Save<Classroom>(request.@params);
                 
             }

+ 75 - 0
TEAMModelOS.API/Controllers/Core/CommonController.cs

@@ -0,0 +1,75 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.Context.Exception;
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
+using static System.Text.Json.JsonElement;
+
+namespace TEAMModelOS.API.Controllers.Core
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    // [Authorize]
+    public class CommonController : BaseController
+    {
+        public readonly IWebHostEnvironment  webHostEnvironment;
+
+        public CommonController(IWebHostEnvironment _webHostEnvironment) {
+            webHostEnvironment = _webHostEnvironment;
+
+        }
+        /// <summary>
+        /// bool =true 獲取全部 false 則從request.lang 篩選指定語言的,默認zh-CN
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("SubjectDefault")]
+        public    async Task<BaseJosnRPCResponse> SubjectDefault(JosnRPCRequest<bool> request)
+        {
+            JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
+            string contentRootPath = webHostEnvironment.ContentRootPath;
+            JsonDocument document= await  GetJson(contentRootPath, "Subject/SubjectDefault");
+            if (request.@params) {
+                List<JsonElement> jsonElements = new List<JsonElement>();
+                foreach (JsonElement element in document.RootElement.EnumerateArray())
+                {
+                    string date = element.GetProperty("lang").GetString();
+                    if (!string.IsNullOrEmpty(date)&&date.Equals(request.lang)) {
+                        jsonElements.Add(element);
+                    }
+                }
+                return builder.Data(jsonElements).build();
+            }
+            else
+            {
+                return builder.Data(document.RootElement).build();
+            }
+            
+        }
+        public static async Task<JsonDocument> GetJson(string contentRootPath, string name)
+        {
+            //string webRootPath = _hostingEnvironment.WebRootPath;
+
+            try
+            {
+                string path = contentRootPath + "/JsonFile/" + name + ".json";
+                //获取正在占用的文件
+                var  fs = await System.IO. File.ReadAllTextAsync(path,Encoding.UTF8);
+               return   JsonDocument.Parse(fs);
+            }
+            catch (Exception e)
+            {
+                new BizException(e.Message);
+            }
+            return null;
+        }
+    }
+}

ファイルの差分が大きいため隠しています
+ 1 - 1
TEAMModelOS.API/Controllers/Core/FileController.cs


+ 1 - 1
TEAMModelOS.SDK/Context/Filters/HttpGlobalExceptionFilter.cs

@@ -73,7 +73,7 @@ namespace TEAMModelOS.SDK.Context.Filters
         {
             var data = new ErrorResponse<string>(statusCode, msg, devmsg);
             context.Response.ContentType = "application/json;charset=utf-8";
-            await context.Response.WriteAsync(JsonSerialization.ToJson(data));
+            await context.Response.WriteAsync(JsonNetHelper.ToJson(data));
         }
     }
     public class ApplicationErrorResult : ObjectResult

+ 1 - 1
TEAMModelOS.SDK/Context/Filters/HttpGlobalExceptionInvoke.cs

@@ -93,7 +93,7 @@ namespace TEAMModelOS.SDK.Context.Filter
         {
             var data = new ErrorResponse<string>(statusCode, msg, devmsg);
             context.Response.ContentType = Constants.CONTENT_TYPE_JSON;
-            await context.Response.WriteAsync(JsonSerialization.ToJson(data));
+            await context.Response.WriteAsync(JsonNetHelper.ToJson(data));
         }
         /// <summary>
         /// 异常信息封装

+ 2 - 2
TEAMModelOS.SDK/Extension/MessagePush/Implements/SendCloudService.cs

@@ -138,7 +138,7 @@ namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
             };
             if (vars != null)
             {
-                paramList.Add(new KeyValuePair<string, string>("vars", JsonSerialization.ToJson(vars)));
+                paramList.Add(new KeyValuePair<string, string>("vars", JsonNetHelper.ToJson(vars)));
             }
             var param_str = "";
             foreach (var param in paramList)
@@ -149,7 +149,7 @@ namespace TEAMModelOS.SDK.Extension.MessagePush.Implements
             string sign = Md5Hash.Encrypt(sign_str);
             paramList.Add(new KeyValuePair<string, string>("signature", sign));
             string result = await _httpClientService.HttpPostAsync(smsSendCloud.SmsUrl, paramList);
-            return JsonSerialization.FromJson<SendCloudResponse>(result);
+            return JsonNetHelper.FromJson<SendCloudResponse>(result);
 
         }
     }

+ 29 - 0
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonApiHelper.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.Json;
+
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper
+{
+    public static class JsonApiHelper
+    {
+        static JsonSerializerOptions options = new JsonSerializerOptions()
+        {
+            WriteIndented = true,                                   //格式化json字符串
+            AllowTrailingCommas = true,                             //可以结尾有逗号
+            //IgnoreNullValues = true,                              //可以有空值,转换json去除空值属性
+            IgnoreReadOnlyProperties = true,                        //忽略只读属性
+            PropertyNameCaseInsensitive = true,                     //忽略大小写
+            //PropertyNamingPolicy = JsonNamingPolicy.CamelCase     //命名方式是默认还是CamelCase
+        };
+        public static string ToJson(this object input)
+        {
+            return JsonSerializer.Serialize(input, options);
+        }
+
+        public static T FromJson<T>(this string input)
+        {
+            return JsonSerializer.Deserialize<T>(input, options);
+        }
+    }
+}

+ 1 - 1
TEAMModelOS.SDK/Helper/Common/JsonHelper/JsonSerialization.cs

@@ -5,7 +5,7 @@ using System.Text;
 
 namespace TEAMModelOS.SDK.Helper.Common.JsonHelper
 {
-    public static class JsonSerialization
+    public static class JsonNetHelper
     {
         static JsonSerializerSettings settings = new JsonSerializerSettings()
         {

+ 1 - 1
TEAMModelOS.SDK/Extension/JsonPath/IJsonPathValueSystem.cs

@@ -4,7 +4,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 
-namespace WebTest.JsonPath
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
 {
     public interface IJsonPathValueSystem
     {

+ 1 - 1
TEAMModelOS.SDK/Extension/JsonPath/JsonApiValueSystem.cs

@@ -5,7 +5,7 @@ using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 
-namespace WebTest.JsonPath
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
 {
     public class JsonApiValueSystem : IJsonPathValueSystem
     {

+ 1 - 1
TEAMModelOS.SDK/Extension/JsonPath/JsonNetValueSystem.cs

@@ -3,7 +3,7 @@ using System.Collections;
 using System.Linq;
 using Newtonsoft.Json.Linq;
 
-namespace WebTest.JsonPath
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
 {
     public class JsonNetValueSystem : IJsonPathValueSystem
     {

+ 1 - 2
TEAMModelOS.SDK/Extension/JsonPath/JsonPathContext.cs

@@ -9,7 +9,7 @@ using System.Text.Json;
 using System.Text.RegularExpressions;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 
-namespace WebTest.JsonPath
+namespace TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath
 {
     /// <summary>
     /// 语法文档  https://www.cnblogs.com/aoyihuashao/p/8665873.html
@@ -257,7 +257,6 @@ namespace WebTest.JsonPath
                 string atom = i >= 0 ? expr.Substring(0, i) : expr;
                 string tail = i >= 0 ? expr.Substring(i + 1) : string.Empty;
                 bool mb = system.HasMember(value, atom);
-                Console.WriteLine("mb:" + mb);
                 if (value != null && mb)
                 {
                     Trace(tail, Index(value, atom), path + ";" + atom);

+ 27 - 27
TEAMModelOS/JsonFile/Period/SubjectDefault.json

@@ -1,83 +1,83 @@
 [
   {
-    "code": "zh-CN",
-    "name": "中国大陆",
-    "lang": "简体中文",
+    "lang": "zh-CN",
+    "name": "涓�浗澶ч檰",
+    "alias": "简体中文",
     "subjects": [
       {
         "code": "Subject_Chinese",
-        "name": "语文"
+        "name": "璇�枃"
       },
       {
         "code": "Subject_Math",
-        "name": "数学"
+        "name": "鏁板�"
       },
       {
         "code": "Subject_English",
-        "name": "英语"
+        "name": "鑻辫�"
       },
       {
         "code": "Subject_Physics",
-        "name": "物理"
+        "name": "鐗╃悊"
       },
       {
         "code": "Subject_Chemistry",
-        "name": "化学"
+        "name": "鍖栧�"
       },
       {
         "code": "Subject_Biology",
-        "name": "生物"
+        "name": "鐢熺墿"
       },
       {
         "code": "Subject_Politics",
-        "name": "政治"
+        "name": "鏀挎不"
       },
       {
         "code": "Subject_History",
-        "name": "历史"
+        "name": "鍘嗗彶"
       },
       {
         "code": "Subject_Geography",
-        "name": "地理"
+        "name": "鍦扮悊"
       },
       {
         "code": "Subject_Information",
-        "name": "信息"
+        "name": "淇℃伅"
       },
       {
         "code": "Subject_Science",
-        "name": "科学"
+        "name": "绉戝�"
       }
     ]
   },
   {
-    "code": "zh-HK",
-    "name": "中國香港",
-    "lang": "繁體中文",
+    "lang": "zh-HK",
+    "name": "涓�湅棣欐腐",
+    "alias": "绻侀珨涓�枃",
     "subjects": []
   },
   {
-    "code": "zh-MO",
-    "name": "中國澳門",
-    "lang": "繁體中文",
+    "lang": "zh-MO",
+    "name": "涓�湅婢抽杸",
+    "alias": "绻侀珨涓�枃",
     "subjects": []
   },
   {
-    "code": "zh-TW",
-    "name": "中國台灣",
-    "lang": "繁體中文",
+    "lang": "zh-TW",
+    "name": "涓�湅鍙扮仯",
+    "alias": "绻侀珨涓�枃",
     "subjects": []
   },
   {
-    "code": "en-US",
+    "lang": "en-US",
     "name": "United States",
-    "lang": "English",
+    "alias": "English",
     "subjects": []
   },
   {
-    "code": "en-UK",
+    "lang": "en-UK",
     "name": "United Kingdom",
-    "lang": "English",
+    "alias": "English",
     "subjects": []
   }
 ]

+ 2 - 2
TEAMModelOS/Properties/launchSettings.json

@@ -11,7 +11,7 @@
   "profiles": {
     "IIS Express": {
       "commandName": "IISExpress",
-      "launchBrowser": true,
+      "launchBrowser": false,
       "launchUrl": "selectModule",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
@@ -19,7 +19,7 @@
     },
     "TEAMModelOS": {
       "commandName": "Project",
-      "launchBrowser": true,
+      "launchBrowser": false,
       "launchUrl": "selectModule",
       "applicationUrl": "https://localhost:5001;http://localhost:5000",
       "environmentVariables": {

+ 1 - 7
TEAMModelOS/TEAMModelOS.csproj

@@ -11,11 +11,6 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
-      <PrivateAssets>all</PrivateAssets>
-      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
-    </PackageReference>
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
     <PackageReference Include="VueCliMiddleware" Version="3.0.0" />
@@ -29,7 +24,6 @@
 
   <ItemGroup>
     <Folder Include="wwwroot\" />
-    <Folder Include="新文件夹\" />
   </ItemGroup>
   
   <ItemGroup>
@@ -70,6 +64,6 @@
     </ItemGroup>
   </Target>
 
-  <ProjectExtensions><VisualStudio><UserProperties jsonfile_4period_4period_3zh-cn_1json__JsonSchema="http://json.schemastore.org/2.0.0-csd.2.beta.2018-10-10.json" jsonfile_4core_4json_1json__JsonSchema="http://json.schemastore.org/2.0.0-csd.2.beta.2018-10-10.json" jsonfile_4core_4lang_1json__JsonSchema="http://json.schemastore.org/2.0.0-csd.2.beta.2018-10-10.json" /></VisualStudio></ProjectExtensions>
+  <ProjectExtensions><VisualStudio><UserProperties jsonfile_4core_4lang_1json__JsonSchema="http://json.schemastore.org/2.0.0-csd.2.beta.2018-10-10.json" /></VisualStudio></ProjectExtensions>
 
 </Project>