|
@@ -1665,6 +1665,97 @@ namespace TEAMModelOS.Controllers.Both
|
|
|
return Ok();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 教师任教的课程
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "student")]
|
|
|
+ [HttpPost("student")]
|
|
|
+ public async Task<IActionResult> Student(JsonElement request) {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ (string student, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
|
+ string code = $"CourseTask-{school}";
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ switch (true)
|
|
|
+ {
|
|
|
+ //任教学校课程和个人课程
|
|
|
+ case bool when $"{grant_type}".Equals("teach", StringComparison.OrdinalIgnoreCase):
|
|
|
+ string sql = $"SELECT distinct value c FROM c join b in c.schedules where c.pk='CourseTask' and b.teacherId in() ";
|
|
|
+ List<KeyValuePair<string, CourseTask>> schoolTeacherTask = new List<KeyValuePair<string, CourseTask>>();
|
|
|
+ List<KeyValuePair<string, CourseTask>> schoolAssistantTask = new List<KeyValuePair<string, CourseTask>>();
|
|
|
+
|
|
|
+ List<KeyValuePair<string, CourseTask>> privateTeacherTask = new List<KeyValuePair<string, CourseTask>>();
|
|
|
+ List<KeyValuePair<string, CourseTask>> privateAssistantTask = new List<KeyValuePair<string, CourseTask>>();
|
|
|
+ List<CourseDto> schoolCourses = new List<CourseDto>();
|
|
|
+ List<CourseDto> teahcerCourses = new List<CourseDto>();
|
|
|
+ if (!string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ School schoolBase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ JsonElement _year = default, _semesterId = default, _periodId = default;
|
|
|
+ if (!request.TryGetProperty("periodId", out _periodId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("year", out _year))
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ if (!request.TryGetProperty("semesterId", out _semesterId))
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ var period = schoolBase.period.Find(x => x.id.Equals($"{_periodId}"));
|
|
|
+ //string date = SchoolService.GetOpensByStudyYearAndSemester(period.semesters, int.Parse($"{_year}"), $"{_semesterId}");
|
|
|
+ sql = $"{sql} and c.year={_year} and c.semesterId='{_semesterId}'";
|
|
|
+ HashSet<string> courseIds = new HashSet<string>();
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<CourseTask>(sql, $"CourseTask-{school}");
|
|
|
+ if (resultSchool.list.IsNotEmpty())
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ if (courseIds.Any())
|
|
|
+ {
|
|
|
+ string sqlCourse = $"select value c from c where c.id in ({string.Join(",", courseIds.Select(b => $"'{b}'"))})";
|
|
|
+ var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<CourseBase>(sqlCourse, $"CourseBase-{school}");
|
|
|
+ if (result.list.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var item in result.list)
|
|
|
+ {
|
|
|
+ List<CourseTaskDto> courseTaskDtos = new List<CourseTaskDto>();
|
|
|
+ var teacher = schoolTeacherTask.Where(x => x.Key.Equals(item.id)).Select(z => new CourseTaskDto { courseTask=z.Value, type="teacher" });
|
|
|
+ if (teacher.Any())
|
|
|
+ {
|
|
|
+ courseTaskDtos.AddRange(teacher.ToList());
|
|
|
+ }
|
|
|
+ var assistant = schoolAssistantTask.Where(x => x.Key.Equals(item.id)).Select(z => new CourseTaskDto { courseTask=z.Value, type="assistant" });
|
|
|
+ if (assistant.Any())
|
|
|
+ {
|
|
|
+ courseTaskDtos.AddRange(assistant.ToList());
|
|
|
+ }
|
|
|
+ schoolCourses.Add(new CourseDto { courseBase=item, courseTasks=courseTaskDtos });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<CourseTask>(sql, $"CourseTask");
|
|
|
+ if (resultTeacher.list.IsNotEmpty())
|
|
|
+ {
|
|
|
+ HashSet<string> courseIds = new HashSet<string>();
|
|
|
+
|
|
|
+ }
|
|
|
+ return Ok(new { teahcerCourses, schoolCourses });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{_option.Location},course-base\teacher{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ return BadRequest(new { ex.Message });
|
|
|
+ }
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 教师任教的课程
|
|
|
/// </summary>
|
|
@@ -1679,9 +1770,7 @@ namespace TEAMModelOS.Controllers.Both
|
|
|
try
|
|
|
{
|
|
|
(string tmdid, _, _, string school) = HttpContext.GetAuthTokenInfo();
|
|
|
- tmdid="1528783301";
|
|
|
if (!request.TryGetProperty("grant_type", out JsonElement grant_type)) return BadRequest();
|
|
|
- if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
|
string code = $"CourseTask-{school}";
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
switch (true)
|
|
@@ -1800,10 +1889,8 @@ namespace TEAMModelOS.Controllers.Both
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//个人,
|
|
|
//学校,
|
|
|
-
|
|
|
//助教,学校。
|
|
|
//助教,个人。
|
|
|
return Ok(new { teahcerCourses , schoolCourses});
|
|
@@ -1817,8 +1904,6 @@ namespace TEAMModelOS.Controllers.Both
|
|
|
}
|
|
|
return Ok();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public class CourseDto {
|