Browse Source

決賽名單 追加jointGroup所屬班級流水號

jeff 7 tháng trước cách đây
mục cha
commit
b22a6a5dec

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Teacher/JointEvent.cs

@@ -91,6 +91,7 @@ namespace TEAMModelOS.SDK.Models
         {
             public string id { get; set; }
             public string name { get; set; }
+            public string no { get; set; } //系統安排的流水號 ※各組(jointGroup)的班級從1開始++ 決賽才記入
         }
     }
     /// <summary>

+ 16 - 3
TEAMModelOS.SDK/Models/Service/JointService.cs

@@ -416,6 +416,7 @@ namespace TEAMModelOS.SDK.Models.Service
             //5. 決賽課程生成
             ///生成資料製作
             List<JointEventGroupDb> jointCourseCreates = new List<JointEventGroupDb>(); //要生成的老師課程名單
+            Dictionary<string, int> jointGroupClassCntDic = new Dictionary<string, int>(); //各jointGroup的班級數目 => 用來做個決賽班級的流水號
             foreach (JointEventGroupDb jointEventCourseRow in jointEventCourse)
             {
                 foreach (JointEventGroupBase.JointEventGroupCourse course in jointEventCourseRow.courseLists)
@@ -430,6 +431,10 @@ namespace TEAMModelOS.SDK.Models.Service
                             JointEventGroupDb jointCourseCreateRow = jointCourseCreates.Where(c => c.jointEventId.Equals(jointEventCourseRow.jointEventId) && c.jointGroupId.Equals(jointEventCourseRow.jointGroupId) && c.creatorId.Equals(jointEventCourseRow.creatorId)).FirstOrDefault();
                             if (jointCourseCreateRow == null)
                             {
+                                ///各jointGroup的班級數目計算
+                                if (jointGroupClassCntDic.ContainsKey(jointEventCourseRow.jointGroupId)) jointGroupClassCntDic[jointEventCourseRow.jointGroupId]++;
+                                else jointGroupClassCntDic.Add(jointEventCourseRow.jointGroupId, 1);
+                                ///DB 老師決賽document
                                 JointEventGroupDb finalEventCourse = new JointEventGroupDb();
                                 finalEventCourse.jointEventId = jointEventCourseRow.jointEventId;
                                 finalEventCourse.jointGroupId = jointEventCourseRow.jointGroupId;
@@ -448,7 +453,7 @@ namespace TEAMModelOS.SDK.Models.Service
                                     courseId = courseId,
                                     courseName = courseName,
                                     groupLists = new List<JointEventGroupBase.JointEventGroupCourseGroup>() {
-                                        new() { id = group.id, name = group.name }
+                                        new() { id = group.id, name = group.name, no = jointGroupClassCntDic[jointEventCourseRow.jointGroupId].ToString() }
                                     }
                                 });
                                 finalEventCourse.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
@@ -459,13 +464,17 @@ namespace TEAMModelOS.SDK.Models.Service
                                 JointEventGroupBase.JointEventGroupCourse courseRowNow = jointCourseCreateRow.courseLists.Where(c => c.courseId.Equals(courseId)).FirstOrDefault();
                                 if (courseRowNow == null)
                                 {
+                                    ///各jointGroup的班級數目計算
+                                    if (jointGroupClassCntDic.ContainsKey(jointEventCourseRow.jointGroupId)) jointGroupClassCntDic[jointEventCourseRow.jointGroupId]++;
+                                    else jointGroupClassCntDic.Add(jointEventCourseRow.jointGroupId, 1);
+                                    ///DB 老師決賽課程資料
                                     jointCourseCreateRow.courseLists.Add(
                                         new JointEventGroupBase.JointEventGroupCourse
                                         {
                                             courseId = courseId,
                                             courseName = courseName,
                                             groupLists = new List<JointEventGroupBase.JointEventGroupCourseGroup>() {
-                                                            new() { id = group.id, name = group.name }
+                                                            new() { id = group.id, name = group.name, no = jointGroupClassCntDic[jointEventCourseRow.jointGroupId].ToString() }
                                             }
                                         }
                                     );
@@ -475,8 +484,12 @@ namespace TEAMModelOS.SDK.Models.Service
                                     JointEventGroupBase.JointEventGroupCourseGroup groupRowNow = courseRowNow.groupLists.Where(g => g.id.Equals(group.id)).FirstOrDefault();
                                     if (groupRowNow == null)
                                     {
+                                        ///各jointGroup的班級數目計算
+                                        if (jointGroupClassCntDic.ContainsKey(jointEventCourseRow.jointGroupId)) jointGroupClassCntDic[jointEventCourseRow.jointGroupId]++;
+                                        else jointGroupClassCntDic.Add(jointEventCourseRow.jointGroupId, 1);
+                                        ///DB 老師決賽班級資料
                                         courseRowNow.groupLists.Add(
-                                            new() { id = group.id, name = group.name }
+                                            new() { id = group.id, name = group.name, no = jointGroupClassCntDic[jointEventCourseRow.jointGroupId].ToString() }
                                         );
                                     }
                                 }

+ 1 - 0
TEAMModelOS/Controllers/Teacher/JointEventController.cs

@@ -1763,6 +1763,7 @@ namespace TEAMModelOS.Controllers.Common
             {
                 public string id { get; set; }
                 public string name { get; set; }
+                public string no { get; set; } //jointGroup所屬班級流水號
                 public int stuNum { get; set; }
                 public bool goFinal { get; set; } //是否可參加決賽
                 public List<object> schedule { get; set; } = new List<object>(); //已完成的行程