|
@@ -12,6 +12,7 @@ using TEAMModelOS.Models;
|
|
using TEAMModelOS.SDK.Context.Exception;
|
|
using TEAMModelOS.SDK.Context.Exception;
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
|
|
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
|
|
using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
|
|
using TEAMModelOS.SDK.Module.AzureCosmosDB.Interfaces;
|
|
using static System.Text.Json.JsonElement;
|
|
using static System.Text.Json.JsonElement;
|
|
@@ -43,38 +44,37 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
string contentRootPath = webHostEnvironment.ContentRootPath;
|
|
string contentRootPath = webHostEnvironment.ContentRootPath;
|
|
JsonDocument document = await GetJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
JsonDocument document = await GetJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
|
|
|
- string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
|
-
|
|
|
|
- JArray parsedJson = JArray.Parse(data);
|
|
|
|
|
|
+ //string data = getJson(contentRootPath, "/JsonFile/Core/BaseDataDefault.json");
|
|
|
|
+ //JArray parsedJson = JArray.Parse(data);
|
|
if (!request.@params)
|
|
if (!request.@params)
|
|
{
|
|
{
|
|
|
|
|
|
- List<JObject> jsonElements = new List<JObject>();
|
|
|
|
- foreach (JObject element in parsedJson )
|
|
|
|
- {
|
|
|
|
- if (element.TryGetValue("lang", out JToken json))
|
|
|
|
- {
|
|
|
|
- if (json.ToString().Equals(request.lang))
|
|
|
|
- {
|
|
|
|
- jsonElements.Add(element);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //foreach (JsonElement element in document.RootElement.EnumerateArray())
|
|
|
|
|
|
+ List<JsonElement> jsonElements = new List<JsonElement>();
|
|
|
|
+ //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);
|
|
// 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();
|
|
return builder.Data(jsonElements).build();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- return builder.Data(parsedJson).build();
|
|
|
|
|
|
+ return builder.Data(document.RootElement).build();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,7 +126,8 @@ namespace TEAMModelOS.Controllers.Syllabus
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
IQueryable<dynamic> data = azureCosmosDBRepository.FindByDict(request.@params.collectionName,request.@params.queryDict);
|
|
IQueryable<dynamic> data = azureCosmosDBRepository.FindByDict(request.@params.collectionName,request.@params.queryDict);
|
|
- return builder.Data(data).build();
|
|
|
|
|
|
+ JsonElement json = JsonApiHelper.FromApiJson<JsonElement>( data.ToJson());
|
|
|
|
+ return builder.Data(json).build();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|