public async Task <dynamic> OnPostAsync([FromForm] Course course, [FromForm] List <string> teachers, [FromForm] string token) { try { var t = await tokenService.GetTokenAsync(token); if (t == null) { throw new Exception("请先登录"); } if (t.Role != UserRole.Admin) { throw new Exception("权限不足"); } var id = await courseService.AddCourseAysnc(course); foreach (var teacher in teachers) { await courseService.AddTeacherToCouseAsync(id, teacher); } return(new { Res = true, CourseID = id }); } catch (Exception e) { return(new { Res = false, Error = e.Message }); } }