|
@@ -84,7 +84,7 @@ namespace TEAMModelOS.Controllers
|
|
else if ($"{_scope}".Equals("private"))
|
|
else if ($"{_scope}".Equals("private"))
|
|
{
|
|
{
|
|
|
|
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
|
|
|
+ code = $"LessonRecord";
|
|
tbname = "Teacher";
|
|
tbname = "Teacher";
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -192,7 +192,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
else if ($"{_dscope}".Equals("private"))
|
|
else if ($"{_dscope}".Equals("private"))
|
|
{
|
|
{
|
|
- code = $"LessonRecord-{_dtmdid}";
|
|
|
|
|
|
+ code = $"LessonRecord";
|
|
tbname = "Teacher";
|
|
tbname = "Teacher";
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -253,6 +253,7 @@ namespace TEAMModelOS.Controllers
|
|
string code = "";
|
|
string code = "";
|
|
string school = null;
|
|
string school = null;
|
|
List<string> autoTch = new List<string>();
|
|
List<string> autoTch = new List<string>();
|
|
|
|
+ string sqlPrivate = "";
|
|
if (_scope.GetString().Equals("school"))
|
|
if (_scope.GetString().Equals("school"))
|
|
{
|
|
{
|
|
if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
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 (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
{
|
|
{
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
|
|
|
+ code = $"LessonRecord";
|
|
|
|
+ sqlPrivate = $" and c.tmdid='{_tmdid}'";
|
|
tbname = "Teacher";
|
|
tbname = "Teacher";
|
|
List<string> ids = new List<string>();
|
|
List<string> ids = new List<string>();
|
|
ids.Add($"{_tmdid}");
|
|
ids.Add($"{_tmdid}");
|
|
@@ -331,7 +333,8 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
sqlShow = $" and (array_contains(c.show,'student') or array_contains(c.show,'all') {autoSql} ) ";
|
|
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>();
|
|
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) }))
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).GetItemQueryIterator<LessonRecord>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
{
|
|
{
|
|
@@ -418,6 +421,7 @@ namespace TEAMModelOS.Controllers
|
|
string tbname = "";
|
|
string tbname = "";
|
|
string code = "";
|
|
string code = "";
|
|
string school = null;
|
|
string school = null;
|
|
|
|
+ string sqlPrivate = "";
|
|
List<string> autoTch = new List<string>();
|
|
List<string> autoTch = new List<string>();
|
|
if (_scope.GetString().Equals("school"))
|
|
if (_scope.GetString().Equals("school"))
|
|
{
|
|
{
|
|
@@ -460,7 +464,9 @@ namespace TEAMModelOS.Controllers
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
{
|
|
{
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
|
|
|
+
|
|
|
|
+ sqlPrivate = $" and c.tmdid='{_tmdid}'";
|
|
|
|
+ code = $"LessonRecord";
|
|
tbname = "Teacher";
|
|
tbname = "Teacher";
|
|
List<string> ids = new List<string>();
|
|
List<string> ids = new List<string>();
|
|
ids.Add($"{_tmdid}");
|
|
ids.Add($"{_tmdid}");
|
|
@@ -495,7 +501,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
sqlShow = $" and (array_contains(c.show,'student') or array_contains(c.show,'all') {autoSql} ) ";
|
|
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)
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, continuationToken: continuationToken,
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, continuationToken: continuationToken,
|
|
requestOptions: new QueryRequestOptions() { MaxItemCount = pageCount, PartitionKey = new PartitionKey(code) }))
|
|
requestOptions: new QueryRequestOptions() { MaxItemCount = pageCount, PartitionKey = new PartitionKey(code) }))
|
|
@@ -599,7 +605,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
{
|
|
{
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
|
|
|
+ code = $"LessonRecord";
|
|
tbname = "Teacher";
|
|
tbname = "Teacher";
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -636,6 +642,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
string tbname = "";
|
|
string tbname = "";
|
|
string code = "";
|
|
string code = "";
|
|
|
|
+ string sqlPrivate = "";
|
|
if (_scope.GetString().Equals("school") )
|
|
if (_scope.GetString().Equals("school") )
|
|
{
|
|
{
|
|
if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
@@ -654,7 +661,8 @@ namespace TEAMModelOS.Controllers
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
if (!string.IsNullOrEmpty($"{_tmdid}"))
|
|
{
|
|
{
|
|
- code = $"LessonRecord-{_tmdid}";
|
|
|
|
|
|
+ sqlPrivate = $" and c.tmdid='{_tmdid}'";
|
|
|
|
+ code = $"LessonRecord";
|
|
tbname = "Teacher";
|
|
tbname = "Teacher";
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -690,9 +698,10 @@ namespace TEAMModelOS.Controllers
|
|
["today"] = true,
|
|
["today"] = true,
|
|
["periodId"] = $"{_periodId}",
|
|
["periodId"] = $"{_periodId}",
|
|
}.ToJsonString().ToObject<JsonElement>();
|
|
}.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 {
|
|
try {
|
|
var tmdids_excellent = excellentRcd.Select(x => x.tmdid);
|
|
var tmdids_excellent = excellentRcd.Select(x => x.tmdid);
|
|
var tmdids_doubleGreen = excellentRcd.Select(x => x.tmdid);
|
|
var tmdids_doubleGreen = excellentRcd.Select(x => x.tmdid);
|
|
@@ -739,13 +748,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();
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("select value(c) from c ");
|
|
sql.Append("select value(c) from c ");
|
|
Dictionary<string, object> dict = GetLessonCond(request);
|
|
Dictionary<string, object> dict = GetLessonCond(request);
|
|
AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
|
|
AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
|
|
List<LessonRecord> lessonRecords = new List<LessonRecord>();
|
|
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)
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition,
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition,
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|