소스 검색

Merge branch 'develop-rc' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop-rc

OnePsycho 3 년 전
부모
커밋
a6ca23d786

+ 100 - 71
TEAMModelBI/Controllers/OpenApi/CourseController.cs

@@ -27,7 +27,7 @@ using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Service;
 using System.ComponentModel.DataAnnotations;
 
-namespace TEAMModelAPI.Controllers
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -120,8 +120,8 @@ namespace TEAMModelAPI.Controllers
             var period = data.period.Find(x => x.id.Equals($"{_periodId}"));
             if (period != null)
             {
-              
-                return Ok(new { period.subjects, period.timetable, period.grades, period.majors , weekDays });
+
+                return Ok(new { period.subjects, period.timetable, period.grades, period.majors, weekDays });
             }
             else
             {
@@ -138,22 +138,25 @@ namespace TEAMModelAPI.Controllers
             var (id, school) = HttpContext.GetApiTokenInfo();
             List<CourseDto> courseDtos = json.courses;
             List<Dictionary<string, string>> errorData = new List<Dictionary<string, string>>();
-            List<Course> courses = new List<Course>() ;
-             
+            List<Course> courses = new List<Course>();
+
             School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
-            foreach (var courseDto in courseDtos) {
+            foreach (var courseDto in courseDtos)
+            {
                 var period = data.period.Find(x => x.id.Equals($"{courseDto.periodId}"));
                 if (period != null)
                 {
                     //同名学科
                     var subject = period.subjects.Find(x => x.id.Equals($"{courseDto.subjectId}"));
-                    if (subject == null) {
+                    if (subject == null)
+                    {
                         subject = period.subjects.Find(x => x.name.Equals($"{courseDto.subjectName}"));
                     }
-                    if (subject == null) {
+                    if (subject == null)
+                    {
                         subject = new Subject { id = courseDto.subjectId, name = subject.name, type = 1 };
                         period.subjects.Add(subject);
-                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(data, data.id, new PartitionKey("Base"));
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(data, data.id, new PartitionKey("Base"));
                     }
                     Course course = null;
                     if (string.IsNullOrWhiteSpace(courseDto?.id))
@@ -216,17 +219,19 @@ namespace TEAMModelAPI.Controllers
                     //return Ok(new { error = 2, msg = "学段不存在!" });
                 }
             }
-            
-            return Ok(new { courses = courses ,errorData});
+
+            return Ok(new { courses, errorData });
         }
         //[Required(ErrorMessage = "{0} 课程的科目id必须填写"), RegularExpression(@"[0-9a-zA-Z]{8}(-[0-9a-zA-Z]{4}){3}-[0-9a-zA-Z]{12}",ErrorMessage ="科目的uuid格式错误!")]
 
-        public class ImportCourseDto {
+        public class ImportCourseDto
+        {
             public List<ImportCourse> courses { get; set; } = new List<ImportCourse>();
         }
 
 
-        public class ImportCourse {
+        public class ImportCourse
+        {
             [Required(ErrorMessage = "课程id  必须设置"), RegularExpression(@"[0-9a-zA-Z]{8}(-[0-9a-zA-Z]{4}){3}-[0-9a-zA-Z]{12}", ErrorMessage = "科目的uuid格式错误!")]
             public string courseId { get; set; }
             [Required(ErrorMessage = "课程名称  必须设置")]
@@ -238,10 +243,10 @@ namespace TEAMModelAPI.Controllers
             [Required(ErrorMessage = "课程学段id  必须设置"), RegularExpression(@"[0-9a-zA-Z]{8}(-[0-9a-zA-Z]{4}){3}-[0-9a-zA-Z]{12}", ErrorMessage = "学段的uuid格式错误!")]
             public string periodId { get; set; }
             public List<Schedule> schedules { get; set; }
-        
+
         }
 
-        
+
         [ProducesDefaultResponseType]
         [HttpPost("upsert-course-schedule")]
         [ApiToken(Auth = "1305", Name = "更新课程的排课信息", RWN = "W", Limit = false)]
@@ -249,32 +254,37 @@ namespace TEAMModelAPI.Controllers
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             List<ImportCourse> importCourses = json.courses;
-            HashSet<string> courseIds= importCourses .Select(x => x.courseId).ToHashSet();
+            HashSet<string> courseIds = importCourses.Select(x => x.courseId).ToHashSet();
             if (courseIds.Count < 1) { return Ok(new { error = 1, msg = "课程参数错误!" }); }
 
             //string sql = $"select value(c) from c  where c.id in({string.Join(",",courseIds.Select(x=>$"'{x}'"))})";
             string sql = $"select value(c) from c ";//直接获取全校的课程
             List<Course> courses = new List<Course>();
             await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
-                .GetItemQueryIterator<Course>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Course-{school}") })) {
+                .GetItemQueryIterator<Course>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Course-{school}") }))
+            {
                 courses.Add(item);
             }
             List<Subject> addSubjects = new List<Subject>();
             School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
             //不存在的课程,可以被直接创建
             var unexistCourseIds = courseIds.Except(courses.Select(x => x.id));
-            foreach (var item in unexistCourseIds) {
-                ImportCourse importCourse= importCourses.Find(x => x.courseId.Equals(item));
-                if (importCourse != null) {
-                    Period period= data.period.Find(x => x.id.Equals(importCourse.periodId));
-                    if (period != null) {
+            foreach (var item in unexistCourseIds)
+            {
+                ImportCourse importCourse = importCourses.Find(x => x.courseId.Equals(item));
+                if (importCourse != null)
+                {
+                    Period period = data.period.Find(x => x.id.Equals(importCourse.periodId));
+                    if (period != null)
+                    {
                         //同名学科
                         var subject = period.subjects.Find(x => x.id.Equals($"{importCourse.subjectId}"));
                         if (subject == null)
                         {
                             subject = period.subjects.Find(x => x.name.Equals($"{importCourse.subjectName}"));
                         }
-                        if (subject == null) {
+                        if (subject == null)
+                        {
                             subject = new Subject { id = importCourse.subjectId, name = importCourse.subjectName, type = 1 };
                             period.subjects.Add(subject);
                             addSubjects.Add(subject);
@@ -301,15 +311,17 @@ namespace TEAMModelAPI.Controllers
             //importCourses =importCourses .Where(x => !unexistCourseIds .Contains(x.courseId));
 
             //排查 课程学段,课程排课作息,课程排课的星期几是否准确
-            List<ScheduleTimeDto> import_schedules_hastime = new List<ScheduleTimeDto>() ;
+            List<ScheduleTimeDto> import_schedules_hastime = new List<ScheduleTimeDto>();
             List<ScheduleNoTimeDto> import_schedules_nottime = new List<ScheduleNoTimeDto>();
             //保存没有选用名单的排课。
-            List<Schedule> schedules_noList= new List<Schedule>() ;
+            List<Schedule> schedules_noList = new List<Schedule>();
             List<ScheduleTimeDto> weeksError = new List<ScheduleTimeDto>();
 
 
-            importCourses .ToList().ForEach(x => {
-                x.schedules.ForEach(z => {
+            importCourses.ToList().ForEach(x =>
+            {
+                x.schedules.ForEach(z =>
+                {
 
                     if (!string.IsNullOrWhiteSpace(z.classId) || !string.IsNullOrWhiteSpace(z.stulist))
                     {
@@ -353,7 +365,8 @@ namespace TEAMModelAPI.Controllers
 
                                 });
                             }
-                            else {
+                            else
+                            {
                                 //允许导入没有排课时间表的课程。
                                 import_schedules_nottime.Add(new ScheduleNoTimeDto
                                 {
@@ -367,7 +380,8 @@ namespace TEAMModelAPI.Controllers
                         }
                         else { schedules_noList.Add(z); }
                     }
-                    else {
+                    else
+                    {
                         schedules_noList.Add(z);
                     }
                 });
@@ -384,17 +398,19 @@ namespace TEAMModelAPI.Controllers
             groupIdWarning = check_groupId.Where(x => x.list.Count > 1).SelectMany(x => x.list);
             //import_schedules.RemoveAll(x => import_groupIdConfuse.Contains(x));
             //物理教室自检
-            var check_roomIds = import_schedules_hastime.Where(r=>!string.IsNullOrWhiteSpace(r.keyRoomIds)).GroupBy(x => x.keyRoomIds).Select(g => new { key = g.Key, list = g.ToList() });
+            var check_roomIds = import_schedules_hastime.Where(r => !string.IsNullOrWhiteSpace(r.keyRoomIds)).GroupBy(x => x.keyRoomIds).Select(g => new { key = g.Key, list = g.ToList() });
             IEnumerable<ScheduleTimeDto> roomIdsWarning = new List<ScheduleTimeDto>();
             roomIdsWarning = check_roomIds.Where(x => x.list.Count > 1).SelectMany(x => x.list);
             //import_schedules.RemoveAll(x => import_roomIdsConfuse.Contains(x));
 
-          
+
             //打散数据库已经有的排课信息
             List<ScheduleTimeDto> database_schedules = new List<ScheduleTimeDto>();
-            courses.ForEach(x => {
-                x.schedule.ForEach(z => {
-                    if (!string.IsNullOrWhiteSpace(z.teacherId) &&(!string.IsNullOrWhiteSpace(z.classId) || !string.IsNullOrWhiteSpace(z.stulist)))
+            courses.ForEach(x =>
+            {
+                x.schedule.ForEach(z =>
+                {
+                    if (!string.IsNullOrWhiteSpace(z.teacherId) && (!string.IsNullOrWhiteSpace(z.classId) || !string.IsNullOrWhiteSpace(z.stulist)))
                     {
                         string classId = null;
                         //行政班不为空,教学班为空,则名单取行政班
@@ -432,12 +448,13 @@ namespace TEAMModelAPI.Controllers
             List<ScheduleTimeDto> groupIdError = new List<ScheduleTimeDto>();
             List<ScheduleTimeDto> roomIdsError = new List<ScheduleTimeDto>();
             //数据库排查
-            import_schedules_hastime.ForEach(x => {
+            import_schedules_hastime.ForEach(x =>
+            {
                 //检查教师的排课是否冲突,不同的课程不能出现 教师冲突的情况, 相同课程可能是需要更新的。
-                if (database_schedules.FindAll(s => s.keyTeacher.Equals(x.keyTeacher)  && !x.courseId.Equals(s.courseId)).IsNotEmpty()) 
+                if (database_schedules.FindAll(s => s.keyTeacher.Equals(x.keyTeacher) && !x.courseId.Equals(s.courseId)).IsNotEmpty())
                 {
                     teacherError.Add(x);
-                } 
+                }
                 //检查名单的排课是否冲突
                 if (database_schedules.FindAll(s => s.keyGroupId.Equals(x.keyGroupId) && !x.courseId.Equals(s.courseId)).IsNotEmpty())
                 {
@@ -455,20 +472,21 @@ namespace TEAMModelAPI.Controllers
             import_schedules_hastime.RemoveAll(x => roomIdsError.Contains(x));
             //最终导入之前,必须检查,课程是否存在(notInCourseIds),教师是否存在,名单是否存在,并重新排列行政班,教学班,
             //排课时间段id是否正确,星期几是否正确(import_weeksConfuse),教室是否正确
-           
+
             //检查教师存在的
             HashSet<string> teachers = import_schedules_hastime.Select(x => x.teacherId).ToHashSet();
             teachers.Union(import_schedules_nottime.Select(x => x.teacherId));
-            IEnumerable<string> unexistTeacherIds= null;
-            if (teachers.Count > 0) {
+            IEnumerable<string> unexistTeacherIds = null;
+            if (teachers.Count > 0)
+            {
                 List<string> teacherIds = new List<string>();
-                string sqlTeacher = $"select value(c.id) from c where c.id in ({string.Join(",",teachers.Select(x=>$"'{x}'"))})";
+                string sqlTeacher = $"select value(c.id) from c where c.id in ({string.Join(",", teachers.Select(x => $"'{x}'"))})";
                 await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
-                    .GetItemQueryIterator<string>(queryText: sqlTeacher, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") })) 
+                    .GetItemQueryIterator<string>(queryText: sqlTeacher, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                 {
                     teacherIds.Add(item);
                 }
-                unexistTeacherIds= teachers.Except(teacherIds);
+                unexistTeacherIds = teachers.Except(teacherIds);
                 //移除不存在的教师
                 import_schedules_hastime.RemoveAll(x => unexistTeacherIds.Contains(x.teacherId));
                 import_schedules_nottime.RemoveAll(x => unexistTeacherIds.Contains(x.teacherId));
@@ -486,7 +504,7 @@ namespace TEAMModelAPI.Controllers
                 {
                     rooms.Add(item);
                 }
-                unexistRoomIds= roomIds.Except(rooms);
+                unexistRoomIds = roomIds.Except(rooms);
                 //移除不存在的教室
                 import_schedules_hastime.RemoveAll(x => unexistRoomIds.Contains(x.roomId));
                 import_schedules_nottime.RemoveAll(x => unexistRoomIds.Contains(x.roomId));
@@ -494,7 +512,8 @@ namespace TEAMModelAPI.Controllers
             //检查名单存在的
             List<string> groupIds = new List<string>();
             var classIdsHasTime = import_schedules_hastime.Where(x => !string.IsNullOrWhiteSpace(x.classId)).Select(x => x.classId).ToHashSet();
-            if (classIdsHasTime.Any()) {
+            if (classIdsHasTime.Any())
+            {
                 groupIds.AddRange(classIdsHasTime);
             }
             var stulistsHasTime = import_schedules_hastime.Where(x => !string.IsNullOrWhiteSpace(x.stulist)).Select(x => x.stulist).ToHashSet();
@@ -513,9 +532,10 @@ namespace TEAMModelAPI.Controllers
                 groupIds.AddRange(stulistsNotTime);
             }
 
-            List<GroupListDto> groupListDtos= await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds, school);
+            List<GroupListDto> groupListDtos = await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds, school);
             IEnumerable<string> unexistGroupIds = null;
-            if (groupListDtos.IsNotEmpty()) {
+            if (groupListDtos.IsNotEmpty())
+            {
                 unexistGroupIds = groupIds.Except(groupListDtos.Select(x => x.id));
                 //移除不存在的名单id
                 import_schedules_hastime.RemoveAll(x => unexistGroupIds.Contains(x.classId));
@@ -527,7 +547,8 @@ namespace TEAMModelAPI.Controllers
             HashSet<Course> update_course = new HashSet<Course>();
             HashSet<string> unexistTimeIds = new HashSet<string>();
             //处理包含时间排课的课程
-            import_schedules_hastime.ForEach(schedule => {
+            import_schedules_hastime.ForEach(schedule =>
+            {
                 Course course = courses.Find(x => x.id.Equals(schedule.courseId));
                 if (string.IsNullOrWhiteSpace(course?.period?.id))
                 {
@@ -535,47 +556,53 @@ namespace TEAMModelAPI.Controllers
                     TimeTable timeTable = period?.timetable.Find(x => x.id.Equals(schedule.timeId));
                     if (timeTable != null)
                     {
-                        string groupId= string.IsNullOrWhiteSpace(schedule.classId)?schedule.stulist:schedule.classId;
-                        GroupListDto groupList= groupListDtos.Find(g => g.id.Equals(groupId));
+                        string groupId = string.IsNullOrWhiteSpace(schedule.classId) ? schedule.stulist : schedule.classId;
+                        GroupListDto groupList = groupListDtos.Find(g => g.id.Equals(groupId));
                         string classId = null;
                         string stulist = null;
-                        if (groupList.type.Equals("class")) {
+                        if (groupList.type.Equals("class"))
+                        {
                             classId = groupList.id;
 
 
                         }
-                        else {
+                        else
+                        {
                             stulist = groupList.id;
                         }
-                        var course_schedule =course.schedule.Find(x => x.teacherId.Equals(schedule.teacherId));
+                        var course_schedule = course.schedule.Find(x => x.teacherId.Equals(schedule.teacherId));
                         if (course_schedule != null)
                         {
                             course_schedule.classId = classId;
-                            course_schedule.stulist = stulist ;
+                            course_schedule.stulist = stulist;
                             course_schedule.room = schedule.roomId;
-                            var time=  course_schedule.time.Find(t => t.id.Equals(schedule.timeId) && t.week.Equals(schedule.week));
+                            var time = course_schedule.time.Find(t => t.id.Equals(schedule.timeId) && t.week.Equals(schedule.week));
                             if (time != null)
                             {
-                                time.id=schedule.timeId;
-                                time.week=schedule.week;
+                                time.id = schedule.timeId;
+                                time.week = schedule.week;
                             }
-                            else {
+                            else
+                            {
                                 course_schedule.time.Add(new TimeInfo { id = schedule.timeId, week = schedule.week });
                             }
                         }
-                        else {
-                            course.schedule.Add(new Schedule { teacherId = schedule.teacherId,classId = classId, stulist = stulist, room = schedule.roomId, time = new List<TimeInfo> { new TimeInfo { id=schedule.timeId,week=schedule.week} } });
+                        else
+                        {
+                            course.schedule.Add(new Schedule { teacherId = schedule.teacherId, classId = classId, stulist = stulist, room = schedule.roomId, time = new List<TimeInfo> { new TimeInfo { id = schedule.timeId, week = schedule.week } } });
                         }
                         update_course.Add(course);
                     }
-                    else {
+                    else
+                    {
                         //课程,所在学段对应的作息时间不正确
                         unexistTimeIds.Add(schedule.timeId);
                     }
                 }
             });
             //处理没有时间排课的课程
-            import_schedules_nottime.ForEach(schedule => {
+            import_schedules_nottime.ForEach(schedule =>
+            {
                 Course course = courses.Find(x => x.id.Equals(schedule.courseId));
                 if (string.IsNullOrWhiteSpace(course?.period?.id))
                 {
@@ -601,38 +628,40 @@ namespace TEAMModelAPI.Controllers
                     }
                     else
                     {
-                        course.schedule.Add(new Schedule { teacherId=schedule.teacherId, classId = classId, stulist = stulist, room = schedule.roomId});
+                        course.schedule.Add(new Schedule { teacherId = schedule.teacherId, classId = classId, stulist = stulist, room = schedule.roomId });
                     }
                     update_course.Add(course);
                 }
             });
 
-            foreach (var item in update_course) {
+            foreach (var item in update_course)
+            {
                 await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
             }
-            return Ok(new {
-                import= new //导入数据自检信息
+            return Ok(new
+            {
+                import = new //导入数据自检信息
                 {
                     teacherWarning,//自检-教师冲突的排课
                     groupIdWarning,//自检-名单冲突的排课
                     roomIdsWarning,//自检-物理教室冲突的排课
                     weeksError //自检-错误的星期几编码
                 },
-                database= new //数据库比对信息
+                database = new //数据库比对信息
                 {
                     teacherError,//数据比对-教师冲突的排课
                     groupIdError,//数据比对-名单冲突的排课
                     roomIdsError,//数据比对-物理教室冲突的排课
-                    unexistCourseIds ,//不存在的课程
+                    unexistCourseIds,//不存在的课程
                     unexistTeacherIds,//不存在的教师
                     unexistGroupIds,//不存在的名单
                     unexistRoomIds,//不存在的教室
                     unexistTimeIds  //不存在的作息
                 },
-                updateCourse= update_course,
-                addSubjects= addSubjects
+                updateCourse = update_course,
+                addSubjects
             });
         }
-        
+
     }
 }

+ 7 - 7
TEAMModelBI/Controllers/OpenApi/ExamController.cs

@@ -27,7 +27,7 @@ using HTEXLib.COMM.Helpers;
 using HTEXLib.Translator;
 using TEAMModelOS.Models.Dto;
 
-namespace TEAMModelAPI.Controllers
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -80,7 +80,7 @@ namespace TEAMModelAPI.Controllers
         }
         [ProducesDefaultResponseType]
         [HttpPost("import-exam")]
-        [ApiToken(Auth = "1102", Name = "汇入评测基础数据",RWN ="W", Limit = false)]
+        [ApiToken(Auth = "1102", Name = "汇入评测基础数据", RWN = "W", Limit = false)]
         public async Task<IActionResult> importExam(JsonElement request)
         {
             //获取评测的ID
@@ -155,7 +155,7 @@ namespace TEAMModelAPI.Controllers
                 }
                 if (value.Count > 0)
                 {
-                    return Ok(new { code = 1, msg = "学生ID异常", value = value });
+                    return Ok(new { code = 1, msg = "学生ID异常", value });
                 }
                 else
                 {
@@ -297,7 +297,7 @@ namespace TEAMModelAPI.Controllers
                                                             }
                                                             else
                                                             {
-                                                                result.studentScores[newIndex][i] = System.Math.Round((double)ac / sc * points[i], 1);
+                                                                result.studentScores[newIndex][i] = Math.Round((double)ac / sc * points[i], 1);
                                                             }
 
                                                         }
@@ -316,7 +316,7 @@ namespace TEAMModelAPI.Controllers
                                                             }
                                                             else
                                                             {
-                                                                result.studentScores[newIndex][i] = System.Math.Round(persent * points[i], 1);
+                                                                result.studentScores[newIndex][i] = Math.Round(persent * points[i], 1);
                                                             }
                                                         }
                                                         break;
@@ -376,7 +376,7 @@ namespace TEAMModelAPI.Controllers
 
             try
             {
-               
+
                 var client = _azureCosmos.GetCosmosClient();
                 var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(fileDto.examId, new PartitionKey($"Exam-{fileDto.code}"));
                 ExamInfo examInfo;
@@ -495,7 +495,7 @@ namespace TEAMModelAPI.Controllers
                             stringBuilder.Append(fileDto.subjectId).Append("/");
                             stringBuilder.Append(dtoChildren.id + ".json");
 
-                            tasks.Add(_azureStorage.GetBlobContainerClient(fileDto.code).UploadFileByContainer( dtoChildren.ToJsonString(), "exam", stringBuilder.ToString(), false));
+                            tasks.Add(_azureStorage.GetBlobContainerClient(fileDto.code).UploadFileByContainer(dtoChildren.ToJsonString(), "exam", stringBuilder.ToString(), false));
                         }
                     }
                     info @info = new();

+ 68 - 44
TEAMModelBI/Controllers/OpenApi/GroupListController.cs

@@ -25,7 +25,8 @@ using TEAMModelOS.Filter;
 using Microsoft.AspNetCore.Authorization;
 using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Service;
-namespace TEAMModelAPI.Controllers
+
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -68,6 +69,7 @@ namespace TEAMModelAPI.Controllers
         {
             var client = _azureCosmos.GetCosmosClient();
             var (id, school) = HttpContext.GetApiTokenInfo();
+
             json.TryGetProperty("periodId", out JsonElement periodId);
             List<GroupListGrp> groupLists = new List<GroupListGrp>();
             //包含,学校的行政班,教学班
@@ -94,7 +96,7 @@ namespace TEAMModelAPI.Controllers
                     HashSet<string> groupNames = new HashSet<string>();
                     string gpsql = $"SELECT distinct c.groupId,c.groupName FROM c where  c.classId='{item.id}'and c.groupName <>null";
                     await foreach (var gp in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: gpsql,
-                        requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
+                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
                     {
                         groupNames.Add(gp.groupName);
                     }
@@ -186,7 +188,7 @@ namespace TEAMModelAPI.Controllers
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             if (!json.TryGetProperty("periodId", out JsonElement _periodId)) { return Ok(new { error = 2, msg = "学段信息错误!" }); }
-            if (!json.TryGetProperty("students", out JsonElement _students)) { return Ok(new { error = 1, msg = "学生列表格式错误!" }); } 
+            if (!json.TryGetProperty("students", out JsonElement _students)) { return Ok(new { error = 1, msg = "学生列表格式错误!" }); }
             if (_students.ValueKind.Equals(JsonValueKind.Array))
             {
                 School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
@@ -195,17 +197,18 @@ namespace TEAMModelAPI.Controllers
                 {
                     List<Student> webStudents = _students.ToObject<List<Student>>();
                     webStudents.ForEach(x => x.periodId = $"{_periodId}");
-                    List<Student> preStudents = await StudentService.GeStudentData(_azureCosmos, school, webStudents?.Select(x=>x.id));
+                    List<Student> preStudents = await StudentService.GeStudentData(_azureCosmos, school, webStudents?.Select(x => x.id));
                     var retUpsert = await StudentService.upsertStudents(_azureCosmos, _dingDing, _option, school, json.GetProperty("students").EnumerateArray());
                     await StudentService.CheckStudent(_serviceBus, _configuration, _azureCosmos, school, webStudents, preStudents);
-                    return this.Ok(new { code = $"{school}", students = retUpsert.studs, retUpsert.classDuplNos, retUpsert.errorIds });
+                    return Ok(new { code = $"{school}", students = retUpsert.studs, retUpsert.classDuplNos, retUpsert.errorIds });
                 }
-                else 
+                else
                 {
-                    return Ok(new { error = 2, msg = "学段信息错误!" }); 
+                    return Ok(new { error = 2, msg = "学段信息错误!" });
                 }
             }
-            else {
+            else
+            {
                 return Ok(new { error = 1, msg = "学生列表格式错误" });
             }
         }
@@ -234,7 +237,7 @@ namespace TEAMModelAPI.Controllers
                     List<Student> preStudents = await StudentService.GeStudentData(_azureCosmos, school, webStudents?.Select(x => x.id));
                     var retUpdate = await StudentService.updateStudents(_azureCosmos, _dingDing, _option, school, json.GetProperty("students").EnumerateArray());
                     await StudentService.CheckStudent(_serviceBus, _configuration, _azureCosmos, school, webStudents, preStudents);
-                    return this.Ok(new { code = school, students = retUpdate.studs, retUpdate.classDuplNos, retUpdate.nonexistentIds, retUpdate.errorNos, retUpdate.errorClassId });
+                    return Ok(new { code = school, students = retUpdate.studs, retUpdate.classDuplNos, retUpdate.nonexistentIds, retUpdate.errorNos, retUpdate.errorClassId });
                 }
                 else
                 {
@@ -272,8 +275,8 @@ namespace TEAMModelAPI.Controllers
                     {
                         webStudents.Add(new Student { id = idstu, code = $"Base-{school}" });
                     }
-                    List<Student>  preStudents = await StudentService.GeStudentData(_azureCosmos, school, webStudents?.Select(x => x.id));
-                    (List<string> studs, List<string> nonexistentIds, List<string> errorIds) retRemove = await StudentService.removeStudentClassInfo(    _azureCosmos, _dingDing, _option,school, json.GetProperty("students").EnumerateArray());
+                    List<Student> preStudents = await StudentService.GeStudentData(_azureCosmos, school, webStudents?.Select(x => x.id));
+                    (List<string> studs, List<string> nonexistentIds, List<string> errorIds) retRemove = await StudentService.removeStudentClassInfo(_azureCosmos, _dingDing, _option, school, json.GetProperty("students").EnumerateArray());
                     await StudentService.CheckStudent(_serviceBus, _configuration, _azureCosmos, school, webStudents, preStudents);
                     return Ok(new { code = $"{school}", ids = retRemove.studs, retRemove.nonexistentIds, retRemove.errorIds });
                 }
@@ -296,13 +299,15 @@ namespace TEAMModelAPI.Controllers
         [ProducesDefaultResponseType]
         [HttpPost("upsert-teach-groups")]
         [ApiToken(Auth = "1206", Name = "创建或更新教学班", RWN = "W", Limit = false)]
-        public async Task<IActionResult> UpsertTeachGroups(GroupListDtoImpt json) {
+        public async Task<IActionResult> UpsertTeachGroups(GroupListDtoImpt json)
+        {
             var (_, school) = HttpContext.GetApiTokenInfo();
             var groupListsDto = json.groupLists;
             List<GroupList> groupLists = new List<GroupList>(); ;
             List<Dictionary<string, string>> errorData = new List<Dictionary<string, string>>();
             School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
-            foreach (var list in groupListsDto) {
+            foreach (var list in groupListsDto)
+            {
                 Period period = data.period.Find(x => x.id.Equals($"{list.periodId}"));
                 if (period != null)
                 {
@@ -319,7 +324,7 @@ namespace TEAMModelAPI.Controllers
                             scope = "school",
                             school = school,
                             type = "teach",
-                            year = list.year > 2000 ?DateTimeOffset.UtcNow.Year: groupList.year,
+                            year = list.year > 2000 ? DateTimeOffset.UtcNow.Year : groupList.year,
                             froms = 3
                         };
                         groupList = await GroupListService.CheckListNo(groupList, _azureCosmos, _dingDing, _option);
@@ -358,23 +363,25 @@ namespace TEAMModelAPI.Controllers
                             await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(groupList, new PartitionKey(groupList.code));
                         }
                     }
-                    if (groupList != null) {
+                    if (groupList != null)
+                    {
                         groupLists.Add(groupList);
                     }
                 }
                 else
                 {
-                    errorData.Add(new Dictionary<string, string> { { "group",list.name}, { "periodId",list.periodId} });
+                    errorData.Add(new Dictionary<string, string> { { "group", list.name }, { "periodId", list.periodId } });
                     // return Ok(new { error = 2, msg ="学段不存在!" });
                 }
             }
-             
-            return Ok(new { groupLists=groupLists.Select(x=>new { x.name,x.no,x.periodId,x.school,x.type,x.year,x.tcount,x.scount,x.id}), errorData });
+
+            return Ok(new { groupLists = groupLists.Select(x => new { x.name, x.no, x.periodId, x.school, x.type, x.year, x.tcount, x.scount, x.id }), errorData });
         }
 
-        public class MemberImpt {
+        public class MemberImpt
+        {
             public List<Member> members { get; set; } = new List<Member>();
-            public string groupId { get; set; } 
+            public string groupId { get; set; }
         }
 
         /// <summary>
@@ -393,11 +400,12 @@ namespace TEAMModelAPI.Controllers
             var tmds = members.Where(x => x.type == 1).ToList();
             var stus = members.Where(x => x.type == 2).ToList();
             List<Student> students = await StudentService.GeStudentData(_azureCosmos, school, stus?.Select(x => x.id));
-            List<TmdInfo> infos = new List<TmdInfo> ();
+            List<TmdInfo> infos = new List<TmdInfo>();
             string tmdstr = "";
             try
             {
-                if (tmds.Any()) {
+                if (tmds.Any())
+                {
                     var content = new StringContent(tmds.Select(x => x.id).ToJsonString(), Encoding.UTF8, "application/json");
                     tmdstr = await _coreAPIHttpService.GetUserInfos(content);
                     infos = tmdstr.ToObject<List<TmdInfo>>();
@@ -409,11 +417,12 @@ namespace TEAMModelAPI.Controllers
                 //return Ok(new { error =3, msg = "醍摩豆ID验证错误!" });
             }
             var unexist_student = stus.Select(x => x.id).Except(students.Select(y => y.id)).ToList();
-            var unexist_tmdids = tmds.Select(x => x.id).Except(infos.Select(y => y.id)).ToList() ;
+            var unexist_tmdids = tmds.Select(x => x.id).Except(infos.Select(y => y.id)).ToList();
             stus.RemoveAll(x => unexist_student.Contains(x.id));
             tmds.RemoveAll(x => unexist_tmdids.Contains(x.id));
             Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{json.groupId}", new PartitionKey($"GroupList-{school}"));
-            try {
+            try
+            {
                 if (response.Status == 200)
                 {
                     JsonDocument jsonDocument = JsonDocument.Parse(response.Content);
@@ -422,7 +431,8 @@ namespace TEAMModelAPI.Controllers
                     {
                         if (infos.Any())
                         {
-                            infos.ToList().ForEach(x => {
+                            infos.ToList().ForEach(x =>
+                            {
                                 var mebJoined = list.members.Find(m => m.id.Equals(x.id) && m.type == 1);
                                 var mb = tmds.Where(m => m.id.Equals(x.id) && m.type == 1).First();
                                 string groupId = Guid.NewGuid().ToString();
@@ -444,7 +454,7 @@ namespace TEAMModelAPI.Controllers
                                 if (mebJoined != null)
                                 {
                                     mebJoined.nickname = mb.nickname == null ? mebJoined.nickname : mb.nickname;
-                                    mebJoined.groupName = groupName==null? mebJoined.groupName:groupName;
+                                    mebJoined.groupName = groupName == null ? mebJoined.groupName : groupName;
                                     mebJoined.groupId = groupId == null ? mebJoined.groupId : groupId;
                                 }
                                 else
@@ -458,7 +468,8 @@ namespace TEAMModelAPI.Controllers
                         }
                         if (stus.Any())
                         {
-                            stus.ToList().ForEach(x => {
+                            stus.ToList().ForEach(x =>
+                            {
                                 var mebJoined = list.members.Find(m => m.id.Equals(x.id) && m.type == 2);
                                 var mb = stus.Where(m => m.id.Equals(x.id) && m.type == 2).First();
                                 string groupId = Guid.NewGuid().ToString();
@@ -509,9 +520,9 @@ namespace TEAMModelAPI.Controllers
                                 list.scount,
                                 list.id,
                                 list.members
-                                
+
                             }
-                        }) ;
+                        });
                     }
                     else
                     {
@@ -522,7 +533,9 @@ namespace TEAMModelAPI.Controllers
                 {
                     return Ok(new { error = 2, msg = "名单不存在!" });
                 }
-            } catch (Exception ex) {
+            }
+            catch (Exception ex)
+            {
                 return BadRequest($"{ex.StackTrace}");
             }
         }
@@ -535,13 +548,15 @@ namespace TEAMModelAPI.Controllers
         [ProducesDefaultResponseType]
         [HttpPost("remove-teach-members")]
         [ApiToken(Auth = "1208", Name = "移除教学班学生", RWN = "W", Limit = false)]
-        public async Task<IActionResult> RemoveTeachMembers(JsonElement json) {
+        public async Task<IActionResult> RemoveTeachMembers(JsonElement json)
+        {
             var (id, school) = HttpContext.GetApiTokenInfo();
             json.TryGetProperty("stuids", out JsonElement _stuids);
             json.TryGetProperty("tmdids", out JsonElement _tmdids);
             if (!json.TryGetProperty("groupId", out JsonElement _groupId)) { return Ok(new { error = 1, msg = "名单错误!" }); }
             List<string> stuids = null;
-            if (_stuids.ValueKind.Equals(JsonValueKind.Array)) {
+            if (_stuids.ValueKind.Equals(JsonValueKind.Array))
+            {
                 stuids = _stuids.ToObject<List<string>>();
             }
             List<string> tmdids = null;
@@ -554,14 +569,17 @@ namespace TEAMModelAPI.Controllers
                 // School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
                 Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{_groupId}", new PartitionKey($"GroupList-{school}"));
                 if (response.Status == 200)
-                { 
-                    JsonDocument document= JsonDocument.Parse(response.Content);
-                    var  list= document.RootElement.Deserialize<GroupList>();
+                {
+                    JsonDocument document = JsonDocument.Parse(response.Content);
+                    var list = document.RootElement.Deserialize<GroupList>();
                     List<string> remove_tmdids = new List<string>();
-                    if (tmdids.Any()) {
-                        tmdids.ForEach(x => {
-                            int len= list.members.RemoveAll(z => z.id.Equals(x) && z.type == 1);
-                            if (len > 0) {
+                    if (tmdids.Any())
+                    {
+                        tmdids.ForEach(x =>
+                        {
+                            int len = list.members.RemoveAll(z => z.id.Equals(x) && z.type == 1);
+                            if (len > 0)
+                            {
                                 remove_tmdids.Add(x);
                             }
                         });
@@ -569,7 +587,8 @@ namespace TEAMModelAPI.Controllers
                     List<string> remove_stuids = new List<string>();
                     if (stuids.Any())
                     {
-                        stuids.ForEach(x => {
+                        stuids.ForEach(x =>
+                        {
                             int len = list.members.RemoveAll(z => z.id.Equals(x) && z.type == 2);
                             if (len > 0)
                             {
@@ -578,7 +597,11 @@ namespace TEAMModelAPI.Controllers
                         });
                     }
                     list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
-                    return Ok(new { remove_stuids, remove_tmdids,list=
+                    return Ok(new
+                    {
+                        remove_stuids,
+                        remove_tmdids,
+                        list =
                         new
                         {
                             list.name,
@@ -594,13 +617,14 @@ namespace TEAMModelAPI.Controllers
                         }
                     });
                 }
-                else {
+                else
+                {
                     return Ok(new { error = 2, msg = "名单不存在!" });
                 }
             }
-            else 
+            else
             {
-                 return Ok(new { error = 2, msg = "移除的名单人员为空!" }); 
+                return Ok(new { error = 2, msg = "移除的名单人员为空!" });
             }
         }
     }

+ 6 - 4
TEAMModelBI/Controllers/OpenApi/OpenApiConfigController.cs

@@ -16,7 +16,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Table;
 
-namespace TEAMModelBI.Controllers
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -50,18 +50,20 @@ namespace TEAMModelBI.Controllers
         public async Task<IActionResult> CreateToken(JsonElement request)
         {
             try
-            {   if (!request.TryGetProperty("id", out JsonElement _id)) { return BadRequest(); }
+            {
+                if (!request.TryGetProperty("id", out JsonElement _id)) { return BadRequest(); }
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
                 List<BusinessConfig> configs = table.FindListByDictSync<BusinessConfig>(new Dictionary<string, object> { { "PartitionKey", $"BusinessConfig" }, { "RowKey", $"{_id}" } });
                 string jwt = "";
-                if (configs.Any()) {
+                if (configs.Any())
+                {
                     var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, configs[0].RowKey, _option.JwtSecretKey, "business");
                     jwt = auth_token.jwt;
                     configs[0].jti = auth_token.jti;
                     configs[0].token = auth_token.jwt;
                     await table.SaveOrUpdate<BusinessConfig>(configs[0]);
                 }
-               
+
                 return Ok(new { jwt });
             }
             catch (Exception e)

+ 20 - 16
TEAMModelBI/Controllers/OpenApi/RoomController.cs

@@ -27,7 +27,8 @@ using TEAMModelOS.Filter;
 using Azure.Storage.Blobs.Models;
 using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Authorization;
-namespace TEAMModelAPI.Controllers
+
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -75,11 +76,11 @@ namespace TEAMModelAPI.Controllers
             }
             List<Room> rooms = new List<Room>();
             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Room>(queryText: sql.ToString(),
-            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Room-{school}") }))
+            requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{school}") }))
             {
                 rooms.Add(item);
             }
-            return Ok(new { rooms = rooms.Select(x => new { x.id, x.name, x.x, x.y, x.openType, x.style, x.area, x.address, school = school }) });
+            return Ok(new { rooms = rooms.Select(x => new { x.id, x.name, x.x, x.y, x.openType, x.style, x.area, x.address, school }) });
         }
         /// <summary>
         /// 物理教室详细
@@ -93,13 +94,13 @@ namespace TEAMModelAPI.Controllers
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             if (!json.TryGetProperty("roomId", out JsonElement roomId)) return BadRequest();
-            Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
+            Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
               .ReadItemStreamAsync($"{roomId}", new PartitionKey($"Room-{school}"));
             if (response.Status == 200)
             {
                 JsonDocument document = JsonDocument.Parse(response.Content);
                 Room room = document.RootElement.Deserialize<Room>();
-                return Ok(new { room.id, room.name, room.x, room.y, room.openType, room.style, room.area, room.address, school = school });
+                return Ok(new { room.id, room.name, room.x, room.y, room.openType, room.style, room.area, room.address, school });
             }
             else
             {
@@ -124,7 +125,7 @@ namespace TEAMModelAPI.Controllers
         public async Task<IActionResult> UpsertRoomInfo(RoomsDto json)
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
-            var rooms = json.rooms ;
+            var rooms = json.rooms;
             List<Room> db_rooms = new List<Room>();
             List<Room> roomCreate = new List<Room>();
             School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
@@ -135,10 +136,12 @@ namespace TEAMModelAPI.Controllers
                 db_rooms.Add(item);
             }
             //不存在的教室,可以被直接创建
-            var unexistRoomIds = rooms.Select(x=>x.id).Except(db_rooms.Select(x => x.id));
-            foreach (var roomId in unexistRoomIds) {
+            var unexistRoomIds = rooms.Select(x => x.id).Except(db_rooms.Select(x => x.id));
+            foreach (var roomId in unexistRoomIds)
+            {
                 var room_web = rooms.Find(x => x.id.Equals(roomId));
-                if (room_web != null) {
+                if (room_web != null)
+                {
                     var room = new Room
                     {
                         id = room_web.id,
@@ -153,20 +156,21 @@ namespace TEAMModelAPI.Controllers
                     roomCreate.Add(room);
                 }
             }
-            foreach (var room in db_rooms) {
+            foreach (var room in db_rooms)
+            {
                 var room_web = rooms.Find(x => x.id.Equals(room.id));
                 if (room_web != null)
                 {
-                    room.name = string.IsNullOrWhiteSpace(room_web.name) ? room.name : room_web.name;  
+                    room.name = string.IsNullOrWhiteSpace(room_web.name) ? room.name : room_web.name;
                     room.code = $"Room-{school}";
                     room.pk = "Room";
-                    room.area= string.IsNullOrWhiteSpace(room_web.area) ? room.area : room_web.area; 
-                    room.no =string.IsNullOrWhiteSpace(room_web.no)?room.no : room_web.no;
-                    room.address = string.IsNullOrWhiteSpace(room_web.address) ? room.address : room_web.address; 
-                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(room,room.id, new PartitionKey(room.code));
+                    room.area = string.IsNullOrWhiteSpace(room_web.area) ? room.area : room_web.area;
+                    room.no = string.IsNullOrWhiteSpace(room_web.no) ? room.no : room_web.no;
+                    room.address = string.IsNullOrWhiteSpace(room_web.address) ? room.address : room_web.address;
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(room, room.id, new PartitionKey(room.code));
                 }
             }
-            return Ok(new { roomUpdate= db_rooms, roomCreate= roomCreate });
+            return Ok(new { roomUpdate = db_rooms, roomCreate });
         }
     }
 }

+ 19 - 11
TEAMModelBI/Controllers/OpenApi/SchoolController.cs

@@ -27,7 +27,7 @@ using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.SDK.Models.Table;
 
-namespace TEAMModelAPI.Controllers
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -50,7 +50,7 @@ namespace TEAMModelAPI.Controllers
             _dingDing = dingDing;
             _option = option?.Value;
             _configuration = configuration;
-            _coreAPIHttpService=coreAPIHttpService;
+            _coreAPIHttpService = coreAPIHttpService;
         }
         /// <summary>
         ///  第三方获取学校列表
@@ -60,11 +60,12 @@ namespace TEAMModelAPI.Controllers
         [ProducesDefaultResponseType]
         [HttpPost("get-schools")]
         [ApiToken(Auth = "1000", Name = "合作商获取可访问的学校列表", RWN = "R", Limit = false)]
-        public async Task<IActionResult> GetSchools() {
+        public async Task<IActionResult> GetSchools()
+        {
             var (id, _) = HttpContext.GetApiTokenInfo();
             var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
-            List<BusinessSchool> schools=  await table.FindListByDict<BusinessSchool>(new Dictionary<string, object> { { "PartitionKey", $"BusinessSchool" },{ "bizid",id} });
-            return Ok(new { schools = schools.Select(x => new {id =x.RowKey,x.name,x.picture })});
+            List<BusinessSchool> schools = await table.FindListByDict<BusinessSchool>(new Dictionary<string, object> { { "PartitionKey", $"BusinessSchool" }, { "bizid", id } });
+            return Ok(new { schools = schools.Select(x => new { id = x.RowKey, x.name, x.picture }) });
         }
         /// <summary>
         ///  学校基本信息
@@ -73,17 +74,24 @@ namespace TEAMModelAPI.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-school-info")]
-        [ApiToken(Auth = "1001",Name = "学校基本信息", RWN = "R", Limit =false)]
+        [ApiToken(Auth = "1001", Name = "学校基本信息", RWN = "R", Limit = false)]
         public async Task<IActionResult> GetSchoolInfo()
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
             List<dynamic> period = new List<dynamic>();
-            data.period.ForEach(x => { period.Add(new { x.subjects ,x.grades,x.name,x.id,x.campusId,x.semesters}); });
-            return Ok(new { 
-                id = data.id, name = data.name, data.areaId, type = data.type, 
-                data.region, data.province, data.city, data.dist,
-                campuses=data.campuses,
+            data.period.ForEach(x => { period.Add(new { x.subjects, x.grades, x.name, x.id, x.campusId, x.semesters }); });
+            return Ok(new
+            {
+                data.id,
+                data.name,
+                data.areaId,
+                data.type,
+                data.region,
+                data.province,
+                data.city,
+                data.dist,
+                data.campuses,
                 period
             });
         }

+ 12 - 9
TEAMModelBI/Controllers/OpenApi/TeacherController.cs

@@ -30,7 +30,7 @@ using Microsoft.AspNetCore.Authorization;
 using System.Net.Http;
 using System.ComponentModel.DataAnnotations;
 
-namespace TEAMModelAPI.Controllers
+namespace TEAMModelBI.Controllers.OpenApi.Business
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
     [ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -96,7 +96,7 @@ namespace TEAMModelAPI.Controllers
             string insql = "";
             if (coreUsers.Any())
             {
-                insql = $"   c.id in  ({string.Join(",", coreUsers.Select(x => $"'{ x.id}'"))}) ";
+                insql = $"   c.id in  ({string.Join(",", coreUsers.Select(x => $"'{x.id}'"))}) ";
             }
             string sql = $"select c.id,c.name ,c.picture,c.job ,c.subjectIds,c.roles from c where   {insql}";
             await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>
@@ -107,7 +107,8 @@ namespace TEAMModelAPI.Controllers
             var teacherIds = coreUsers.Select(x => x.id).Except(teachers.Select(x => x.id));
             List<CoreUser> unjoined = coreUsers.FindAll(x => teacherIds.Contains(x.id));
             List<dynamic> tchs = new List<dynamic>();
-            teachers.Select(x => new { x.id, x.name, x.picture, x.job, x.subjectIds, x.roles }).ToList().ForEach(x => {
+            teachers.Select(x => new { x.id, x.name, x.picture, x.job, x.subjectIds, x.roles }).ToList().ForEach(x =>
+            {
                 var coreUser = coreUsers.Find(c => c.id.Equals(x.id));
                 if (coreUser != null)
                 {
@@ -118,7 +119,7 @@ namespace TEAMModelAPI.Controllers
             {
                 teachers = tchs,
                 unjoined = unjoined.Select(x => new { x.id, x.name, x.picture, x.searchKey }),
-                unexist = unexist
+                unexist
             });
         }
         /// <summary>
@@ -132,9 +133,9 @@ namespace TEAMModelAPI.Controllers
         {
             json.TryGetProperty("tmdid", out JsonElement _tmdid);
             var (id, school) = HttpContext.GetApiTokenInfo();
-            Azure.Response responseSchoolTch = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
+            Response responseSchoolTch = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School")
                 .ReadItemStreamAsync($"{_tmdid}", new PartitionKey($"Teacher-{school}"));
-            Azure.Response responseTch = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher")
+            Response responseTch = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher")
                  .ReadItemStreamAsync($"{_tmdid}", new PartitionKey($"Base"));
             Teacher teacher = null;
             if (responseTch.Status == 200)
@@ -237,7 +238,7 @@ namespace TEAMModelAPI.Controllers
                             teacher.schools = new List<Teacher.TeacherSchool> { new Teacher.TeacherSchool { schoolId = school, name = data.name, status = "invite", time = now, picture = data.picture, areaId = data.areaId } };
                         }
                     }
-                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(teacher, teacher.id, new PartitionKey("Base"));
                 }
                 else
                 {
@@ -261,7 +262,8 @@ namespace TEAMModelAPI.Controllers
                 List<string> subjectIds = new List<string>();
                 if (item.subjects.IsNotEmpty() && !string.IsNullOrWhiteSpace(item.periodId))
                 {
-                    item.subjects.ForEach(s => {
+                    item.subjects.ForEach(s =>
+                    {
                         //同名学科
                         var subject = data.period.Find(x => x.id.Equals(item.periodId))?.subjects?.Find(x => x.id.Equals(s.id));
                         if (subject == null)
@@ -307,7 +309,8 @@ namespace TEAMModelAPI.Controllers
                 {
                     if (subjectIds.IsNotEmpty())
                     {
-                        subjectIds.ForEach(x => {
+                        subjectIds.ForEach(x =>
+                        {
                             if (!schoolTeacher.subjectIds.Contains(x))
                             {
                                 schoolTeacher.subjectIds.Add(x);

+ 6 - 0
TEAMModelBI/Controllers/OpenApi/OpenApiService.cs

@@ -0,0 +1,6 @@
+namespace TEAMModelBI.Controllers.OpenApi
+{
+    public class OpenApiService
+    {
+    }
+}

+ 1 - 1
TEAMModelBI/TEAMModelBI.csproj

@@ -27,7 +27,7 @@
 	</ItemGroup>
 
 	<ItemGroup>
-		<Folder Include="Controllers\OpenApi\Business\" />
+		<Folder Include="Controllers\OpenApi\School\" />
 		<Folder Include="wwwroot\" />
 	</ItemGroup>
 	<PropertyGroup>

+ 1 - 1
TEAMModelOS.SDK/Context/Attributes/Filter/ApiTokenAttribute.cs

@@ -52,7 +52,7 @@ namespace TEAMModelOS.Filter
         /// </summary>
         ///public decimal cost { get; set; }
     }
-    
+
     public class ApiTokenAttribute : Attribute, IFilterFactory
     {
         public bool IsReusable => true;