|
@@ -84,7 +84,7 @@ namespace TEAMModelOS.Controllers
|
|
|
else if ($"{_scope}".Equals("private"))
|
|
|
{
|
|
|
|
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
+ code = $"LessonRecord";
|
|
|
tbname = "Teacher";
|
|
|
}
|
|
|
else
|
|
@@ -192,7 +192,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
else if ($"{_dscope}".Equals("private"))
|
|
|
{
|
|
|
- code = $"LessonRecord-{_dtmdid}";
|
|
|
+ code = $"LessonRecord";
|
|
|
tbname = "Teacher";
|
|
|
}
|
|
|
else
|
|
@@ -253,6 +253,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string code = "";
|
|
|
string school = null;
|
|
|
List<string> autoTch = new List<string>();
|
|
|
+ string sqlPrivate = "";
|
|
|
if (_scope.GetString().Equals("school"))
|
|
|
{
|
|
|
if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
@@ -296,7 +297,8 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
|
{
|
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
+ code = $"LessonRecord";
|
|
|
+ sqlPrivate = $" and c.tmdid='{_tmdid}'";
|
|
|
tbname = "Teacher";
|
|
|
List<string> ids = new List<string>();
|
|
|
ids.Add($"{_tmdid}");
|
|
@@ -331,38 +333,38 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
sqlShow = $" and (array_contains(c.show,'student') or array_contains(c.show,'all') {autoSql} ) ";
|
|
|
}
|
|
|
- cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false ) and array_length(c.groupIds)>0 {sqlShow} and ");
|
|
|
+
|
|
|
+ cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false ) and array_length(c.groupIds)>0 {sqlPrivate} {sqlShow} and ");
|
|
|
List<LessonRecord> records = new List<LessonRecord>();
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<LessonRecord>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
|
{
|
|
|
records.Add(item);
|
|
|
}
|
|
|
- if (records.Any()) {
|
|
|
- var groupIds= records.SelectMany(x => x.groupIds).ToHashSet();
|
|
|
- if (groupIds.Any()) {
|
|
|
- var groups = await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school," c.id ");
|
|
|
- //获取已经被删除的名单。
|
|
|
- var idsExp = groupIds.Except(groups.Select(x => x.id));
|
|
|
- if (idsExp.Any()) {
|
|
|
-
|
|
|
+ //if (records.Any()) {
|
|
|
+ // var groupIds= records.SelectMany(x => x.groupIds).ToHashSet();
|
|
|
+ // if (groupIds.Any()) {
|
|
|
+ // var groups = await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school," c.id ");
|
|
|
+ // //获取已经被删除的名单。
|
|
|
+ // var idsExp = groupIds.Except(groups.Select(x => x.id));
|
|
|
+ // if (idsExp.Any()) {
|
|
|
|
|
|
- foreach(var item in records)
|
|
|
- {
|
|
|
- int countRmv = item.groupIds.RemoveAll(x => idsExp.Contains(x));
|
|
|
- if (countRmv > 0)
|
|
|
- {
|
|
|
- try {
|
|
|
- LessonRecord record = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<LessonRecord>(item.id, new PartitionKey(code));
|
|
|
- record.groupIds = item.groupIds;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(record, item.id, new PartitionKey(code));
|
|
|
- } catch (CosmosException ex) when (ex.Status == 404) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // foreach(var item in records)
|
|
|
+ // {
|
|
|
+ // int countRmv = item.groupIds.RemoveAll(x => idsExp.Contains(x));
|
|
|
+ // if (countRmv > 0)
|
|
|
+ // {
|
|
|
+ // try {
|
|
|
+ // LessonRecord record = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<LessonRecord>(item.id, new PartitionKey(code));
|
|
|
+ // record.groupIds = item.groupIds;
|
|
|
+ // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(record, item.id, new PartitionKey(code));
|
|
|
+ // } catch (CosmosException ex) when (ex.Status == 404) {
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
count = records.Count;
|
|
|
return Ok(new { count=count, records });
|
|
|
}
|
|
@@ -418,6 +420,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string tbname = "";
|
|
|
string code = "";
|
|
|
string school = null;
|
|
|
+ string sqlPrivate = "";
|
|
|
List<string> autoTch = new List<string>();
|
|
|
if (_scope.GetString().Equals("school"))
|
|
|
{
|
|
@@ -460,7 +463,9 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
|
{
|
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
+
|
|
|
+ sqlPrivate = $" and c.tmdid='{_tmdid}'";
|
|
|
+ code = $"LessonRecord";
|
|
|
tbname = "Teacher";
|
|
|
List<string> ids = new List<string>();
|
|
|
ids.Add($"{_tmdid}");
|
|
@@ -495,7 +500,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
sqlShow = $" and (array_contains(c.show,'student') or array_contains(c.show,'all') {autoSql} ) ";
|
|
|
}
|
|
|
- cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false ) and array_length(c.groupIds)>0 {sqlShow} and ");
|
|
|
+ cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false ) and array_length(c.groupIds)>0 {sqlPrivate} {sqlShow} and ");
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
|
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, continuationToken: continuationToken,
|
|
|
requestOptions: new QueryRequestOptions() { MaxItemCount = pageCount, PartitionKey = new PartitionKey(code) }))
|
|
@@ -599,7 +604,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
|
{
|
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
+ code = $"LessonRecord";
|
|
|
tbname = "Teacher";
|
|
|
}
|
|
|
else
|
|
@@ -636,6 +641,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
|
string tbname = "";
|
|
|
string code = "";
|
|
|
+ string sqlPrivate = "";
|
|
|
if (_scope.GetString().Equals("school") )
|
|
|
{
|
|
|
if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
@@ -654,7 +660,8 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
|
{
|
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
+ sqlPrivate = $" and c.tmdid='{_tmdid}'";
|
|
|
+ code = $"LessonRecord";
|
|
|
tbname = "Teacher";
|
|
|
}
|
|
|
else {
|
|
@@ -690,9 +697,10 @@ namespace TEAMModelOS.Controllers
|
|
|
["today"] = true,
|
|
|
["periodId"] = $"{_periodId}",
|
|
|
}.ToJsonString().ToObject<JsonElement>();
|
|
|
- List<LessonRecord> excellentRcd =await GetOtherLessonCond(excellent, code, tbname);
|
|
|
- List<LessonRecord> doubleGreenRcd = await GetOtherLessonCond(doubleGreen, code, tbname);
|
|
|
- List<LessonRecord> todayRcd = await GetOtherLessonCond(today, code, tbname);
|
|
|
+
|
|
|
+ List<LessonRecord> excellentRcd =await GetOtherLessonCond(excellent, code, tbname, sqlPrivate);
|
|
|
+ List<LessonRecord> doubleGreenRcd = await GetOtherLessonCond(doubleGreen, code, tbname, sqlPrivate);
|
|
|
+ List<LessonRecord> todayRcd = await GetOtherLessonCond(today, code, tbname, sqlPrivate);
|
|
|
try {
|
|
|
var tmdids_excellent = excellentRcd.Select(x => x.tmdid);
|
|
|
var tmdids_doubleGreen = excellentRcd.Select(x => x.tmdid);
|
|
@@ -739,13 +747,13 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async Task<List<LessonRecord>> GetOtherLessonCond(JsonElement request,string code ,string tbname ) {
|
|
|
+ private async Task<List<LessonRecord>> GetOtherLessonCond(JsonElement request,string code ,string tbname,string sqlPrivate) {
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
sql.Append("select value(c) from c ");
|
|
|
Dictionary<string, object> dict = GetLessonCond(request);
|
|
|
AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
|
|
|
List<LessonRecord> lessonRecords = new List<LessonRecord>();
|
|
|
- cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", " where (c.status<>404 or IS_DEFINED(c.status) = false ) and ");
|
|
|
+ cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false ) and array_length(c.groupIds)>0 {sqlPrivate} and ");
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
|
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|