|
@@ -530,10 +530,12 @@ namespace TEAMModelOS.Controllers
|
|
|
public static async Task<ResponseData<dynamic>> GetTeacherTeach(AzureCosmosFactory _azureCosmos, DingDing _dingDing, string bizId, string school, JsonElement json) {
|
|
|
|
|
|
try {
|
|
|
- if (!json.TryGetProperty("tmdid", out JsonElement _tmdid)) {
|
|
|
+ if (json.TryGetProperty("tmdid", out JsonElement _tmdid))
|
|
|
+ {
|
|
|
json.TryGetProperty("period", out JsonElement _period);
|
|
|
List<OCourse> courses = new List<OCourse>();
|
|
|
var query = $"SELECT distinct c.code,c.id,c.no,c.name,c.period,c.subject,c.scope ,c['desc'] ,c.creatorId , c.year ,s as schedule FROM c join s in c.schedule where s.teacherId='{_tmdid}' ";
|
|
|
+ HashSet<string> classIds = new HashSet<string>();
|
|
|
if (!string.IsNullOrWhiteSpace($"{_period}"))
|
|
|
{
|
|
|
query = $"{query} and c.period.id ='{_period}'";
|
|
@@ -541,11 +543,25 @@ namespace TEAMModelOS.Controllers
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<OCourse>(queryText: query,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school}") }))
|
|
|
{
|
|
|
+ if (!string.IsNullOrWhiteSpace(item.schedule?.stulist)) {
|
|
|
+ classIds.Add(item.schedule?.stulist);
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(item.schedule?.classId))
|
|
|
+ {
|
|
|
+ classIds.Add(item.schedule?.classId);
|
|
|
+ }
|
|
|
courses.Add(item);
|
|
|
}
|
|
|
- var group = courses.GroupBy(x => x.id).Select(g => new { key = g.Key, list=g.ToList() });
|
|
|
+ List<OGroupList> groupLists = new List<OGroupList>();
|
|
|
+ if (classIds.Any()) {
|
|
|
+ var tempGroupLists= await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, classIds.ToList(), school);
|
|
|
+ groupLists = tempGroupLists.Select(x => new OGroupList { id = x.id, name = x.name, type = x.type, periodId = x.periodId, school = x.school, scope = x.scope, year = x.year }).ToList();
|
|
|
+ }
|
|
|
+
|
|
|
+ var group = courses.GroupBy(x => x.id).Select(g => new { key = g.Key, list = g.ToList() });
|
|
|
List<Course> coursesR = new List<Course>();
|
|
|
- group.ToList().ForEach(x => {
|
|
|
+ group.ToList().ForEach(x =>
|
|
|
+ {
|
|
|
var first = x.list.First();
|
|
|
coursesR.Add(new Course
|
|
|
{
|
|
@@ -559,12 +575,30 @@ namespace TEAMModelOS.Controllers
|
|
|
creatorId = first.creatorId,
|
|
|
year = first.year,
|
|
|
schedule = x.list.Select(x => x.schedule).ToList()
|
|
|
- }); ;
|
|
|
+ });
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
+ return new ResponseData<dynamic>() {
|
|
|
+ code=RespondCode.Ok,data=new {
|
|
|
+
|
|
|
+ courses = coursesR.Select(x => new {
|
|
|
+ x.id,
|
|
|
+ school=school,
|
|
|
+ x.name,
|
|
|
+ x.no,
|
|
|
+ x.period,
|
|
|
+ x.subject,
|
|
|
+ x.desc,
|
|
|
+ x.creatorId,
|
|
|
+ x.year,
|
|
|
+ x.schedule
|
|
|
+ }) ,
|
|
|
+ groupLists
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return new ResponseData<dynamic>() { code = RespondCode.ParamsError, msg = "参数错误" };
|
|
|
}
|
|
|
- return null;
|
|
|
} catch (Exception ex) {
|
|
|
await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetTeacherTeach() 参数:bizId:{bizId},school:{school},json:{json.ToJsonString()} \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return new ResponseData<dynamic>() { code = RespondCode.Error, msg = "服务器错误" };
|