diff --git a/YD_Event.Application/Event/Dtos/EventDtos.cs b/YD_Event.Application/Event/Dtos/EventDtos.cs index 85d20d4..7eea00f 100644 --- a/YD_Event.Application/Event/Dtos/EventDtos.cs +++ b/YD_Event.Application/Event/Dtos/EventDtos.cs @@ -553,6 +553,11 @@ public class EventDetailOutput : AddEventInput /// 退款规则详情列表 /// public List? RefundRules { get; set; } + + /// + /// 是否可以编辑项目信息(有报名记录时不能编辑项目和组别 + /// + public bool CanEditProject { get; set; } } /// diff --git a/YD_Event.Application/Event/EventService.cs b/YD_Event.Application/Event/EventService.cs index 1a7018c..3847250 100644 --- a/YD_Event.Application/Event/EventService.cs +++ b/YD_Event.Application/Event/EventService.cs @@ -150,6 +150,10 @@ public class EventService : BaseService, ITransient var output = eventInfo.Adapt(); + // 检查是否有报名记录,决定是否可以编辑项目(有报名记录时不能编辑项目和组别 + var hasRegistration = await _registrationRepository.IsAnyAsync(x => x.EventId == id && !x.DeleteMark); + output.CanEditProject = !hasRegistration; + // 1. 获取参与单位 var units = await _unitRepository.GetListAsync(x => x.EventId == id); if (units.Any()) @@ -525,8 +529,8 @@ public class EventService : BaseService, ITransient var eventInfo = await _repository.GetByIdAsync(input.Id); if (eventInfo == null) throw new InvalidOperationException("赛事不存在"); - // 检查是否有报名记录:如果有人报名,检查是否修改了项目和组别 - var hasRegistration = await _registrationRepository.IsAnyAsync(x => x.EventId == input.Id); + // 检查是否有报名记录:如果有人报名,检查是否修改了项目和组别(软删除的不算) + var hasRegistration = await _registrationRepository.IsAnyAsync(x => x.EventId == input.Id && !x.DeleteMark); if (hasRegistration) { var hasProjectOrGroupChange = await CheckIfProjectsOrGroupsChanged(input, eventInfo.Id); @@ -1067,7 +1071,7 @@ public class EventService : BaseService, ITransient [DisplayName("删除赛事")] public override async Task Delete(KeyDto dto) { - if (await _registrationRepository.IsAnyAsync(x => x.EventId == dto.Id)) + if (await _registrationRepository.IsAnyAsync(x => x.EventId == dto.Id && !x.DeleteMark)) { throw new InvalidOperationException("已有人员报名此赛事,暂不支持删除"); } @@ -1188,8 +1192,8 @@ public class EventService : BaseService, ITransient throw new InvalidOperationException("请先完成参与单位配置"); } - // 检查是否有报名记录:如果有人报名,检查是否修改了项目和组别 - var hasRegistration = await _registrationRepository.IsAnyAsync(x => x.EventId == input.EventId); + // 检查是否有报名记录:如果有人报名,检查是否修改了项目和组别(软删除的不算) + var hasRegistration = await _registrationRepository.IsAnyAsync(x => x.EventId == input.EventId && !x.DeleteMark); if (hasRegistration) { var oldEventProjects = await _eventProjectRepository.GetListAsync(x => x.EventId == input.EventId && !x.DeleteMark); diff --git a/YD_Event.Application/YD_Event.Application.xml b/YD_Event.Application/YD_Event.Application.xml index 0810be6..9a399b7 100644 --- a/YD_Event.Application/YD_Event.Application.xml +++ b/YD_Event.Application/YD_Event.Application.xml @@ -4975,6 +4975,11 @@ 退款规则详情列表 + + + 是否可以编辑项目信息(有报名记录时不能编辑项目和组别 + + 积分规则明细DTO