|
@@ -297,5 +297,33 @@ namespace TEAMModelAPI.Controllers
|
|
|
return Ok(new { error=1,msg="课程不存在!"});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-classroom-list")]
|
|
|
+ [ApiToken(Auth = "9", Name = "获取物理教室列表信息", RW = "R", Limit = false)]
|
|
|
+ public async Task<IActionResult> GetClassroomList(JsonElement json)
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var (id, school) = HttpContext.GetApiTokenInfo();
|
|
|
+ json.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
+ json.TryGetProperty("subjectId", out JsonElement subjectId);
|
|
|
+ StringBuilder sql = new StringBuilder($"SELECT c.id,c.name,c.subject,c.period,c.scope,c.no,c.school FROM c where 1=1 ");
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{periodId}"))
|
|
|
+ {
|
|
|
+ sql.Append($" and c.period.id='{periodId}'");
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace($"{subjectId}"))
|
|
|
+ {
|
|
|
+ sql.Append($" and c.subject.id='{subjectId}'");
|
|
|
+ }
|
|
|
+ List<dynamic> courses = new List<dynamic>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<dynamic>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school}") }))
|
|
|
+ {
|
|
|
+ courses.Add(item);
|
|
|
+ }
|
|
|
+ return Ok(new { courses });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|