已发布试卷中的试题不可以被删除

草稿箱和已停用可以删除但是发布需要校验
master
xiaochanghai 1 year ago
parent 18d026b3d6
commit 851556bac8
  1. 1094
      Model/Tiobon.Web.pdm
  2. 2
      Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamRecordController.cs
  3. 2
      Tiobon.Core.IServices/Ghre/IGhre_ExamRecordServices.cs
  4. 13
      Tiobon.Core.Model/Base/Ghre/Ghre_ExamRecord.Dto.Base.cs
  5. 4
      Tiobon.Core.Model/Edit/Ghre/Ghre_ExamRecord.Dto.EditInput.cs
  6. 4
      Tiobon.Core.Model/Insert/Ghre/Ghre_ExamRecord.Dto.InsertInput.cs
  7. 15
      Tiobon.Core.Model/Models/Ghre/Ghre_ExamRecord.cs
  8. 4
      Tiobon.Core.Model/View/Ghre/Ghre_ExamRecord.Dto.View.cs
  9. 27
      Tiobon.Core.Services/CommonServices.cs
  10. 47
      Tiobon.Core.Services/Ghre/Ghre_ExamPaperServices.cs
  11. 2
      Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
namespace Tiobon.Core.Api.Controllers;
/// <summary>
/// Ghre_ExamRecord(Controller)
/// 考试记录(Controller)
/// </summary>
[Route("api/[controller]")]
[ApiController, GlobalActionFilter]

@ -4,7 +4,7 @@ using Tiobon.Core.Model.Models;
namespace Tiobon.Core.IServices
{
/// <summary>
/// Ghre_ExamRecord(自定义服务接口)
/// 考试记录(自定义服务接口)
/// </summary>
public interface IGhre_ExamRecordServices :IBaseServices<Ghre_ExamRecord, Ghre_ExamRecordDto, InsertGhre_ExamRecordInput, EditGhre_ExamRecordInput>
{

@ -6,7 +6,7 @@
*
* Ver
*
*V0.01 2024/5/31 17:43:01 SimonHsiao
*V0.01 2024/6/21 17:49:13 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
*
@ -22,7 +22,7 @@ namespace Tiobon.Core.Model.Models
{
/// <summary>
/// Ghre_ExamRecord (Dto.Base)
/// 考试记录 (Dto.Base)
/// </summary>
public class Ghre_ExamRecordBase
{
@ -65,14 +65,15 @@ namespace Tiobon.Core.Model.Models
public DateTime? EndTime { get; set; }
/// <summary>
/// 实际开始时间
/// 实际结束时间
/// </summary>
public DateTime? ActualBeginTime { get; set; }
public DateTime? ActualEndTime { get; set; }
/// <summary>
/// 实际结束时间
/// 状态
/// </summary>
public DateTime? ActualEndTime { get; set; }
[Display(Name = "Status"), Description("状态"), MaxLength(32, ErrorMessage = "状态 不能超过 32 个字符")]
public string Status { get; set; }
/// <summary>
/// 备注

@ -6,7 +6,7 @@
*
* Ver
*
*V0.01 2024/5/31 17:43:01 SimonHsiao
*V0.01 2024/6/21 17:49:13 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
*
@ -19,7 +19,7 @@ namespace Tiobon.Core.Model.Models
{
/// <summary>
/// Ghre_ExamRecord (Dto.EditInput)
/// 考试记录 (Dto.EditInput)
/// </summary>
public class EditGhre_ExamRecordInput : Ghre_ExamRecordBase
{

@ -6,7 +6,7 @@
*
* Ver
*
*V0.01 2024/5/31 17:43:01 SimonHsiao
*V0.01 2024/6/21 17:49:13 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
*
@ -19,7 +19,7 @@ namespace Tiobon.Core.Model.Models
{
/// <summary>
/// Ghre_ExamRecord (Dto.InsertInput)
/// 考试记录 (Dto.InsertInput)
/// </summary>
public class InsertGhre_ExamRecordInput : Ghre_ExamRecordBase
{

@ -6,7 +6,7 @@
*
* Ver
*
*V0.01 2024/5/31 17:43:01 SimonHsiao
*V0.01 2024/6/21 17:49:13 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
*
@ -23,9 +23,9 @@ namespace Tiobon.Core.Model.Models
{
/// <summary>
/// Ghre_ExamRecord (Model)
/// 考试记录 (Model)
/// </summary>
[SugarTable("Ghre_ExamRecord", "Ghre_ExamRecord"), Entity(TableCnName = "Ghre_ExamRecord", TableName = "Ghre_ExamRecord")]
[SugarTable("Ghre_ExamRecord", "Ghre_ExamRecord"), Entity(TableCnName = "考试记录", TableName = "Ghre_ExamRecord")]
public class Ghre_ExamRecord : BasePoco
{
@ -67,14 +67,15 @@ namespace Tiobon.Core.Model.Models
public DateTime? EndTime { get; set; }
/// <summary>
/// 实际开始时间
/// 实际结束时间
/// </summary>
public DateTime? ActualBeginTime { get; set; }
public DateTime? ActualEndTime { get; set; }
/// <summary>
/// 实际结束时间
/// 状态
/// </summary>
public DateTime? ActualEndTime { get; set; }
[Display(Name = "Status"), Description("状态"), MaxLength(32, ErrorMessage = "状态 不能超过 32 个字符")]
public string Status { get; set; }
/// <summary>
/// 备注

@ -6,7 +6,7 @@
*
* Ver
*
*V0.01 2024/5/31 17:43:01 SimonHsiao
*V0.01 2024/6/21 17:49:13 SimonHsiao
*
* Copyright(c) 2024 Tiobon Corporation. All Rights Reserved.
*
@ -18,7 +18,7 @@
namespace Tiobon.Core.Model.Models;
/// <summary>
/// Ghre_ExamRecord(Dto.View)
/// 考试记录(Dto.View)
/// </summary>
public class Ghre_ExamRecordDto : Ghre_ExamRecord
{

@ -891,6 +891,15 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-publish",
position = "left"
});
result.JM_PageControlT1.Toolbar.Add(new Toolbar()
{
display = true,
fnKey = "TBD6YN",
fnTitle = "预览",
fnType = "row",
icon = "ghr-preview",
position = "left"
});
break;
case "F_ExamPaperReleased":
@ -915,6 +924,15 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-icon-stop",
position = "left"
});
result.JM_PageControlT1.Toolbar.Add(new Toolbar()
{
display = true,
fnKey = "TBD6YN",
fnTitle = "预览",
fnType = "row",
icon = "ghr-preview",
position = "left"
});
break;
case "F_ExamPaperDisabled":
@ -930,6 +948,15 @@ public partial class CommonServices : BaseServices<RootEntityTkey<int>>, ICommon
icon = "ghr-icon-start",
position = "left"
});
result.JM_PageControlT1.Toolbar.Add(new Toolbar()
{
display = true,
fnKey = "TBD6YN",
fnTitle = "预览",
fnType = "row",
icon = "ghr-preview",
position = "left"
});
break;
case "F_Training_CoursewWare":
toolbar = result.JM_PageControlT1.Toolbar.Where(x => x.fnKey == "NewYN").FirstOrDefault();

@ -5,7 +5,6 @@ using System.Text.RegularExpressions;
using AgileObjects.AgileMapper;
using Microsoft.AspNetCore.Http;
using MongoDB.Driver.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tiobon.Core.Common;
@ -18,13 +17,13 @@ using Tiobon.Core.Model;
using Tiobon.Core.Model.Models;
using Tiobon.Core.Services.BASE;
namespace Tiobon.Core.Services
namespace Tiobon.Core.Services;
/// <summary>
/// 试卷 (服务)
/// </summary>
public class Ghre_ExamPaperServices : BaseServices<Ghre_ExamPaper, Ghre_ExamPaperDto, InsertGhre_ExamPaperInput, EditGhre_ExamPaperInput>, IGhre_ExamPaperServices
{
/// <summary>
/// 试卷 (服务)
/// </summary>
public class Ghre_ExamPaperServices : BaseServices<Ghre_ExamPaper, Ghre_ExamPaperDto, InsertGhre_ExamPaperInput, EditGhre_ExamPaperInput>, IGhre_ExamPaperServices
{
private readonly IGhre_ExamPaperConfigServices _ghre_ExamPaperConfigServices;
private readonly IGhre_ExamPaperQuestionServices _ghre_ExamPaperQuestionServices;
private readonly IGhre_QuestionServices _ghre_QuestionServices;
@ -32,6 +31,8 @@ namespace Tiobon.Core.Services
private readonly IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices;
private readonly IGhre_CourseServices _ghre_CourseServices;
private readonly IGhre_CourseSceneServices _ghre_CourseSceneServices;
private readonly IGhre_ExamServices _ghre_ExamServices;
private readonly IGhre_ExamRecordServices _ghre_ExamRecordServices;
private readonly IBaseRepository<Ghre_ExamPaper> _dal;
public Ghre_ExamPaperServices(IBaseRepository<Ghre_ExamPaper> dal,
@ -41,6 +42,8 @@ namespace Tiobon.Core.Services
IGhre_ExamPaperQuestionServices ghre_ExamPaperQuestionServices,
IGhre_CourseServices ghre_CourseServices,
IGhre_CourseSceneServices ghre_CourseSceneServices,
IGhre_ExamServices ghre_ExamServices,
IGhre_ExamRecordServices ghre_ExamRecordServices,
ICaching caching,
IGhrs_UserServices ghrs_UserServices)
{
@ -54,6 +57,8 @@ namespace Tiobon.Core.Services
_ghrs_UserServices = ghrs_UserServices;
_ghre_CourseServices = ghre_CourseServices;
_ghre_CourseSceneServices = ghre_CourseSceneServices;
_ghre_ExamServices = ghre_ExamServices;
_ghre_ExamRecordServices = ghre_ExamRecordServices;
}
public override async Task<Ghre_ExamPaperDto> QueryById(object objId)
@ -682,7 +687,7 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
(insert.LinkType == "CourseSceneId" && insert.LinkType != paper.LinkType)
)
{
var courses = await _ghre_CourseServices.Query(x =>x.Id == paper.LinkId && x.ExamPaperId.Contains(id.ObjToString()));
var courses = await _ghre_CourseServices.Query(x => x.Id == paper.LinkId && x.ExamPaperId.Contains(id.ObjToString()));
courses.ForEach(async x =>
{
var ids = JsonHelper.JsonToObj<List<long?>>(x.ExamPaperId);
@ -738,13 +743,32 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
var ip = GetUserIp(UserContext.Context);
List<Ghre_ExamPaper> entities = new List<Ghre_ExamPaper>();
foreach (var id in ids)
for (int i = 0; i < ids.Count(); i++)
{
if (id == null || !BaseDal.Any(id))
var id = ids[i];
if (!BaseDal.Any(id))
continue;
var entity = await BaseDal.QueryById(id);
#region 校验数据是否被引用
if (entity.Status == "Released" && (status == "Draft" || status == "Disabled"))//取消发布-停用
{
if (await _ghre_ExamServices.AnyAsync(x => x.ExamPaperId == id && x.Status == "Released"))
{
var exam = await _ghre_ExamServices.QuerySingleDto(x => x.ExamPaperId == id && x.Status == "Released");
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】已与考试【{exam.ExamName}({exam.ExamNo}】关联,暂不可{(status == "Draft" ? "" : "")}");
}
if (await _ghre_ExamRecordServices.AnyAsync(x => x.ExamPaperId == id && x.Status == "UnderWay"))
{
var exam = await _ghre_ExamRecordServices.QuerySingleDto(x => x.ExamPaperId == id && x.Status == "UnderWay");
return ServiceResult.OprateFailed($"试卷【{entity.PaperName}({entity.PaperNo})】,当前有学员正在考试中,暂不可{(status == "Draft" ? "" : "")}");
}
}
#endregion
BasePoco ent = entity;
ent.UpdateIP = ip;
ent.UpdateProg = api;
@ -755,6 +779,8 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
}
}
var result = await BaseDal.Update(entities);
if (status == "Released")
return ServiceResult.OprateSuccess("发布成功!");
@ -831,5 +857,4 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';");
return new ServiceResult<CommonSelect>() { Success = true, Message = "查询成功", Data = result, };
}
#endregion
}
}

@ -8,7 +8,7 @@ using Tiobon.Core.Common.Caches;
namespace Tiobon.Core.Services
{
/// <summary>
/// Ghre_ExamRecord (服务)
/// 考试记录 (服务)
/// </summary>
public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRecordDto, InsertGhre_ExamRecordInput, EditGhre_ExamRecordInput>, IGhre_ExamRecordServices
{

Loading…
Cancel
Save