|
@@ -367,7 +367,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
if (!request.TryGetProperty("scope", out JsonElement _scope)) return BadRequest();
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
- sql.Append("select value(c) from c ");
|
|
|
+ sql.Append("select distinct value(c) from c ");
|
|
|
int pageCount = 10;
|
|
|
Dictionary<string, object> dict = GetLessonCond(request);
|
|
|
if (request.TryGetProperty("pageCount", out JsonElement _pageCount))
|
|
@@ -398,6 +398,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string tbname = "";
|
|
|
string code = "";
|
|
|
string school = null;
|
|
|
+ List<string> autoTch = new List<string>();
|
|
|
if (_scope.GetString().Equals("school"))
|
|
|
{
|
|
|
if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
@@ -406,6 +407,28 @@ namespace TEAMModelOS.Controllers
|
|
|
code = $"LessonRecord-{_school}";
|
|
|
tbname = "School";
|
|
|
school = $"{_school}";
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ //只查询某个老师的课例
|
|
|
+ if (request.TryGetProperty("tmdid", out JsonElement tmdid) && !string.IsNullOrWhiteSpace($"{tmdid}"))
|
|
|
+ {
|
|
|
+ ids.Add($"{tmdid}");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ string sqltch = "select distinct value(c.id) from c ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
|
|
|
+ .GetItemQueryIterator<string>(queryText: sqltch, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{_school}") }))
|
|
|
+ {
|
|
|
+ ids.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ids.Any()) {
|
|
|
+ string sqlTechbase = $"select distinct value(c.id) from c where c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))}) and (array_contains(c.lessonShow,'student') or array_contains(c.lessonShow,'all')) ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
+ .GetItemQueryIterator<string>(queryText: sqlTechbase, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ {
|
|
|
+ autoTch.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -419,6 +442,17 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
code = $"LessonRecord-{_tmdid}";
|
|
|
tbname = "Teacher";
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ ids.Add($"{_tmdid}");
|
|
|
+ if (ids.Any())
|
|
|
+ {
|
|
|
+ string sqlTechbase = $"select distinct value(c.id) from c where c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))}) and (array_contains(c.lessonShow,'student') or array_contains(c.lessonShow,'all')) ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
+ .GetItemQueryIterator<string>(queryText: sqlTechbase, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ {
|
|
|
+ autoTch.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -433,9 +467,14 @@ namespace TEAMModelOS.Controllers
|
|
|
try
|
|
|
{
|
|
|
string sqlShow = "";
|
|
|
- //if (roles.Count == 1 && roles.Contains("student") ) {
|
|
|
- // sqlShow = " and (array_contains(c.show,'student') or array_contains(c.show,'all')) ";
|
|
|
- //}
|
|
|
+ if (roles.Count == 1 && roles.Contains("student"))
|
|
|
+ {
|
|
|
+ string autoSql = "";
|
|
|
+ if (autoTch.Any()) {
|
|
|
+ autoSql = $" or c.tmdid in ({string.Join(",",autoTch.Select(x=>$"'{x}'"))})";
|
|
|
+ }
|
|
|
+ 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 ) {sqlShow} and ");
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
|
|
|
.GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, continuationToken: continuationToken,
|