|
@@ -1114,6 +1114,103 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 通过学段获取学校班级、教室信息; 教师id获取课程信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-info-prdid")]
|
|
|
+ //[Authorize(Roles="IES")]
|
|
|
+ public async Task<IActionResult> GetInfoByPeriodId(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ string domain = HttpContext?.Request?.Host.Host;
|
|
|
+ if (domain.Equals("teammodelos.chinacloudsites.cn"))
|
|
|
+ {
|
|
|
+ domain = _option.HostName;
|
|
|
+ }
|
|
|
+ if (_option.Location.Equals("China"))
|
|
|
+ {
|
|
|
+ domain = _option.HostName;
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!jsonElement.TryGetProperty("id_token", out JsonElement id_token)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
|
|
|
+ jsonElement.TryGetProperty("periodId", out JsonElement _periodId);
|
|
|
+
|
|
|
+ var jwt = new JwtSecurityToken(id_token.GetString());
|
|
|
+ var tchId = jwt.Payload.Sub;
|
|
|
+
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ string periodId = null;
|
|
|
+ if (string.IsNullOrEmpty($"{_periodId}"))
|
|
|
+ {
|
|
|
+ School school_base = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{school_code}", new PartitionKey("Base"));
|
|
|
+ periodId = school_base.period[0].id;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取班级信息
|
|
|
+ List<object> school_Classes = new();
|
|
|
+ string classesSql = $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, c.graduate, ARRAY_LENGTH(c.students) AS studCount FROM c where c.graduate = 0 or IS_DEFINED(c.graduate) = false and c.periodId='{periodId}'";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: classesSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
|
|
|
+ {
|
|
|
+ var jsonc = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ foreach (var classeinfo in jsonc.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ school_Classes.Add(classeinfo.ToObject<object>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取教师的课程
|
|
|
+ List<object> school_Courses = new();
|
|
|
+ var query = $"SELECT value(c) FROM c JOIN A1 IN c.schedule where A1.teacherId='{tchId}' and c.period.id='{periodId}'";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code}") }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ school_Courses.Add(obj.ToObject<object>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取教室
|
|
|
+ List<Room> school_Rooms = new();
|
|
|
+ string roomSql = $"select value(c) from c where c.periodId = '{periodId}'";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Room>(queryText: roomSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{school_code}") }))
|
|
|
+ {
|
|
|
+ school_Rooms.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取学校行政班
|
|
|
+ List<GroupListDto> school_GroupList = new();
|
|
|
+ string glSql = $"select c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader ,c.froms ,c.joinLock from c";
|
|
|
+
|
|
|
+ string schoolglSql = $"{glSql} where c.periodId ='{periodId}'";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: schoolglSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{school_code}") }))
|
|
|
+ {
|
|
|
+ school_GroupList.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取个人行政班
|
|
|
+ List<GroupListDto> personal_GroupList = new();
|
|
|
+ string pglSql = $"{glSql} where c.creatorId='{tchId}'";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupListDto>(queryText: pglSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("GroupList") }))
|
|
|
+ {
|
|
|
+ personal_GroupList.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { status = 200, school_Classes, school_Courses, school_Rooms, school_GroupList, personal_GroupList });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/get-info-prdid()\n{ex.Message}\n{ex.StackTrace}\n{jsonElement.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest(new { status = 500 });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//課綱的model先記在下面,待式樣確定後再轉換
|
|
|
private List<SyllabusNode> CreateSyllabusTree(List<Syllabus> syllabuses)
|