赛事报名
This commit is contained in:
parent
c96e7a63b3
commit
95d991fe51
@ -212,6 +212,11 @@ public class UserEventDetailOutput
|
||||
/// 报名ID (如果已报名)
|
||||
/// </summary>
|
||||
public long? RegistrationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上级项目类型名称
|
||||
/// </summary>
|
||||
public string? ParentProjectTypeName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -34,6 +34,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
private readonly ISqlSugarRepository<EventUnit> _unitRepository;
|
||||
private readonly ISqlSugarRepository<EventProject> _eventProjectRepository;
|
||||
private readonly ISqlSugarRepository<YD_Event.Core.Entities.Project> _projectRepository;
|
||||
private readonly ISqlSugarRepository<ProjectType> _projectTypeRepository;
|
||||
private readonly ISqlSugarRepository<EventRegistration> _registrationRepository;
|
||||
private readonly ISqlSugarRepository<EventRegistrationItem> _registrationItemRepository;
|
||||
private readonly ISqlSugarRepository<EventRegistrationPerson> _registrationPersonRepository;
|
||||
@ -57,6 +58,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
ISqlSugarRepository<EventUnit> unitRepository,
|
||||
ISqlSugarRepository<EventProject> eventProjectRepository,
|
||||
ISqlSugarRepository<YD_Event.Core.Entities.Project> projectRepository,
|
||||
ISqlSugarRepository<ProjectType> projectTypeRepository,
|
||||
ISqlSugarRepository<EventRegistration> registrationRepository,
|
||||
ISqlSugarRepository<EventRegistrationItem> registrationItemRepository,
|
||||
ISqlSugarRepository<EventRegistrationPerson> registrationPersonRepository,
|
||||
@ -79,6 +81,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
_unitRepository = unitRepository;
|
||||
_eventProjectRepository = eventProjectRepository;
|
||||
_projectRepository = projectRepository;
|
||||
_projectTypeRepository = projectTypeRepository;
|
||||
_registrationRepository = registrationRepository;
|
||||
_registrationItemRepository = registrationItemRepository;
|
||||
_registrationPersonRepository = registrationPersonRepository;
|
||||
@ -190,7 +193,32 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
|
||||
var eventProjects = await _eventProjectRepository.GetListAsync(x => x.EventId == id);
|
||||
var projectIds = eventProjects.Select(x => x.ProjectId).Distinct().ToList();
|
||||
var baseProjects = await _projectRepository.GetListAsync(x => projectIds.Contains(x.Id) && x.Status == AvailabilityStatus.Enable);
|
||||
var baseProjects = await _projectRepository.AsQueryable()
|
||||
.LeftJoin<ProjectType>((p, t) => p.ProjectTypeId == t.Id)
|
||||
.Where(p => projectIds.Contains(p.Id) && p.Status == AvailabilityStatus.Enable)
|
||||
.Select((p, t) => new { p.Id, ProjectTypeId = t.Id })
|
||||
.ToListAsync();
|
||||
|
||||
// 获取所有项目类型
|
||||
var allProjectTypes = await _projectTypeRepository.AsQueryable()
|
||||
.Where(t => !t.DeleteMark && t.Status == AvailabilityStatus.Enable)
|
||||
.ToListAsync();
|
||||
|
||||
// 获取上级项目类型名称(如果有项目,取第一个项目的上级类型名称)
|
||||
string? parentProjectTypeName = null;
|
||||
if (baseProjects.Any())
|
||||
{
|
||||
var firstProject = baseProjects.First();
|
||||
var currentProjectType = allProjectTypes.FirstOrDefault(t => t.Id == firstProject.ProjectTypeId);
|
||||
if (currentProjectType != null && currentProjectType.ParentId > 0)
|
||||
{
|
||||
var parentProjectType = allProjectTypes.FirstOrDefault(t => t.Id == currentProjectType.ParentId);
|
||||
parentProjectTypeName = parentProjectType?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取完整的基础项目信息
|
||||
var fullBaseProjects = await _projectRepository.GetListAsync(x => projectIds.Contains(x.Id) && x.Status == AvailabilityStatus.Enable);
|
||||
|
||||
var completionStats = await _projectService.GetProjectStatisticsBatchAsync(
|
||||
projectIds,
|
||||
@ -198,7 +226,7 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
|
||||
output.Projects = eventProjects.Select(ep =>
|
||||
{
|
||||
var p = baseProjects.FirstOrDefault(b => b.Id == ep.ProjectId);
|
||||
var p = fullBaseProjects.FirstOrDefault(b => b.Id == ep.ProjectId);
|
||||
var completionCount = 0;
|
||||
if (p != null && completionStats.TryGetValue(p.Id, out var count))
|
||||
{
|
||||
@ -212,6 +240,9 @@ public class UserEventRegistrationService : IDynamicApiController, ITransient
|
||||
CompletionCount = completionCount
|
||||
};
|
||||
}).Where(x => !string.IsNullOrEmpty(x.Name)).ToList();
|
||||
|
||||
// 添加上级项目类型名称
|
||||
output.ParentProjectTypeName = parentProjectTypeName;
|
||||
|
||||
var userId = _authManager.UserId;
|
||||
var registration = await _registrationRepository.GetFirstAsync(x => x.EventId == id && x.CreatedUserId == userId && !x.DeleteMark);
|
||||
|
||||
@ -4385,6 +4385,11 @@
|
||||
报名ID (如果已报名)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Event.Dtos.UserEventDetailOutput.ParentProjectTypeName">
|
||||
<summary>
|
||||
上级项目类型名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Event.Dtos.UserEventLimitOutput">
|
||||
<summary>
|
||||
用户端赛事限制输出
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user