From 9e5a494881ef2df477861d1c7224f3d06e057705 Mon Sep 17 00:00:00 2001 From: mahan Date: Tue, 16 Dec 2025 14:18:00 +0330 Subject: [PATCH] feat: enhance project board query with skill and user details --- .../SetTimeProjectCommandValidator.cs | 18 +++++++++++++++--- .../ProjectBoardListQueryHandler.cs | 15 ++++++++++++--- .../ProjectBoardListResponse.cs | 4 ++++ ServiceHost/appsettings.Development.json | 2 +- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandValidator.cs index 7fb182b7..c47ef658 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandValidator.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Commands/SetTimeProject/SetTimeProjectCommandValidator.cs @@ -1,4 +1,5 @@ using FluentValidation; +using FluentValidation.Validators; using GozareshgirProgramManager.Application.Modules.Projects.DTOs; namespace GozareshgirProgramManager.Application.Modules.Projects.Commands.SetTimeProject; @@ -15,6 +16,9 @@ public class SetTimeProjectCommandValidator:AbstractValidator x.SectionItems) .SetValidator(command => new SetTimeProjectSectionItemValidator()); + RuleFor(x => x.SectionItems) + .Must(sectionItems => sectionItems.Any(si => si.InitData?.Hours > 0)) + .WithMessage("حداقل یکی از بخش‌ها باید مقدار ساعت معتبری داشته باشد."); } } public class SetTimeProjectSectionItemValidator:AbstractValidator @@ -30,13 +34,14 @@ public class SetTimeProjectSectionItemValidator:AbstractValidatorx.AdditionalTime) - .SetValidator(new TimeDataValidator()); + .SetValidator(new AdditionalTimeDataValidator()); + } } -public class TimeDataValidator : AbstractValidator +public class AdditionalTimeDataValidator: AbstractValidator { - public TimeDataValidator() + public AdditionalTimeDataValidator() { RuleFor(x => x.Hours) .GreaterThanOrEqualTo(0) @@ -45,6 +50,13 @@ public class TimeDataValidator : AbstractValidator RuleFor(x=>x.Description) .MaximumLength(500) .WithMessage("توضیحات نمی‌تواند بیشتر از 500 کاراکتر باشد."); + } +} + +public class TimeDataValidator : AbstractValidator +{ + public TimeDataValidator() + { } } \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListQueryHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListQueryHandler.cs index 4ee9564e..740758be 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListQueryHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListQueryHandler.cs @@ -28,7 +28,8 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler x.Phase) .ThenInclude(x => x.Project) .Include(x => x.Activities) - .Include(x => x.AdditionalTimes).AsQueryable(); + .Include(x => x.AdditionalTimes).AsQueryable(). + Include(x => x.Skill).AsQueryable(); if (!_authHelper.HasPermission(ProgramManagerPermissionCode.Board.All.ViewAll)) { @@ -42,10 +43,14 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler x.Activities).Select(a => a.UserId).Distinct().ToList(); + var assignedUser = data.Select(x => x.CurrentAssignedUserId) + .Concat(data.Select(x => x.OriginalAssignedUserId)).ToList(); + var allUserIds = activityUserIds.Concat(assignedUser).Distinct().ToList(); var users = await _programManagerDbContext.Users.AsNoTracking() - .Where(x => activityUserIds.Contains(x.Id)) + .Where(x => allUserIds.Contains(x.Id)) .Select(x => new { x.Id, x.FullName }) .ToDictionaryAsync(x => x.Id, x => x.FullName, cancellationToken); + var result = data.Select(x => { @@ -101,7 +106,11 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler a.TotalSeconds), Histories = mergedHistories - } + }, + OriginalUser = users.GetValueOrDefault(x.OriginalAssignedUserId, "ناشناس"), + AssignedUser = x.CurrentAssignedUserId == x.OriginalAssignedUserId ? null + : users.GetValueOrDefault(x.CurrentAssignedUserId, "ناشناس"), + SkillName = x.Skill?.Name??"-", }; }).ToList(); diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListResponse.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListResponse.cs index 83421e89..ab38750e 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListResponse.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/ProjectBoardList/ProjectBoardListResponse.cs @@ -10,6 +10,10 @@ public class ProjectBoardListResponse public string TaskName { get; set; } public ProjectProgressDto Progress { get; set; } public TaskSectionStatus SectionStatus { get; set; } + public string? AssignedUser { get; set; } + public string OriginalUser { get; set; } + public string SkillName { get; set; } + } public class ProjectProgressDto { diff --git a/ServiceHost/appsettings.Development.json b/ServiceHost/appsettings.Development.json index 684aa6aa..d892b51d 100644 --- a/ServiceHost/appsettings.Development.json +++ b/ServiceHost/appsettings.Development.json @@ -28,7 +28,7 @@ //program_manager_db "ProgramManagerDb": "Data Source=.;Initial Catalog=program_manager_db;Integrated Security=True;TrustServerCertificate=true;", //"ProgramManagerDb": "Data Source=185.208.175.186;Initial Catalog=program_manager_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;" - //"ProgramManagerDbServer": "Data Source=171.22.24.15;Initial Catalog=program_manager_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;" + "ProgramManagerDbServer": "Data Source=171.22.24.15;Initial Catalog=program_manager_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;" //mahan Docker //"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;" },