|
@@ -11,7 +11,9 @@ using TEAMModelBI.Models;
|
|
|
using TEAMModelBI.Tool;
|
|
|
using TEAMModelOS.Models;
|
|
|
using TEAMModelOS.SDK.Context.BI;
|
|
|
+using TEAMModelOS.SDK.Context.Constant;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
+using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
|
|
@@ -37,6 +39,88 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
_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("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");
|
|
|
+ }
|
|
|
+
|
|
|
+ var cosmosClinet = _azureCosmos.GetCosmosClient();
|
|
|
+ StringBuilder sql = new("select value(c) from c ");
|
|
|
+ AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dic, sql);
|
|
|
+
|
|
|
+ List<Paper> papers = new();
|
|
|
+ if (scope.ToString().Equals("school"))
|
|
|
+ {
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
+ {
|
|
|
+ papers.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (scope.ToString().Equals("private"))
|
|
|
+ {
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
+ {
|
|
|
+ papers.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
+ {
|
|
|
+ papers.Add(item);
|
|
|
+ }
|
|
|
+ await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
+ {
|
|
|
+ papers.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok,cnt = papers.Count, papers });
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 复制试卷信息到另外一个学校
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("copy-infos")]
|
|
|
+ public async Task<IActionResult> CopyInfos(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok});
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 查询试卷的数量统计集合
|
|
|
/// </summary>
|
|
@@ -315,7 +399,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
//if ($"{site}".Equals(BIConst.Global))
|
|
|
// cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
|
|
|
|
|
|
- List<object> paperInfos = new List<object>();
|
|
|
+ List<object> paperInfos = new();
|
|
|
string sqlTxt = $"select * from c where c.id='{paperId}' and c.pk='Paper'";
|
|
|
|
|
|
if (!string.IsNullOrEmpty($"{isPersonal}"))
|