diff --git a/Controllers/SubmissionController.cs b/Controllers/SubmissionController.cs index b2defa5..b62dfd1 100644 --- a/Controllers/SubmissionController.cs +++ b/Controllers/SubmissionController.cs @@ -79,4 +79,48 @@ namespace _2021_backend.Controllers //return Ok(ApiResponse.Success("报名结束了")); } } + + [ApiController] + [Route("api/postsession")] + public class PostsessionController : Controller + { + private readonly BackendContext Context; + public PostsessionController(BackendContext context) + { + Context = context; + } + [HttpPost] + + public async Task Post([FromQuery] string stuid, [FromQuery] string selection) + { + Student stu = Context.Students.FirstOrDefault(r => r.Stuid == stuid); + if (stu == null) + { + return StatusCode(400, ApiResponse.Error("INVALID_STUDENT_GUID")); + } + List timelist; + try + { + timelist = JsonSerializer.Deserialize>(selection); + } + catch (Exception ex) + { + Console.WriteLine(ex); + return StatusCode(400, ApiResponse.Error("MALFORMED_DATA")); + }; + //get the selected session guids; + List targetSessions; + var sessions = Context.Sessions.ToList(); + targetSessions = sessions.FindAll((Session s) => + { + return timelist.Any(it => it.Day == s.Day && it.BeginTime == s.BeginTime); + }).Select(it => it.Guid).ToList(); + stu.Timelist = targetSessions; + stu.Status = status.已选时间; + await Context.SaveChangesAsync(); + return Ok(ApiResponse.Success("success")); + //return Ok(ApiResponse.Success("报名结束了")); + + } + } } \ No newline at end of file diff --git a/Pages/Message/Index.cshtml b/Pages/Message/Index.cshtml index 87535dd..3b06dbd 100644 --- a/Pages/Message/Index.cshtml +++ b/Pages/Message/Index.cshtml @@ -14,6 +14,7 @@ +
diff --git a/Pages/Message/Index.cshtml.cs b/Pages/Message/Index.cshtml.cs index c05c75a..026241f 100644 --- a/Pages/Message/Index.cshtml.cs +++ b/Pages/Message/Index.cshtml.cs @@ -114,6 +114,20 @@ namespace _2021_backend.Pages.Message return Construct(PageId); } + public async Task OnPostTimeSelectAsync(int PageId) + { + var stu = Context.Students.ToList(); + foreach (var e in stu) + { + if (e.Status != status.不通过) + { + await Utils.TencentSMS.Send(Context, SMSType.TimeSelect, e, Context.Users.Find(Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value)).Name); + } + } + Context.SaveChanges(); + return Construct(PageId); + } + public async Task OnPostResultAccpetAsync(int PageId) { var stu = Context.Students.ToList(); diff --git a/Pages/Students/Index.cshtml b/Pages/Students/Index.cshtml index 6f1137a..139225a 100644 --- a/Pages/Students/Index.cshtml +++ b/Pages/Students/Index.cshtml @@ -34,6 +34,7 @@ + diff --git a/Pages/Students/Index.cshtml.cs b/Pages/Students/Index.cshtml.cs index fb75ded..be0503f 100644 --- a/Pages/Students/Index.cshtml.cs +++ b/Pages/Students/Index.cshtml.cs @@ -93,5 +93,17 @@ namespace _2021_backend.Pages.Students if (pageId == null) pageId = 0; return Construct((int)pageId, errInfo); } + + public async Task OnPostFinalizeAsync(int? pageId, string errInfo) + { + if (pageId == null) pageId = 0; + + foreach(var s in Context.Students) + { + if (s.RegisterTime.CompareTo(new DateTime(2021, 11, 11)) < 0) s.Status = status.不通过; + } + Context.SaveChanges(); + return Construct((int)pageId, errInfo); + } } } diff --git a/Utils/TencentSMS.cs b/Utils/TencentSMS.cs index e64f610..f581072 100644 --- a/Utils/TencentSMS.cs +++ b/Utils/TencentSMS.cs @@ -131,7 +131,7 @@ namespace _2021_backend.Utils case SMSType.TimeSelect: sms.Type = SMSType.TimeSelect; req.TemplateId = SMSID_timeSelect; - req.TemplateParamSet = new string[] { stu.Name, stu.Stuid }; + req.TemplateParamSet = new string[] { stu.Name }; break; case SMSType.TimeSet: sms.Type = SMSType.TimeSet; diff --git a/appsettings.json b/appsettings.json index fd37739..35c49d2 100644 --- a/appsettings.json +++ b/appsettings.json @@ -14,7 +14,7 @@ "SMS_ID_REJECT": "1089595", "SMS_ID_SUBMITTED": "1163892", "SMS_ID_TIMESET": "1131089", - "SMS_ID_TIMESELECT": "1131090", + "SMS_ID_TIMESELECT": "1210823", "TENCENT_ID": "AKIDYv5JGwKSJtCE0VjhOpyqSotgDTSaYIsF", "TENCENT_KEY": "mPzSimdGenpdCWcT5TcWBboreAQQ9bmh", "SMSBOT_NAME": "msgbot", diff --git a/students.txt b/students.txt index c795b05..a24351e 100644 --- a/students.txt +++ b/students.txt @@ -1 +1 @@ -build \ No newline at end of file +张峻瑜 6 180 27-09:00-204 27-13:00-204 27-15:30-204 28-13:00-204 28-15:30-204 28-18:30-204