public async Task <dynamic> OnSetStuHWScoreAsync([FromForm] string stuID, [FromForm] int hwID, [FromForm] int score, [FromForm] string comment, [FromForm] string token) { try { var t = await tokenService.GetTokenAsync(token); if (t == null) { throw new Exception("请先登录"); } var role = t.Role; if (role != UserRole.Admin) { role = await homeworkService.GetHWRoleAsync(hwID, t.UserID); } if (role == UserRole.Student) { throw new Exception("权限不足"); } await homeworkService.SetStuHomeworkScoreAsync(stuID, hwID, score, comment); return(new { Res = true }); } catch (Exception e) { return(new { Res = false, Error = e.Message }); } }