CrazyIter_Bin преди 1 година
родител
ревизия
9d9c2d93db

+ 23 - 6
TEAMModelOS.SDK/Models/Cosmos/Common/GroupList.cs

@@ -54,7 +54,11 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 加入人数200人,学生加入已满200 自动关闭加入。可手动解除限制,开启审核时,关闭人数上限设置机制
         /// </summary>
-        public int limit { get; set; } = 200;
+        public int limitCount { get; set; } = 200;
+        /// <summary>
+        /// 二维码 天数
+        /// </summary>
+        public int qrcodeDays { get; set; }
         /// <summary>
         /// 二维码过期时间
         /// </summary>
@@ -117,11 +121,15 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 加入人数200人,学生加入已满200 自动关闭加入。可手动解除限制,开启审核时,关闭人数上限设置机制
         /// </summary>
-        public int limit { get; set; } = 200;
+        public int limitCount { get; set; } = 200;
         /// <summary>
         /// 二维码过期时间
         /// </summary>
         public int qrcodeExpire { get; set; }
+        /// <summary>
+        /// 二维码 天数
+        /// </summary>
+        public int qrcodeDays { get; set; }
         public HashSet<int> grades { get; set; } = new HashSet<int>();
     }
 
@@ -270,8 +278,9 @@ namespace TEAMModelOS.SDK.Models
             this.froms = groupList.froms;
             this.joinLock = groupList.joinLock;
             this.qrcodeExpire = groupList.qrcodeExpire;
+            this.qrcodeDays = groupList.qrcodeDays;
             this.review=groupList.review;
-            this.limit = groupList.limit;
+            this.limitCount = groupList.limitCount;
             this.grades = groupList.grades;
         }
         public string pk { get; set; }
@@ -315,11 +324,15 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 加入人数200人,学生加入已满200 自动关闭加入。可手动解除限制,开启审核时,关闭人数上限设置机制
         /// </summary>
-        public int limit { get; set; } = 200;
+        public int limitCount { get; set; } = 200;
         /// <summary>
         /// 二维码过期时间
         /// </summary>
         public int qrcodeExpire { get; set; }
+        /// <summary>
+        /// 二维码 天数
+        /// </summary>
+        public int qrcodeDays { get; set; }
         //补充毕业
         //0在校,1毕业 
         public int graduate { get; set; } = 0;
@@ -375,11 +388,15 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 加入人数200人,学生加入已满200 自动关闭加入。可手动解除限制,开启审核时,关闭人数上限设置机制
         /// </summary>
-        public int limit { get; set; } = 200;
+        public int limitCount { get; set; } = 200;
         /// <summary>
         /// 二维码过期时间
         /// </summary>
-        public int qrcodeExpire { get; set; }
+        public long qrcodeExpire { get; set; }
+        /// <summary>
+        /// 二维码 天数
+        /// </summary>
+        public int qrcodeDays { get; set; }
         //0在校,1毕业 
         public int graduate { get; set; } = 0;
         public long expire { get; set; } = 0;

+ 120 - 113
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -130,7 +130,7 @@ namespace TEAMModelOS.SDK
                     }
                 }
             }
-            string SummarySql = " c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader  ,c.froms ,c.joinLock ,c.review,c.limit ,c.expire,c.qrcodeExpire ,c.grades  ";
+            string SummarySql = " c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader  ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire,c.qrcodeExpire ,c.qrcodeDays ,c.grades  ";
             if (groupTypes.IsEmpty() || groupTypes.Contains("teach")) {
                 //教学班
                 string teachsql="";
@@ -211,7 +211,7 @@ namespace TEAMModelOS.SDK
                     //状态=4 表示未开放加入。
                     return (4, item, null) ;
                 }
-                if (item.members!=null  &&item.limit>0 &&  item.members.Count>item.limit) {
+                if (item.members!=null  &&item.limitCount>0 &&  item.members.Count>item.limitCount) {
                     if (item.review ==1)
                     {
                         //状态=6 ,人数已满,需要审核通过再加入。
@@ -558,142 +558,149 @@ namespace TEAMModelOS.SDK
         /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
         /// <returns></returns>
         public static async Task<List<GroupListDto>> GetGroupListByListids(CosmosClient client, DingDing _dingDing, List<string> classes, string school,
-            string SummarySql = " c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader ,c.froms ,c.joinLock ,c.review,c.limit ,c.expire ,c.qrcodeExpire  ,c.grades ", int graduate = -1)
+            string SummarySql = " c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire ,c.qrcodeExpire,c.qrcodeDays  ,c.grades ", int graduate = -1)
         {
-            classes.RemoveAll(x => x == null);
-            if (!classes.IsNotEmpty()) {
-                return null;
-            }
             List<GroupListDto> groupLists = null;
-            if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !string.IsNullOrEmpty(school))
+            try
             {
-                //默认的教研组
-
-                GroupListDto groupList = new GroupListDto
+                classes.RemoveAll(x => x == null);
+                if (!classes.IsNotEmpty())
                 {
-                    id = "TeacherAll",
-                    name = "TeacherAll",
-                    code = $"GroupList-{school}",
-                    school = school,
-                    scope = "school",
-                    type = "yxtrain",
-                };
-                groupLists = new List<GroupListDto> { groupList };
-            }
-            else
-            {
-                Dictionary<string, List<GroupListDto>> groups = new Dictionary<string, List<GroupListDto>>();
-                //List<Student> students = new List<Student>();
-                string sql = string.Join(",", classes.Select(x => $"'{x}'"));
-                if (!string.IsNullOrEmpty(school))
+                    return null;
+                }
+           
+                if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !string.IsNullOrEmpty(school))
                 {
-                    List<GroupListDto> schoolList = new List<GroupListDto>();
+                    //默认的教研组
 
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
-                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
-                    {
-                        schoolList.Add(item);
-                    }
-                    if (schoolList.IsNotEmpty())
+                    GroupListDto groupList = new GroupListDto
                     {
-                        groups.Add("School", schoolList);
-                    }
-                    //取差集,减少二次搜寻
-                    classes = classes.Except(schoolList.Select(y => y.id)).ToList();
-                    if (classes.IsNotEmpty())
+                        id = "TeacherAll",
+                        name = "TeacherAll",
+                        code = $"GroupList-{school}",
+                        school = school,
+                        scope = "school",
+                        type = "yxtrain",
+                    };
+                    groupLists = new List<GroupListDto> { groupList };
+                }
+                else
+                {
+                    Dictionary<string, List<GroupListDto>> groups = new Dictionary<string, List<GroupListDto>>();
+                    //List<Student> students = new List<Student>();
+                    string sql = string.Join(",", classes.Select(x => $"'{x}'"));
+                    if (!string.IsNullOrEmpty(school))
                     {
-                        if (!groupLists.IsNotEmpty())
+                        List<GroupListDto> schoolList = new List<GroupListDto>();
+
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
+                                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
                         {
-                            groupLists = new List<GroupListDto>();
+                            schoolList.Add(item);
                         }
-                        string insql = string.Join(",", classes.Select(x => $"'{x}'"));
-                        //搜寻没有关联学生的行政班
-                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: 
-                            $"select   c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.teacher.id as leader ,c.graduate from c where c.id in ({insql})",
-                                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
+                        if (schoolList.IsNotEmpty())
                         {
-                            ///行政班(学生搜寻classId动态返回)class
-                            GroupListDto group = new GroupListDto
+                            groups.Add("School", schoolList);
+                        }
+                        //取差集,减少二次搜寻
+                        classes = classes.Except(schoolList.Select(y => y.id)).ToList();
+                        if (classes.IsNotEmpty())
+                        {
+                            if (!groupLists.IsNotEmpty())
                             {
-                                id = item.id,
-                                code = $"GroupList-{school}",
-                                name = item.name,
-                                periodId = item.periodId,
-                                scope = "school",
-                                school = school,
-                                type = "class",
-                                year = item.year,
-                                expire = item.expire,
-                                leader = item.leader,
-                                no = item.no,
-                                pk = "GroupList",
-                                graduate = item.graduate,
-                                grades= new HashSet<int> { item.year}
-                            };
-                            //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
-                            if (graduate >= 0)
+                                groupLists = new List<GroupListDto>();
+                            }
+                            string insql = string.Join(",", classes.Select(x => $"'{x}'"));
+                            //搜寻没有关联学生的行政班
+                            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText:
+                                $"select   c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.teacher.id as leader ,c.graduate from c where c.id in ({insql})",
+                                    requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
                             {
-                                if (group.graduate == graduate)
+                                ///行政班(学生搜寻classId动态返回)class
+                                GroupListDto group = new GroupListDto
+                                {
+                                    id = item.id,
+                                    code = $"GroupList-{school}",
+                                    name = item.name,
+                                    periodId = item.periodId,
+                                    scope = "school",
+                                    school = school,
+                                    type = "class",
+                                    year = item.year,
+                                    expire = item.expire,
+                                    leader = item.leader,
+                                    no = item.no,
+                                    pk = "GroupList",
+                                    graduate = item.graduate,
+                                    grades= new HashSet<int> { item.year }
+                                };
+                                //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
+                                if (graduate >= 0)
+                                {
+                                    if (group.graduate == graduate)
+                                    {
+                                        groupLists.Add(group);
+                                    }
+                                }
+                                //全部。
+                                else
                                 {
                                     groupLists.Add(group);
                                 }
+                                //  groupLists.Add(group);
                             }
-                            //全部。
-                            else 
-                            {
-                                groupLists.Add(group);
-                            }
-                          //  groupLists.Add(group);
+                            //取差集,减少二次搜寻
+                            classes = classes.Except(groupLists.Select(y => y.id)).ToList();
                         }
-                        //取差集,减少二次搜寻
-                        classes = classes.Except(groupLists.Select(y => y.id)).ToList();
-                    }
-                }
-                if (classes.IsNotEmpty())
-                {
-                    List<GroupListDto> privateList = new List<GroupListDto>();
-                    sql = string.Join(",", classes.Select(x => $"'{x}'"));
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
-                           requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
-                    {
-                        privateList.Add(item);
-                        //if (string.IsNullOrWhiteSpace(school))
-                        //{
-                        //    privateList.Add(item);
-                        //}
-                        //else
-                        //{
-                        //    if (!string.IsNullOrWhiteSpace(item.school))
-                        //    {
-                        //        if (item.school.Equals(school))
-                        //        {
-                        //            privateList.Add(item);
-                        //        }
-                        //    }
-                        //    else
-                        //    {
-                        //        privateList.Add(item);
-                        //    }
-                        //}
                     }
-                    if (privateList.IsNotEmpty())
+                    if (classes.IsNotEmpty())
                     {
-                        groups.Add("Teacher", privateList);
+                        List<GroupListDto> privateList = new List<GroupListDto>();
+                        sql = string.Join(",", classes.Select(x => $"'{x}'"));
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
+                               requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
+                        {
+                            privateList.Add(item);
+                            //if (string.IsNullOrWhiteSpace(school))
+                            //{
+                            //    privateList.Add(item);
+                            //}
+                            //else
+                            //{
+                            //    if (!string.IsNullOrWhiteSpace(item.school))
+                            //    {
+                            //        if (item.school.Equals(school))
+                            //        {
+                            //            privateList.Add(item);
+                            //        }
+                            //    }
+                            //    else
+                            //    {
+                            //        privateList.Add(item);
+                            //    }
+                            //}
+                        }
+                        if (privateList.IsNotEmpty())
+                        {
+                            groups.Add("Teacher", privateList);
+                        }
                     }
-                }
-                if (groups.Count != 0)
+                    if (groups.Count != 0)
 
-                {
-                    if (groupLists.IsNotEmpty())
-                    {
-                        groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
-                    }
-                    else
                     {
-                        groupLists = groups.SelectMany(x => x.Value).ToList();
+                        if (groupLists.IsNotEmpty())
+                        {
+                            groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
+                        }
+                        else
+                        {
+                            groupLists = groups.SelectMany(x => x.Value).ToList();
+                        }
                     }
-                }
 
+                }
+            } catch (Exception ex ) {
+                await _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
             return groupLists;
         }

+ 0 - 2
TEAMModelOS/Controllers/Both/CourseBaseController.cs

@@ -1686,8 +1686,6 @@ namespace TEAMModelOS.Controllers.Both
                     //任教学校课程和个人课程
                     case bool when $"{grant_type}".Equals("teach", StringComparison.OrdinalIgnoreCase):
                         //个人,
-
-
                         //学校,
                         //助教,学校。
                         //助教,个人。

+ 4 - 2
TEAMModelOS/Controllers/Both/GroupListController.cs

@@ -43,7 +43,7 @@ namespace TEAMModelOS.Controllers
         private readonly AzureStorageFactory _azureStorage;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly IWebHostEnvironment _environment;
-        private const string SummarySql = " c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader ,c.froms ,c.joinLock ,c.review,c.limit ,c.expire,c.qrcodeExpire ,c.grades  ";
+        private const string SummarySql = " c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.leader ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire,c.qrcodeExpire,c.qrcodeDays ,c.grades  ";
         public IConfiguration _configuration { get; set; }
         public GroupListController(IWebHostEnvironment environment,CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, 
             AzureServiceBusFactory serviceBus, AzureStorageFactory azureStorage, IConfiguration configuration, AzureRedisFactory azureRedis)
@@ -833,8 +833,10 @@ namespace TEAMModelOS.Controllers
         [AuthToken(Roles = "teacher,admin")]
         [HttpPost("upsert-grouplist")]
         [Authorize(Roles = "IES")]
-        public async Task<IActionResult> UpsertGroupList(GroupList list)
+        public async Task<IActionResult> UpsertGroupList(JsonElement  json)
         {
+
+            GroupList list = json.ToObject<GroupList>();
             try
             {
                 var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();