From f2f6aa982fef63d4e74a3fa9d7aea45f2b51e200 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 3 Jun 2024 17:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E8=AF=95=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=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 | 14 +++++++++++ .../Ghre/IGhre_ExamServices.cs | 2 ++ .../Ghre/Ghre_ExamServices.cs | 24 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs index 07605249..eb8e9aef 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs @@ -126,4 +126,18 @@ public class Ghre_ExamController : BaseController + /// 复制 + /// + /// 考试ID + /// + [HttpPost("Copy/{id}")] + public async Task Copy(long id) + { + return await _service.Copy(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 5afeb40b..c5b5a8e6 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs @@ -24,5 +24,7 @@ namespace Tiobon.Core.IServices Task GetStatus(long id); Task StartExam(long id); + + Task Copy(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 48df07c9..14e572c8 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -15,6 +15,7 @@ using Tiobon.Core.Common.Helper; using Microsoft.AspNetCore.Http; using Tiobon.Core.Common.UserManager; using MathNet.Numerics.Distributions; +using System.Drawing.Drawing2D; namespace Tiobon.Core.Services; @@ -323,6 +324,12 @@ public class Ghre_ExamServices : BaseServices Copy(long id) + { + var exam = await base.QueryById(id); + var staffs = await _ghre_ExamStaffServices.Query(x => x.ExamId == id); + exam.Status = "Draft"; + + var insert = Mapper.Map(exam).ToANew(); + var insertStaffs = Mapper.Map(exam).ToANew>(); + id = await base.Add(insert); + insertStaffs.ForEach(x => x.ExamId = id); + await _ghre_ExamStaffServices.Add(insertStaffs); + + return ServiceResult.OprateSuccess("复制成功!"); + + } } \ No newline at end of file