diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQuery.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQuery.cs similarity index 80% rename from ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQuery.cs rename to ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQuery.cs index 22f6c800..8e9e292d 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQuery.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQuery.cs @@ -6,6 +6,6 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProj /// درخواست جستجو در سراسر سلسله‌مراتب پروژه (پروژه، فاز، تسک). /// نتایج با اطلاعات مسیر سلسله‌مراتب برای پشتیبانی از ناوبری درخت در رابط کاربری بازگردانده می‌شود. /// -public record GetProjectHierarchySearchQuery( - string SearchQuery) : IBaseQuery; +public record GetProjectSearchQuery( + string SearchQuery) : IBaseQuery; \ No newline at end of file diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQueryHandler.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQueryHandler.cs similarity index 82% rename from ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQueryHandler.cs rename to ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQueryHandler.cs index 2e20e5e6..e9cb3c25 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQueryHandler.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQueryHandler.cs @@ -10,18 +10,18 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProj /// این handler در تمام سطح‌های پروژه، فاز و تسک جستجو می‌کند و از تمام فیلدهای متنی (نام، توضیحات) استفاده می‌کند. /// همچنین در زیرمجموعه‌های هر سطح (ProjectSections، PhaseSections، TaskSections) جستجو می‌کند. /// -public class GetProjectHierarchySearchQueryHandler : IBaseQueryHandler +public class GetProjectSearchQueryHandler : IBaseQueryHandler { private readonly IProgramManagerDbContext _context; private const int MaxResults = 50; - public GetProjectHierarchySearchQueryHandler(IProgramManagerDbContext context) + public GetProjectSearchQueryHandler(IProgramManagerDbContext context) { _context = context; } - public async Task> Handle( - GetProjectHierarchySearchQuery request, + public async Task> Handle( + GetProjectSearchQuery request, CancellationToken cancellationToken) { var searchQuery = request.SearchQuery.ToLower(); @@ -41,13 +41,13 @@ public class GetProjectHierarchySearchQueryHandler : IBaseQueryHandler GetLevelOrder(r.Level)) + .OrderBy(r => r.Level) .ThenBy(r => r.Title) .Take(MaxResults) .ToList(); - var response = new GetProjectHierarchySearchResponse(sortedResults); - return OperationResult.Success(response); + var response = new GetProjectSearchResponse(sortedResults); + return OperationResult.Success(response); } /// @@ -66,7 +66,7 @@ public class GetProjectHierarchySearchQueryHandler : IBaseQueryHandler - /// ترتیب سطح برای مرتب‌سازی: پروژه (1) → فاز (2) → تسک (3) - /// - private static int GetLevelOrder(ProjectHierarchyLevel level) - { - return level switch - { - ProjectHierarchyLevel.Project => 1, - ProjectHierarchyLevel.Phase => 2, - ProjectHierarchyLevel.Task => 3, - _ => 4 - }; - } + } diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQueryValidator.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQueryValidator.cs similarity index 79% rename from ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQueryValidator.cs rename to ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQueryValidator.cs index 4a32fd92..70c25241 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchQueryValidator.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchQueryValidator.cs @@ -5,9 +5,9 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProj /// /// اعتبارسنج برای درخواست جستجوی سراسری /// -public class GetProjectHierarchySearchQueryValidator : AbstractValidator +public class GetProjectSearchQueryValidator : AbstractValidator { - public GetProjectHierarchySearchQueryValidator() + public GetProjectSearchQueryValidator() { RuleFor(x => x.SearchQuery) .NotEmpty().WithMessage("متن جستجو نمی‌تواند خالی باشد.") diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchResponse.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchResponse.cs similarity index 84% rename from ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchResponse.cs rename to ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchResponse.cs index b03fb96e..288206f7 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectHierarchySearchResponse.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/GetProjectSearchResponse.cs @@ -3,6 +3,6 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.GetProj /// /// پوسته‌ی پاسخ برای نتایج جستجوی سراسری /// -public record GetProjectHierarchySearchResponse( +public record GetProjectSearchResponse( List Results); diff --git a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/ProjectHierarchySearchResultDto.cs b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/ProjectHierarchySearchResultDto.cs index 8a8b70ff..036d3a8b 100644 --- a/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/ProjectHierarchySearchResultDto.cs +++ b/ProgramManager/src/Application/GozareshgirProgramManager.Application/Modules/Projects/Queries/GetProjectHierarchySearch/ProjectHierarchySearchResultDto.cs @@ -26,7 +26,7 @@ public record ProjectHierarchySearchResultDto /// /// شناسه پروژه - همیشه برای فاز و تسک پر شده است، برای پروژه با شناسه خود پر می‌شود /// - public Guid ProjectId { get; init; } + public Guid? ProjectId { get; init; } /// /// شناسه فاز - فقط برای تسک پر شده است، برای پروژه و فاز خالی است diff --git a/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs b/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs index a2c21899..bf9617a5 100644 --- a/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs +++ b/ServiceHost/Areas/Admin/Controllers/ProgramManager/ProjectController.cs @@ -42,10 +42,10 @@ public class ProjectController : ProgramManagerBaseController } [HttpGet("search")] - public async Task>> Search( + public async Task>> Search( [FromQuery] string query) { - var searchQuery = new GetProjectHierarchySearchQuery(query); + var searchQuery = new GetProjectSearchQuery(query); var res = await _mediator.Send(searchQuery); return res; }