From 04acdd94b8eb370dfc1a90215c970372cdd1b111 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 3 Jun 2024 13:42:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=93=8D=E4=BD=9C=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E8=80=83=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_ExamController.cs | 13 ++++++++++++ .../Ghre/IGhre_ExamServices.cs | 2 ++ .../Ghre/Ghre_ExamServices.cs | 20 +++++++++++++++++++ 3 files changed, 35 insertions(+) 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