CrazyIter_Bin há 1 ano atrás
pai
commit
4e33f586ac

+ 37 - 4
TEAMModelOS.SDK/Models/Cosmos/Common/Activity.cs

@@ -21,7 +21,9 @@ namespace TEAMModelOS.SDK.Models
         public string subject { get; set; }
         public string description { get; set; }
         public string address { get; set; }
+        [Range(1697622366000, 4102415999000, ErrorMessage = $"时间范围错误")]
         public long stime { get; set; }
+        [Range(1697622366000, 4102415999000, ErrorMessage = $"时间范围错误")]
         public long etime { get; set; }
         public string poster { get; set; }
         public List<Attachment> attachment { get; set; } = new List<Attachment>();
@@ -33,7 +35,7 @@ namespace TEAMModelOS.SDK.Models
         [Required(ErrorMessage = "Required")]
         public string owner { get; set; }
         /// <summary>
-        /// "public公开/area区级/school校级",
+        /// "public公开/area区级/school校级",  public公开活动 只能是醍摩豆智慧学区才能选择,
         /// </summary>
         [Required(ErrorMessage = "Required")]
         public string scope { get; set; }
@@ -45,14 +47,16 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// //区级活动时允许参与的学校,如果为空则全部学校
         /// </summary>
-        public List<IdNamePicture> schools { get; set; } = new List<IdNamePicture>();
+        public List<ActivitySchool > schools { get; set; } = new List<ActivitySchool>();
         /// <summary>
         /// //邀请制,允许参加的教师
         /// </summary>
-        public List<IdNameSchool> inviteTeachers { get; set; } = new List<IdNameSchool>();
+        public List<ActivityTeacher> inviteTeachers { get; set; } = new List<ActivityTeacher>();
         /// <summary>
         /// 模块"Contest/赛课活动",  "Training/线上培训", "Research/教研活动"
         /// </summary>
+        [Required(ErrorMessage = "模块不能为空")]
+        [MinLength(1, ErrorMessage = "模块不能为空")]
         public List<string> modules { get; set; } = new List<string>();
         /// <summary>
         /// 本次活动的评审专家
@@ -70,6 +74,33 @@ namespace TEAMModelOS.SDK.Models
         /// 创建者
         /// </summary>
         public string creatorId { get; set; }
+        /// <summary>
+        /// 0未发布,1已发布,2.已结束
+        /// </summary>
+        public int publish { get; set; }
+    }
+
+    public class ActivityTeacher
+    {
+        public string id { get; set; }
+        public string name { get; set; }
+        public string picture { get; set; }
+        public string school { get; set; }
+        /// <summary>
+        /// 0 未确认,1已确认,用于区级发布, publish=1,joinMode=invite,学校可以去进行邀请某一些教师。
+        /// </summary>
+        public int status { get; set; }
+    }
+    public class ActivitySchool
+    {
+        public string id { get; set; }
+        public string name { get; set; }
+        public string picture { get; set; }
+        public string school { get; set; }
+        /// <summary>
+        /// 0 未确认,1已确认,用于区级发布, publish=1,joinMode=invite,学校可以去进行邀请某一些教师。
+        /// </summary>
+        public int status { get; set; }
     }
 
     /// <summary>
@@ -86,10 +117,12 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         ///  //参加活动获得积分。根据最后评委打分,0-100的比例获得积分,不足一分按一分计算。
         /// </summary>
-        public int balance { get; set; }
+        public int balance { get; set; } = 0;
         /// <summary>
         /// "sign","upload","review","score"//报名模块,上传作品模块,评审模块,成绩公布模块
         /// </summary>
+        [Required(ErrorMessage = "优课评选子模块不能为空")]
+        [MinLength(1, ErrorMessage = "优课评选子模块不能为空")]
         public List<string> modules { get; set; } = new List<string>();
 
         public ContestSign sign { get; set; }

+ 1 - 13
TEAMModelOS.SDK/Models/Cosmos/Common/GroupList.cs

@@ -487,19 +487,7 @@ namespace TEAMModelOS.SDK.Models
         public string stulist { get; set; }
         public string teacherId { get; set; }
     }
-    public class IdNamePicture
-    {
-        public string id { get; set; }
-        public string name { get; set; }
-        public string picture { get; set; }
-    }
-    public class IdNameSchool
-    {
-        public string id { get; set; }
-        public string name { get; set; }
-        public string picture { get; set; }
-        public string school { get; set; }
-    }
+    
     public class IdNameCode
     {
         public string id { get; set; }

+ 1 - 1
TEAMModelOS/Controllers/Both/CourseBaseController.cs

@@ -530,7 +530,7 @@ namespace TEAMModelOS.Controllers.Both
                                     }
                                 }else
                                 {
-                                    var groupList =   await GroupListService.GetMemberByListids(_coreAPIHttpService,  _azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school);
+                                    var groupList =   await GroupListService.GetMemberByListids(_coreAPIHttpService,_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school);
                                     groups= groupList.groups.Select(z => new GroupListDto(z)).ToList();
                                     string teacherSQLBase = $"select     c.id,c.name,c.picture from c where  c.id   in ({string.Join(",", teacherIds.Select(z => $"'{z}'"))}) ";
                                     var resultBase = await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<IdNameCode>(teacherSQLBase, $"Base");

+ 54 - 6
TEAMModelOS/Controllers/Common/ActivityController.cs

@@ -80,6 +80,17 @@ namespace TEAMModelOS.Controllers
                             activity.id=!string.IsNullOrWhiteSpace(activity.id)?activity.id: Guid.NewGuid().ToString();
                             activity.code="Activity";
                             activity.pk="Activity";
+
+                            //如果是区级活动,enroll报名制,则学校的确认状态默认为1 。
+                            if (activity.scope.Equals("area", StringComparison.OrdinalIgnoreCase) && activity.joinMode.Equals("enroll", StringComparison.OrdinalIgnoreCase)) 
+                            {
+                                activity.schools.ForEach(z => z.status=1);
+                            }
+                            //醍摩豆智慧学区
+                            if (!activity.owner.Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)  && activity.scope.Equals("public", StringComparison.OrdinalIgnoreCase))
+                            {
+                                 return Ok(new { error = ResponseCode._400ParamsError, msg = "公开的活动只能由醍摩豆智慧学区发布!" });
+                            }
                             ValidResult validResult = activity.Valid();
                             if (validResult.isVaild)
                             {
@@ -92,12 +103,24 @@ namespace TEAMModelOS.Controllers
                                         //赛课
                                         case bool when module.Equals("Contest"):
                                             {
-                                                if (!request.TryGetProperty("Contest", out JsonElement _contest)) return Ok(new { error = ResponseCode._400ParamsError, msg = "赛课信息参数错误" });
+                                                if (!request.TryGetProperty("Contest", out JsonElement _contest))
+                                                {
+                                                    return Ok(new { error = ResponseCode._400ParamsError, msg = "赛课信息参数错误" });
+                                                }
                                                 Contest contest = _activity.ToObject<Contest>();
-                                                contest.id=activity.id;
-                                                contest.code="Contest";
-                                                contest.pk="Contest";
-
+                                                if (contest!=null) {
+                                                    contest.id=activity.id;
+                                                    contest.code="Contest";
+                                                    contest.pk="Contest";
+                                                    ValidResult validResultContest = contest.Valid();
+                                                    if (validResultContest.isVaild)
+                                                    {
+                                                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(contest, new PartitionKey(contest.code));
+                                                    }
+                                                    else {
+                                                        return Ok(validResult);
+                                                    }
+                                                }
                                                 break;
                                             }
                                         //培训
@@ -112,6 +135,8 @@ namespace TEAMModelOS.Controllers
                                             }
                                     }
                                 }
+                                //保存活动基础信息
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(activity, new PartitionKey(activity.code));
                             }
                             else
                             {
@@ -119,7 +144,30 @@ namespace TEAMModelOS.Controllers
                             }
                             break;
                         }
-                   
+                    case bool when $"{grant_type}".Equals("list-area", StringComparison.OrdinalIgnoreCase):
+                        {
+                            if (!request.TryGetProperty("areaId", out JsonElement _areaId)) return BadRequest();
+                            string sql = $"select value c from c where c.scope='area' and c.owner='{_areaId}'  ";
+                            //醍摩豆智慧学区
+                            if (_areaId.GetString().Equals("02944f32-f534-3397-ea56-e6f1fc6c3714", StringComparison.OrdinalIgnoreCase)) {
+                                sql = $"select value c from c where   c.owner='{_areaId}' and ( c.scope='area' or c.scope='public' ) ";
+                            }
+                            var  result =  await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<Activity>(sql, "Activity");
+                            return Ok(new { activities = result.list.OrderByDescending(z=>z.stime) });
+                        }
+                    case bool when $"{grant_type}".Equals("list-school", StringComparison.OrdinalIgnoreCase):
+                        {
+                            break;
+                        }
+                 
+                    case bool when $"{grant_type}".Equals("list-teacher", StringComparison.OrdinalIgnoreCase):
+                        {
+                            break;
+                        }
+                    case bool when $"{grant_type}".Equals("list-portal", StringComparison.OrdinalIgnoreCase):
+                        {
+                            break;
+                        }
                 }
             }catch (Exception ex)
             {