Compare commits

..

2 Commits

7 changed files with 9 additions and 10 deletions
@@ -3,7 +3,6 @@ using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using ModeusSchedule.Abstractions;
using ModeusSchedule.Abstractions.DTO;
using ModeusSchedule.Abstractions.DTO.Requests;
using SfeduSchedule.Services;
@@ -1,9 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.Text;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using ModeusSchedule.Abstractions.DTO;
using ModeusSchedule.Abstractions.DTO.Requests;
using SfeduSchedule.DTO.Responses;
using SfeduSchedule.Services;
@@ -47,7 +45,7 @@ public class ScheduleController(ModeusService modeusService, ModeusEmployeeServi
/// <response code="503">Сервис сотрудников не инициализирован</response>
[HttpGet]
[Route("searchemployee")]
public async Task<IActionResult> SearchEmployees([Required][MinLength(1)] string fullname)
public async Task<IActionResult> SearchEmployees(string fullname = "")
{
if (!modeusEmployeeService.IsInitialized())
return StatusCode(503, "Сервис сотрудников не инициализирован, попробуйте позже.");
-1
View File
@@ -1,4 +1,3 @@
using ModeusSchedule.Abstractions;
using Quartz;
using SfeduSchedule.Services;
-1
View File
@@ -8,7 +8,6 @@ using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Identity.Web;
using Microsoft.OpenApi.Models;
using ModeusSchedule.Abstractions;
using Prometheus;
using Quartz;
using Quartz.Listener;
@@ -1,5 +1,4 @@
using Quartz;
using SfeduSchedule.Jobs;
using System.Text.Json;
namespace SfeduSchedule.Services;
@@ -7,15 +6,22 @@ namespace SfeduSchedule.Services;
public class ModeusEmployeeService(ISchedulerFactory schedulerFactory)
: IHostedService
{
private Dictionary<string, (string, List<string>)> _employees = [];
private Dictionary<string, (string, List<string>)> _employees = []; //
private Task? _backgroundTask;
private CancellationTokenSource? _cts;
private readonly string _employeesFilePath = Path.Combine(Path.Combine(AppContext.BaseDirectory, AppConsts.DataFolderName), AppConsts.EmployeesFileName);
public async Task<Dictionary<string, (string, List<string>)>> GetEmployees(string fullname, int size = 10)
{
if (string.IsNullOrEmpty(fullname))
return _employees
.OrderBy(e => e.Key)
.Take(size)
.ToDictionary(e => e.Key, e => e.Value);
return _employees
.Where(e => e.Key.Contains(fullname, StringComparison.OrdinalIgnoreCase))
.OrderBy(e => e.Key)
.Take(size)
.ToDictionary(e => e.Key, e => e.Value);
}
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Text.Json;
using System.Net.Http.Json;
using Microsoft.Net.Http.Headers;
using ModeusSchedule.Abstractions;
using ModeusSchedule.Abstractions.DTO;
-1
View File
@@ -8,7 +8,6 @@ using ModeusSchedule.Abstractions;
using ModeusSchedule.Abstractions.DTO;
using ModeusSchedule.Abstractions.DTO.Requests;
using SfeduSchedule.DTO.Requests;
using SfeduSchedule.DTO.Responses;
using SfeduSchedule.Logging;
namespace SfeduSchedule.Services;