diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs index 570916ac..07605249 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs @@ -113,4 +113,17 @@ public class Ghre_ExamController : BaseController + /// 开始考试 + /// + /// 考试ID + /// + [HttpPost("StartExam/{id}")] + public async Task StartExam(long id) + { + return await _service.StartExam(id); + } + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs index e35422a0..5afeb40b 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs @@ -22,5 +22,7 @@ namespace Tiobon.Core.IServices Task UpdateStatus(long[] ids, string status); Task GetStatus(long id); + + Task StartExam(long id); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 283ef95a..1f0be6b2 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -639,4 +639,24 @@ public class Ghre_ExamServices : BaseServices StartExam(long id) + { + + if (!await _ghre_ExamRecordServices.AnyAsync(x => x.ExamId == id)) + { + var exam = await base.QueryById(id); + var insrt = new InsertGhre_ExamRecordInput() + { + ExamId = id, + UserId = UserContext.Current.User_Id, + ActualBeginTime = DateTime.Now, + ExamPaperId = exam.ExamPaperId + }; + await _ghre_ExamRecordServices.Add(insrt); + } + + return ServiceResult.OprateSuccess("操作成功!"); + + } } \ No newline at end of file