|
@@ -13,6 +13,10 @@ using System.Text;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
|
|
+using Azure.Core;
|
|
|
|
+using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
|
|
|
|
+using TEAMModelOS.SDK.Context.Constant;
|
|
|
|
+using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.Census
|
|
namespace TEAMModelBI.Controllers.Census
|
|
{
|
|
{
|
|
@@ -33,6 +37,117 @@ namespace TEAMModelBI.Controllers.Census
|
|
_option = option?.Value;
|
|
_option = option?.Value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询学校试题
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [HttpPost("get-list")]
|
|
|
|
+ public async Task<IActionResult> GetList(JsonElement jsonElement)
|
|
|
|
+ {
|
|
|
|
+ if (!jsonElement.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
|
+ jsonElement.TryGetProperty("scope", out JsonElement scope);
|
|
|
|
+ Dictionary<string, object> dic = new();
|
|
|
|
+ if (jsonElement.TryGetProperty("periodId", out JsonElement periodId))
|
|
|
|
+ dic.Add("periodId", periodId);
|
|
|
|
+ if (jsonElement.TryGetProperty("subjectId", out JsonElement subjectId))
|
|
|
|
+ dic.Add("subjectId", subjectId);
|
|
|
|
+ if (jsonElement.TryGetProperty("gradeIds", out JsonElement gradeIds))
|
|
|
|
+ dic.Add("gradeIds", gradeIds);
|
|
|
|
+ if (jsonElement.TryGetProperty("type", out JsonElement type))
|
|
|
|
+ dic.Add("type", type);
|
|
|
|
+ if (jsonElement.TryGetProperty("level", out JsonElement level))
|
|
|
|
+ dic.Add("level", level);
|
|
|
|
+ if (jsonElement.TryGetProperty("field", out JsonElement field))
|
|
|
|
+ dic.Add("field", field);
|
|
|
|
+ if (jsonElement.TryGetProperty("isSort", out JsonElement isSort))
|
|
|
|
+ {
|
|
|
|
+ if (!string.IsNullOrEmpty($"{isSort}"))
|
|
|
|
+ {
|
|
|
|
+ if (bool.Parse($"{isSort}") == true)
|
|
|
|
+ dic.Add("@DESC", "createTime");
|
|
|
|
+ else
|
|
|
|
+ dic.Add("@ASC", "createTime");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ dic.Add("@ASC", "createTime");
|
|
|
|
+ }
|
|
|
|
+ if (jsonElement.TryGetProperty("pid", out JsonElement pd))
|
|
|
|
+ {
|
|
|
|
+ if (pd.ValueKind != JsonValueKind.Null)
|
|
|
|
+ dic.Add("pid", pd.ToString());
|
|
|
|
+ else
|
|
|
|
+ dic.Add("pid", null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var cosmosClinet = _azureCosmos.GetCosmosClient();
|
|
|
|
+ StringBuilder sql = new("select c.id,c.code,c.repairResource, c.periodId,c.question,c.useCount,c.level,c.field,c.knowledge,c.type,c.option,c.createTime,c.answer,c.explain,c.children,c.score,c.gradeIds,c.subjectId,c.blob,c.scope from c ");
|
|
|
|
+ AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dic, sql);
|
|
|
|
+ List<object> items = new();
|
|
|
|
+ if (scope.ToString().Equals("private"))
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ items.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (scope.ToString().Equals("school"))
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ items.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ items.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ items.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Ok(new { state = RespondCode.Ok ,cnt = items.Count, items });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 查询所有试题数量
|
|
/// 查询所有试题数量
|
|
/// </summary>
|
|
/// </summary>
|