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