|
@@ -22,6 +22,7 @@ using TEAMModelOS.SDK.Models.Table;
|
|
|
using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
|
|
|
using TEAMModelOS.SDK.Context.Constant;
|
|
|
using TEAMModelOS.SDK.Models.Dtos;
|
|
|
+using TEAMModelOS.SDK.Services;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -827,6 +828,172 @@ namespace TEAMModelOS.Controllers
|
|
|
return new ResponseData<List<OTeachers>>() { code = RespondCode.Error, msg = "服务器错误" };
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查找课纲
|
|
|
+ /// [ApiToken(Auth = "1601", Name = "查询课纲", RWN = "R", Limit = false)]
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_azureCosmos"></param>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<ResponseData<List<OSyllabusTreeNode>>> GetSyllabus(AzureCosmosFactory _azureCosmos, DingDing _dingDing, string bizId, string school, JsonElement json)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!json.TryGetProperty("volumeId", out JsonElement volumeId)) return new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
+ //if (!json.TryGetProperty("volumeCode", out JsonElement volumeCode)) return new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
+ if (!json.TryGetProperty("scope", out JsonElement scope)) return new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
+
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+
|
|
|
+ OVolume volume = null;
|
|
|
+ List<OSyllabusTreeNode> treeNodes = new();
|
|
|
+ List<OSyllabusTreeNode> redt = new();
|
|
|
+ if ($"{scope}".Equals("school"))
|
|
|
+ {
|
|
|
+ List<OSyllabus> delSyllabus = new();
|
|
|
+ volume = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<OVolume>($"{volumeId}", new PartitionKey($"Volume-{school}"));
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<OSyllabus>(queryText: $"select value(c) from c where c.volumeId='{volumeId}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{volume.school}") }))
|
|
|
+ {
|
|
|
+ if (item.children.IsEmpty())
|
|
|
+ {
|
|
|
+ delSyllabus.Add(item);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ List<OSyllabusTree> trees = SyllabusService.OListToTree(item.children);
|
|
|
+ OSyllabusTreeNode otree = new() { id = item.id, scope = item.scope, trees = trees, volumeId = item.volumeId, codeval = volume.school };
|
|
|
+ treeNodes.Add(otree);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (delSyllabus.IsNotEmpty())
|
|
|
+ {
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemsAsync<OSyllabus>(delSyllabus.Select(x => x.id).ToList(), $"Syllabus-{volume.school}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
+
|
|
|
+ ResponseData<List<OSyllabusTreeNode>> responseData = new();
|
|
|
+ //对课纲树形结构排序
|
|
|
+ if (volume.syllabusIds.IsNotEmpty())
|
|
|
+ {
|
|
|
+ volume.syllabusIds.ForEach(x =>
|
|
|
+ {
|
|
|
+ for (int index = 0; index < treeNodes.Count; index++)
|
|
|
+ {
|
|
|
+ if (treeNodes[index].id == x)
|
|
|
+ {
|
|
|
+ redt.Add(treeNodes[index]);
|
|
|
+ treeNodes.RemoveAt(index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ redt.AddRange(treeNodes);
|
|
|
+ responseData = new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.Ok, msg = "成功", data = redt };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ responseData = new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.Ok, msg = "成功", data = treeNodes };
|
|
|
+ }
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetSyllabus() 参数:bizId:{bizId},school:{school},参数json:{json.ToJsonString()} \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ return new ResponseData<List<OSyllabusTreeNode>>() { code = RespondCode.Error, msg = "服务器错误!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询册别清单
|
|
|
+ /// [ApiToken(Auth = "1602", Name = "查询册别", RWN = "R", Limit = false)]
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_azureCosmos"></param>
|
|
|
+ /// <param name="_dingDing"></param>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<ResponseData<List<OVolume>>> GetVolumes(AzureCosmosFactory _azureCosmos,DingDing _dingDing, string bizId, string school, JsonElement json)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ResponseData<List<OVolume>> responseData = new();
|
|
|
+
|
|
|
+ List<OVolume> ovolumes = new List<OVolume>();
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodCode);
|
|
|
+ json.TryGetProperty("subjectId", out JsonElement subjectCode);
|
|
|
+ json.TryGetProperty("status", out JsonElement status);
|
|
|
+ json.TryGetProperty("scope", out JsonElement scope);
|
|
|
+ if (scope.GetString().Equals("school"))
|
|
|
+ {
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<OVolume>(queryText: $"select value(c) from c where c.status = {status} and c.periodId = '{periodCode}' and c.subjectId = '{subjectCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Volume-{school}") }))
|
|
|
+ {
|
|
|
+ ovolumes.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else { return new ResponseData<List<OVolume>>() { code = RespondCode.ParamsError, msg = "参数错误" }; };
|
|
|
+
|
|
|
+ if (ovolumes.Count > 0)
|
|
|
+ {
|
|
|
+ responseData = new ResponseData<List<OVolume>>() { code = RespondCode.Ok, msg = "成功", data = ovolumes };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ responseData = new ResponseData<List<OVolume>>() { code = RespondCode.NotFound, msg = "未找到参数相关的数据" };
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetVolumes() 参数:bizId:{bizId},school:{school},参数json:{json.ToJsonString()} \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ return new ResponseData<List<OVolume>>() { code = RespondCode.Error, msg = "服务器错误!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询知识
|
|
|
+ /// [ApiToken(Auth = "1701", Name = "查询知识点", RWN = "R", Limit = false)]
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_azureCosmos"></param>
|
|
|
+ /// <param name="_dingDing"></param>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<ResponseData<List<Knowledge>>> GetKnowledges(AzureCosmosFactory _azureCosmos, DingDing _dingDing, string bizId, string school, JsonElement json)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ResponseData<List<Knowledge>> responseData = new();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ if (!json.TryGetProperty("subjectId", out JsonElement subjectId)) return new ResponseData<List<Knowledge>>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
+ //if (!json.TryGetProperty("school_code", out JsonElement school_code)) return new ResponseData<List<Knowledge>>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
+ string code = $"Knowledge-{school}-{subjectId}";
|
|
|
+ StringBuilder sql = new($"select value(c) from c");
|
|
|
+ if (periodId.ValueKind.Equals(JsonValueKind.String))
|
|
|
+ {
|
|
|
+ sql.Append($" where c.periodId = '{periodId}'");
|
|
|
+ }
|
|
|
+ List<Knowledge> knowledges = new();
|
|
|
+
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
+ {
|
|
|
+ knowledges.Add(item);
|
|
|
+ }
|
|
|
+ if (knowledges.Count > 0)
|
|
|
+ responseData = new() { code = RespondCode.Ok, msg = "成功", data = knowledges };
|
|
|
+ else
|
|
|
+ responseData = new() { code = RespondCode.NotFound, msg = "未找到相关" };
|
|
|
+
|
|
|
+ return responseData;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetKnowledges() 参数:bizId:{bizId},school:{school},参数json:{json.ToJsonString()} \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ return new ResponseData<List<Knowledge>>() { code = RespondCode.Error, msg = "服务器错误!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static void GenApiTableRecord(AzureStorageFactory azureStorage)
|
|
|
{
|
|
|
|