Browse Source

CourseManagement調整移到另分支,還原變更

jeff 4 năm trước cách đây
mục cha
commit
2457a8eca8

+ 1 - 28
TEAMModelOS.SDK/Models/Cosmos/School/Class.cs

@@ -17,7 +17,6 @@ namespace TEAMModelOS.SDK.Models
             pk = "Class";
             teacher = new Teachers();
             students = new List<StudentSimple>();
-            courses = new List<coursesInClass>();
         }
         /// <summary>
         /// 教室编号
@@ -33,7 +32,6 @@ namespace TEAMModelOS.SDK.Models
         public string sn { get; set; }
 
         public List<StudentSimple> students { get; set; }
-        public List<coursesInClass> courses { get; set; }
         /// <summary>
         /// TBL IRS 类型区分
         /// </summary>
@@ -65,29 +63,4 @@ public class StudentSimple
 
     public string groupId { get; set; }
     public string groupName { get; set; }
-}
-
-//[JEFF] 指定某班級某課程由某位老師授課時用欄位
-/// <summary>
-/// 該班級排定的課程
-/// </summary>
-public class coursesInClass
-{
-    public courseAtcoursesInClass course { get; set; } //課程資訊
-    public List<Teachers> teachers { get; set; } //老師資訊(複數)
-}
-
-public class courseAtcoursesInClass
-{
-    public string id { get; set; } //課程ID
-    public string name { get; set; } //課程名稱
-    public string notice { get; set; } //公告
-}
-
-public class Teachers
-{
-    public string id { get; set; }
-    public string name { get; set; }
-}
-////[JEFF] 指定某班級某課程由某位老師授課時用欄位
-
+}

+ 0 - 11
TEAMModelOS.SDK/Models/Cosmos/School/Course.cs

@@ -17,7 +17,6 @@ namespace TEAMModelOS.SDK.Models
             subject = new SubjectSimple();
             period = new PeriodSimple();
             teachers = new List<Teachers>();
-            classes = new List<classesInCourse>();
         }        
         /// <summary>
         /// 课程名称
@@ -45,7 +44,6 @@ namespace TEAMModelOS.SDK.Models
         /// 任课教师范围
         /// </summary>
         public List<Teachers> teachers { get; set; }
-        public List<classesInCourse> classes { get; set; }
         public string scope { get; set; }
         public string notice { get; set; }
 
@@ -67,13 +65,4 @@ namespace TEAMModelOS.SDK.Models
         public string id { get; set; }
         public string name { get; set; }
     }
-
-    //[JEFF] 指定某班級某課程由某位老師授課時用欄位
-    public class classesInCourse
-    {
-        public string id { get; set; } //班級ID
-        public string name { get; set; } //班級名稱
-        public List<Teachers> teachers { get; set; } //老師資訊(複數)
-    }
-    ////[JEFF] 指定某班級某課程由某位老師授課時用欄位
 }

+ 0 - 4
TEAMModelOS/ClientApp/src/view/newcourse/NewCoursePlan.vue

@@ -320,8 +320,6 @@
             saveCusPlan() {
                 this.isLoading = true
                 this.classListShow[this.curClassIndex].cusSetting.code = this.$store.state.userInfo.schoolCode
-                console.log('this.classListShow[this.curClassIndex].cusSetting:');
-                console.log(this.classListShow[this.curClassIndex].cusSetting);
                 this.$api.courseMgmt.upsertPlanDto(this.classListShow[this.curClassIndex].cusSetting).then(
                     (res) => {
                         if (!res.error) {
@@ -419,8 +417,6 @@
                     }
                     this.$api.courseMgmt.findPlan(requestData).then(
                         (res) => {
-                            console.log('res:');
-                            console.log(res);
                             if (res.error) {
                                 this.$Message.error(res.v)
                             } else {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 666 - 672
TEAMModelOS/ClientApp/src/view/student-account/Index.vue


+ 0 - 5
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -252,11 +252,6 @@ namespace TEAMModelOS.Controllers.Client
                 }
 
                 List<object> courses = new List<object>(); //老師被安排的課程列表
-
-
-
-
-                
                 var query = $"SELECT c.id, c.name, c.teacher, cc.course, c.scope FROM c JOIN cc IN c.courses JOIN cct IN cc.teachers WHERE cct.id = '{id}'";
                 await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{school_code}") }))
                 {

+ 14 - 40
TEAMModelOS/Controllers/School/ClassRoomController.cs

@@ -124,7 +124,6 @@ namespace TEAMModelOS.Controllers
                             }
                             classroom.students = studentSimples;
 
-                            //[Jeff] 老師個人課程有系統班級時的更新程序 ※此架構已廢除?個人課程已無法加入系統班級?
                             List<TeacherCourse> course = new List<TeacherCourse>();
                             await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.classes where A0.id = '{classroom.id}'"))
                             {
@@ -163,53 +162,28 @@ namespace TEAMModelOS.Controllers
                                 }
                             }
                             //string code = classroom.code.Substring(classroom.pk.Length + 1);
-
-                            //[Jeff] 若Course中的classes.id相同,name不同 => 更新教室名稱
-                            List<string> updCourseIdList = new List<string>();
-                            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: $"SELECT c.id FROM c JOIN cc IN c.classes WHERE cc.id = '{classroom.id}' AND cc.name != '{classroom.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Course-{school_code}") }))
+                            //[Jeff] CourseManagement表廢除 刪除預定:以下CourseManagement更新程序
+                            var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classroom.id, new PartitionKey($"CourseManagement-{school_code}"));
+                            if (sresponse.Status == 200)
                             {
-                                using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                                foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                                using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
+                                CourseManagement classroom1 = json.ToObject<CourseManagement>();
+                                if (!classroom1.name.Equals(classroom.name))
                                 {
-                                    updCourseIdList.Add(obj.GetProperty("id").GetString());
+                                    classroom1.name = classroom.name;
+                                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom1.code}"));
                                 }
-                            }
-                            foreach (string updCourseId in updCourseIdList)
-                            {
-                                var cresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(updCourseId, new PartitionKey($"Course-{school_code}"));
-                                if (cresponse.Status == 200)
+                                if (!string.IsNullOrEmpty(classroom1.teacher.id) && !string.IsNullOrEmpty(classroom.teacher.id) && !classroom1.teacher.id.Equals(classroom.teacher.id))
                                 {
-                                    using var json = await JsonDocument.ParseAsync(cresponse.ContentStream);
-                                    Course updCourse = json.ToObject<Course>();
-                                    classesInCourse updClass = (classesInCourse)updCourse.classes.Where(c => c.id == classroom.id);
-                                    updClass.name = classroom.name;
-                                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(updCourse, updCourse.id, new PartitionKey($"Course-{school_code}"));
+                                    classroom1.teacher.name = classroom.teacher.name;
+                                    classroom1.teacher.id = classroom.teacher.id;
+                                    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom1.code}"));
                                 }
-                                classroom = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom, classroom.id, new PartitionKey($"Class-{school_code}"));
                             }
-                            ////[Jeff] 若Course中的classes.id相同,name不同 => 更新教室名稱
-
-                            //[Jeff] CourseManagement表廢除
-                            //var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classroom.id, new PartitionKey($"CourseManagement-{school_code}"));
-                            //if (sresponse.Status == 200)
-                            //{
-                            //    using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
-                            //    CourseManagement classroom1 = json.ToObject<CourseManagement>();
-                            //    if (!classroom1.name.Equals(classroom.name))
-                            //    {
-                            //        classroom1.name = classroom.name;
-                            //        await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom1.code}"));
-                            //    }
-                            //    if (!string.IsNullOrEmpty(classroom1.teacher.id) && !string.IsNullOrEmpty(classroom.teacher.id) && !classroom1.teacher.id.Equals(classroom.teacher.id))
-                            //    {
-                            //        classroom1.teacher.name = classroom.teacher.name;
-                            //        classroom1.teacher.id = classroom.teacher.id;
-                            //        await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom1.code}"));
-                            //    }
-                            //}
-                            ////[Jeff] CourseManagement表廢除 
+                            ////[Jeff] CourseManagement表廢除 刪除預定:以下CourseManagement更新程序
                             classroom = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom, classroom.id, new PartitionKey($"Class-{school_code}"));
                         }
+
                     }
 
                 }

+ 25 - 63
TEAMModelOS/Controllers/School/CourseController.cs

@@ -224,7 +224,8 @@ namespace TEAMModelOS.Controllers
                 sql.Append("select value(c) from c ");
                 Dictionary<string, object> dict = new Dictionary<string, object>();
                 //处理id
-                if (request.ids.IsNotEmpty()) {
+                if (request.ids.IsNotEmpty())
+                {
                     dict.Add("id", request.ids.ToArray());
                 }
                 string school_code = request.code;
@@ -312,51 +313,33 @@ namespace TEAMModelOS.Controllers
         [ProducesDefaultResponseType]
         //[AuthToken(Roles = "Teacher")]
         [HttpPost("upsert-management")]
-        public async Task<IActionResult> upsertCourseManagement(JsonElement requert)
+        public async Task<IActionResult> upsertCourseManagement(CourseManagement requert)
         {
             try
             {
                 CourseManagement course = new CourseManagement();
                 //course = room.ToObject<CourseManagement>();
                 var client = _azureCosmos.GetCosmosClient();
-                //string code = requert.code;
-                requert.TryGetProperty("code", out JsonElement schoolCodeJson);
-                
-
-                //[Jeff] Class表追加課程安排 (Class.courses)
-
-                //[Jeff] Course表追加課程安排 (Course.classes)
-                if (requert.TryGetProperty("courses", out JsonElement coursesJson))
-                {
-                    foreach (var courseInfo in coursesJson.EnumerateArray())
-                    {
-                        //var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
-                    }
-                        
-                }
-
-
-                //[Jeff] CourseManagement表廢除
-                //requert.code = "CourseManagement-" + requert.code;
+                string code = requert.code;
+                requert.code = "CourseManagement-" + requert.code;
                 /*                if (requert.scope.Equals) { 
 
                                 }*/
-                //var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
-                //if (response.Status == 200)
-                //{
-                //    /*using var json = await JsonDocument.ParseAsync(response.ContentStream);
-                //    CourseManagement courseManagement = json.ToObject<CourseManagement>();
-                //    courseManagement.courses = requert.courses;*/
-                //    //return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
-                //    course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(requert,requert.id, new PartitionKey($"CourseManagement-{code}"));
+                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(requert.id, new PartitionKey($"CourseManagement-{code}"));
+                if (response.Status == 200)
+                {
+/*                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    CourseManagement courseManagement = json.ToObject<CourseManagement>();
+                    courseManagement.courses = requert.courses;*/
+                    //return Ok(new { error = ResponseCode.DATA_EXIST, V = "课程编码已经存在!" });
+                    course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(requert, requert.id, new PartitionKey($"CourseManagement-{code}"));
 
-                //}
-                //else
-                //{
-                //    course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(requert, new PartitionKey($"CourseManagement-{code}"));
+                }
+                else
+                {
+                    course = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").CreateItemAsync(requert, new PartitionKey($"CourseManagement-{code}"));
 
-                //}
-                ////[Jeff] CourseManagement表廢除
+                }
 
 
                 return Ok(new { course });
@@ -380,7 +363,7 @@ namespace TEAMModelOS.Controllers
         public async Task<IActionResult> FindManagement(JsonElement requert)
         {
             //if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
-            if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest(); //school_code
+            if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
             var client = _azureCosmos.GetCosmosClient();
             List<object> courses = new List<object>();
             StringBuilder sql = new StringBuilder();
@@ -397,38 +380,17 @@ namespace TEAMModelOS.Controllers
                 dict.Remove("code");
             }
             AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-            //[Jeff] 取得Class表中課程安排 (Class.courses)
-            if (dict.TryGetValue("id", out object classId)) {
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classId.ToString(), new PartitionKey($"Class-{code}"));
-                if (response.Status == 200)
+            await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{code}") }))
+            {
+                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
-                    dynamic courseResult = new ExpandoObject();
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
-                    courseResult.id = json.RootElement.GetProperty("id").GetString();
-                    courseResult.courses = new List<coursesInClass>();
-                    if (json.RootElement.TryGetProperty("courses", out JsonElement coursesJobj))
+                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                     {
-                        courseResult.courses = coursesJobj.ToObject<object>();
+                        courses.Add(obj.ToObject<object>());
                     }
-                    courses.Add(courseResult);
                 }
             }
-            ////[Jeff] 取得Class表中課程安排 (Class.courses)
-
-            //[Jeff] CourseManagement表廢除
-            //await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CourseManagement-{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())
-            //        {
-            //            courses.Add(obj.ToObject<object>());
-            //        }
-            //    }
-            //}
-            ////[Jeff] CourseManagement表廢除
-
             /* List<object> courses = new List<object>();
              var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(id.ToString(), new PartitionKey($"CourseManagement-{code}"));
              if (response.Status == 200)