From 57fe9eff09035ccfd829ebd41e3bc0d06bbc80b0 Mon Sep 17 00:00:00 2001 From: Mikhail Kuznetsov Date: Fri, 16 Jun 2023 15:00:11 +1000 Subject: [PATCH] API --- PARR.API/Contracts/V1/ApiRoutes.cs | 19 +- .../V1/Requests/Queries/PaginationQuery.cs | 57 ++++ .../Requests/Queries/SchedulerGetAllQuery.cs | 15 + .../Requests/Queries/SchedulerGetByIpQuery.cs | 7 + .../V1/Responses/ApiHealthResponse.cs | 6 + .../V1/Responses/ApiVersionResponse.cs | 9 + .../V1/Responses/Base/BaseResponse.cs | 29 ++ .../Contracts/V1/Responses/Base/ErrorModel.cs | 9 + .../V1/Responses/Base/PagedResponse.cs | 29 ++ .../Contracts/V1/Responses/Base/Response.cs | 57 ++++ .../V1/Responses/SchedulerResponse.cs | 21 ++ .../Controllers/V1/ApiStatusController.cs | 44 ++- PARR.API/Controllers/V1/HomeController.cs | 26 -- .../Controllers/V1/ShchedullerController.cs | 78 +++++ PARR.API/Extensions/PaginationExtensions.cs | 59 ++++ PARR.API/Installers/ApiServicesInstaller.cs | 2 +- PARR.API/Installers/SwaggerInstaller.cs | 4 +- .../DomainToResponseProfile.cs | 8 +- .../MappingProfiles/RequestToDomainProfile.cs | 4 +- PARR.API/PARR.API.csproj | 2 - .../Services/Implementations/ClientService.cs | 19 ++ .../Services/Interfaces/IClientService.cs | 9 + PARR.DAL/Context/DataContext.cs | 31 ++ PARR.DAL/DomainModels/PaginationFilter.cs | 8 + .../20230519051342_AllTbls.Designer.cs | 315 ------------------ .../Migrations/20230601014714_UpdTblHosts.cs | 98 ------ ...ner.cs => 20230616045916_DbV2.Designer.cs} | 232 ++++++++++++- ...1342_AllTbls.cs => 20230616045916_DbV2.cs} | 169 +++++++++- .../Migrations/DataContextModelSnapshot.cs | 228 ++++++++++++- PARR.DAL/Models/Application.cs | 1 + PARR.DAL/Models/ApplicationType.cs | 5 - PARR.DAL/Models/Job.cs | 7 +- PARR.DAL/ParrDalInstaller.cs | 1 + PARR.DAL/Services/Abstracts/BaseService.cs | 11 +- .../Implementations/SchedulerService.cs | 22 ++ .../Services/Interfaces/Base/IBaseService.cs | 5 +- .../Services/Interfaces/ISchedulerService.cs | 9 + 37 files changed, 1151 insertions(+), 504 deletions(-) create mode 100644 PARR.API/Contracts/V1/Requests/Queries/PaginationQuery.cs create mode 100644 PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs create mode 100644 PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs create mode 100644 PARR.API/Contracts/V1/Responses/ApiHealthResponse.cs create mode 100644 PARR.API/Contracts/V1/Responses/ApiVersionResponse.cs create mode 100644 PARR.API/Contracts/V1/Responses/Base/BaseResponse.cs create mode 100644 PARR.API/Contracts/V1/Responses/Base/ErrorModel.cs create mode 100644 PARR.API/Contracts/V1/Responses/Base/PagedResponse.cs create mode 100644 PARR.API/Contracts/V1/Responses/Base/Response.cs create mode 100644 PARR.API/Contracts/V1/Responses/SchedulerResponse.cs delete mode 100644 PARR.API/Controllers/V1/HomeController.cs create mode 100644 PARR.API/Controllers/V1/ShchedullerController.cs create mode 100644 PARR.API/Extensions/PaginationExtensions.cs create mode 100644 PARR.API/Services/Implementations/ClientService.cs create mode 100644 PARR.API/Services/Interfaces/IClientService.cs create mode 100644 PARR.DAL/DomainModels/PaginationFilter.cs delete mode 100644 PARR.DAL/Migrations/20230519051342_AllTbls.Designer.cs delete mode 100644 PARR.DAL/Migrations/20230601014714_UpdTblHosts.cs rename PARR.DAL/Migrations/{20230601014714_UpdTblHosts.Designer.cs => 20230616045916_DbV2.Designer.cs} (56%) rename PARR.DAL/Migrations/{20230519051342_AllTbls.cs => 20230616045916_DbV2.cs} (52%) create mode 100644 PARR.DAL/Services/Implementations/SchedulerService.cs create mode 100644 PARR.DAL/Services/Interfaces/ISchedulerService.cs diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs index 01024021..40280dbe 100644 --- a/PARR.API/Contracts/V1/ApiRoutes.cs +++ b/PARR.API/Contracts/V1/ApiRoutes.cs @@ -27,6 +27,20 @@ public const string Metrics = Base + "/metrics"; } + public static class Scheduler + { + public const string GetAll = Base + "/schedulers/"; + + public const string GetByIp = Base + "/schedulers/ip/"; + //public const string Get = Base + "/schedulers/" + getParam; + + //public const string GetAreas = Base + "/schedulers/" + getParam + "/areas"; + //public const string GetPlaces = Base + "/schedulers/" + getParam + "/places"; + //public const string GetTemplates = Base + "/schedulers/" + getParam + "/templates"; + + public const string getParam = "{id}"; + } + //public static class Layer //{ // public const string GetAll = Base + "/layers/"; @@ -37,6 +51,7 @@ // public const string GetTemplates = Base + "/layers/" + getParam + "/templates"; // public const string getParam = "{id}"; - //} + // + } + } -} diff --git a/PARR.API/Contracts/V1/Requests/Queries/PaginationQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/PaginationQuery.cs new file mode 100644 index 00000000..13134fe6 --- /dev/null +++ b/PARR.API/Contracts/V1/Requests/Queries/PaginationQuery.cs @@ -0,0 +1,57 @@ +namespace PARR.API.Contracts.V1.Requests.Queries +{ + public class PaginationQuery + { + private int pageSizeMax = 100; + private int pageSizeDefault = 10; + + private int pageNumberMin = 1; + + public PaginationQuery() + { + PageNumber = pageNumberMin; + PageSize = pageSizeDefault; + } + + public PaginationQuery(int pageNumber, int pageSize) + { + PageNumber = pageNumber; + PageSize = pageSize; + } + + private int _pageNumber; + public int PageNumber + { + get + { + return _pageNumber; + } + set + { + if (value < pageNumberMin) + _pageNumber = pageNumberMin; + else + _pageNumber = value; + } + } + + private int _pageSize; + public int PageSize + { + get + { + return _pageSize; + } + set + { + if (value > pageSizeMax) + _pageSize = pageSizeMax; + else + _pageSize = value; + + if (_pageSize < 1) + _pageSize = pageSizeDefault; + } + } + } +} diff --git a/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs new file mode 100644 index 00000000..0b021ad6 --- /dev/null +++ b/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs @@ -0,0 +1,15 @@ +namespace PARR.API.Contracts.V1.Requests.Queries +{ + public class SchedulerGetAllQuery + { + /// + /// true - вкл задания, false - выкл задания, null - все задания + /// + public bool? IsEnabled { get; set; } + + /// + /// Список запланированных заданий на указанную дату + /// + public DateTimeOffset? StartDatePlanned { get; set; } + } +} diff --git a/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs new file mode 100644 index 00000000..fea5392d --- /dev/null +++ b/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs @@ -0,0 +1,7 @@ +namespace PARR.API.Contracts.V1.Requests.Queries +{ + public class SchedulerGetByIpQuery + { + public string? Ip { get; set; } + } +} diff --git a/PARR.API/Contracts/V1/Responses/ApiHealthResponse.cs b/PARR.API/Contracts/V1/Responses/ApiHealthResponse.cs new file mode 100644 index 00000000..a598ee0d --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/ApiHealthResponse.cs @@ -0,0 +1,6 @@ +namespace PARR.API.Contracts.V1.Responses +{ + public class ApiHealthResponse + { + } +} diff --git a/PARR.API/Contracts/V1/Responses/ApiVersionResponse.cs b/PARR.API/Contracts/V1/Responses/ApiVersionResponse.cs new file mode 100644 index 00000000..6db5f104 --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/ApiVersionResponse.cs @@ -0,0 +1,9 @@ +namespace PARR.API.Contracts.V1.Responses +{ + public class ApiVersionResponse + { + public string? Version { get; set; } + + public string? Environment { get; set; } + } +} diff --git a/PARR.API/Contracts/V1/Responses/Base/BaseResponse.cs b/PARR.API/Contracts/V1/Responses/Base/BaseResponse.cs new file mode 100644 index 00000000..00a4d83d --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/Base/BaseResponse.cs @@ -0,0 +1,29 @@ +namespace PARR.API.Contracts.V1.Responses.Base +{ + public class BaseResponse + { + public BaseResponse() { } + + public BaseResponse(bool isSuccess) + { + IsSuccess = isSuccess; + } + + public BaseResponse(bool isSuccess, List errors) + { + IsSuccess = isSuccess; + Errors = errors; + } + + public BaseResponse(bool isSuccess, List errors, string message) + { + IsSuccess = isSuccess; + Errors = errors; + Message = message; + } + + public List Errors { get; set; } = new List(); + public bool IsSuccess { get; private set; } + public string? Message { get; private set; } + } +} diff --git a/PARR.API/Contracts/V1/Responses/Base/ErrorModel.cs b/PARR.API/Contracts/V1/Responses/Base/ErrorModel.cs new file mode 100644 index 00000000..f218ce33 --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/Base/ErrorModel.cs @@ -0,0 +1,9 @@ +namespace PARR.API.Contracts.V1.Responses.Base +{ + public class ErrorModel + { + public string? FieldName { get; set; } + + public string? Message { get; set; } + } +} diff --git a/PARR.API/Contracts/V1/Responses/Base/PagedResponse.cs b/PARR.API/Contracts/V1/Responses/Base/PagedResponse.cs new file mode 100644 index 00000000..4dd40303 --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/Base/PagedResponse.cs @@ -0,0 +1,29 @@ +namespace PARR.API.Contracts.V1.Responses.Base +{ + public class PagedResponse : BaseResponse + { + public PagedResponse(bool isSuccess) : base(isSuccess) { } + + public PagedResponse(bool isSuccess, List errors) : base(isSuccess, errors) { } + + public PagedResponse(bool isSuccess, List errors, string message) : base(isSuccess, errors, message) { } + + + public PagedResponse(IEnumerable data, bool isSuccess) : base(isSuccess) { Data = data; } + + public PagedResponse(IEnumerable data, bool isSuccess, List errors) : base(isSuccess, errors) { Data = data; } + + public PagedResponse(IEnumerable data, bool isSuccess, List errors, string message) : base(isSuccess, errors, message) { Data = data; } + + + public IEnumerable? Data { get; set; } + + public int? PageNumber { get; set; } + + public int? PageSize { get; set; } + + public int? TotalPage { get; set; } + + public int? TotalItems { get; set; } + } +} diff --git a/PARR.API/Contracts/V1/Responses/Base/Response.cs b/PARR.API/Contracts/V1/Responses/Base/Response.cs new file mode 100644 index 00000000..25691d6e --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/Base/Response.cs @@ -0,0 +1,57 @@ +using FluentValidation.Results; + +namespace PARR.API.Contracts.V1.Responses.Base +{ + public class Response : BaseResponse + { + public Response(T response, bool isSuccess) : base(isSuccess) + { + Data = response; + } + + public Response(T response, bool isSuccess, List errors) : base(isSuccess, errors) + { + Data = response; + } + + public Response(T response, bool isSuccess, List errors, string message) : base(isSuccess, errors, message) + { + Data = response; + } + + public T? Data { get; private set; } + } + + + public class Response : Response + { + /// + /// Респонс для валидации от FluentValidator + /// + /// ResultValidate.Errors + public Response(List validationErrors) : base(null, false) + { + var errors = new List(); + foreach (var error in validationErrors) + { + errors.Add(new ErrorModel + { + FieldName = error.PropertyName, + Message = error.ErrorMessage + }); + } + + Errors = errors; + } + + /// + /// Респонс когда не нужно передавать объект + /// + /// + /// + public Response(bool isSuccess, List errors) : base(null, isSuccess, errors) + { + + } + } +} diff --git a/PARR.API/Contracts/V1/Responses/SchedulerResponse.cs b/PARR.API/Contracts/V1/Responses/SchedulerResponse.cs new file mode 100644 index 00000000..9444e815 --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/SchedulerResponse.cs @@ -0,0 +1,21 @@ +namespace PARR.API.Contracts.V1.Responses +{ + public class SchedulerBaseResponse + { + public required string Name { get; set; } + public DateTimeOffset StartAt { get; set; } + public int FrequencyMinute { get; set; } + + } + + public class SchedulerGetAllResponse: SchedulerBaseResponse + { + public Guid Id { get; set; } + public bool IsEnabled { get; set; } + } + + public class SchedulerResponse + { + + } +} diff --git a/PARR.API/Controllers/V1/ApiStatusController.cs b/PARR.API/Controllers/V1/ApiStatusController.cs index d7db559d..52e78fff 100644 --- a/PARR.API/Controllers/V1/ApiStatusController.cs +++ b/PARR.API/Controllers/V1/ApiStatusController.cs @@ -1,9 +1,49 @@ -using PARR.API.Controllers.V1.Base; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using PARR.API.Contracts.V1; +using PARR.API.Contracts.V1.Responses; +using PARR.API.Contracts.V1.Responses.Base; +using PARR.API.Controllers.V1.Base; +using System.Reflection; namespace PARR.API.Controllers.V1 { public class ApiStatusController : BaseApiController { - //TODO: + /// + /// Получить версию и окружение + /// + /// + [AllowAnonymous] + [HttpGet(ApiRoutes.ApiStatus.Version)] + public IActionResult GetVersion() + { + var version = Assembly.GetEntryAssembly()?.GetCustomAttribute()?.InformationalVersion; + var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + + var response = new ApiVersionResponse + { + Environment = environment, + Version = version + }; + + return Ok(new Response(response, true)); + } + + + /// + /// Проверка доступности системы + /// + /// + [AllowAnonymous] + [HttpGet(ApiRoutes.ApiStatus.Health)] + public IActionResult GetHealth() + { + //Так же можно реализовать проверку связи с БД + //Проверка доступности хранилищ + var response = new ApiHealthResponse { }; + + return Ok(new Response(response, true)); + } } } diff --git a/PARR.API/Controllers/V1/HomeController.cs b/PARR.API/Controllers/V1/HomeController.cs deleted file mode 100644 index 663235dc..00000000 --- a/PARR.API/Controllers/V1/HomeController.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using PARR.DAL.Services.Interfaces; - -namespace PARR.API.Controllers.V1 -{ - public class HomeController : Controller - { - private readonly IHostService hostService; - - public HomeController(IHostService hostService) - { - this.hostService = hostService; - } - - [HttpGet("test")] - public async Task Index() - { - var hosts = await hostService.Get().ToListAsync(); - //foreach (var host in hosts) { logger.LogInformation($"{host.HostName}"); } - //return View(); - - return Ok(hosts.Select(t => new { t.HostName, t.IP, t.Id })); - } - } -} diff --git a/PARR.API/Controllers/V1/ShchedullerController.cs b/PARR.API/Controllers/V1/ShchedullerController.cs new file mode 100644 index 00000000..be8945f8 --- /dev/null +++ b/PARR.API/Controllers/V1/ShchedullerController.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Mvc; +using PARR.API.Contracts.V1.Requests.Queries; +using PARR.API.Contracts.V1; +using PARR.API.Controllers.V1.Base; +using AutoMapper; +using PARR.DAL.DomainModels; +using PARR.DAL.Models; +using PARR.DAL.Services.Interfaces; +using Microsoft.EntityFrameworkCore; +using PARR.API.Contracts.V1.Responses; +using PARR.API.Contracts.V1.Responses.Base; +using PARR.API.Extensions; +using System.Runtime.CompilerServices; +using PARR.API.Services.Interfaces; + +namespace PARR.API.Controllers.V1 +{ + public class ShchedullerController : BaseApiController + { + private readonly IMapper mapper; + private readonly ISchedulerService schedulerService; + private readonly IClientService clientService; + + public ShchedullerController( + IMapper mapper, + ISchedulerService schedulerService, + IClientService clientService + ) + { + this.mapper = mapper; + this.schedulerService = schedulerService; + this.clientService = clientService; + } + + + /// + /// Список всех планировщиков постранично в соотвествии с фильтрами + /// + /// + /// + [HttpGet(ApiRoutes.Scheduler.GetAll)] + public async Task GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] SchedulerGetAllQuery filter) + { + var paginationFilter = mapper.Map(paginationQuery); + IQueryable query = schedulerService.Get().OrderBy(s => s.StartAt); + + if (filter.IsEnabled.HasValue) + query = query.Where(t => t.IsEnabled == filter.IsEnabled); + + if (filter.StartDatePlanned.HasValue) + query = query.Where(t => t.StartAt.DateTime.Date <= filter.StartDatePlanned.Value.DateTime.Date); ; + + var schedulers = await schedulerService.GetPage(query, paginationFilter).ToListAsync(); + + if (!schedulers.Any()) + return NoContent(); + + var schedulerResponse = mapper.Map>(schedulers); + var paginationResponse = new PagedResponse(schedulerResponse, true).GetPaginatedProps(paginationFilter, query); + + return Ok(paginationResponse); + } + + + [HttpGet(ApiRoutes.Scheduler.GetByIp)] + public async Task GetByClientIP([FromQuery] SchedulerGetByIpQuery requestQuery) + { + var ip = requestQuery.Ip ?? clientService.GetClientIp()?.ToString(); + if (string.IsNullOrEmpty(ip)) + return BadRequest(new Response(false, new List { new ErrorModel { Message = "Client IP address is null." } })); + + // TODO; + + return Ok(); + } + + } +} diff --git a/PARR.API/Extensions/PaginationExtensions.cs b/PARR.API/Extensions/PaginationExtensions.cs new file mode 100644 index 00000000..c96cb8e2 --- /dev/null +++ b/PARR.API/Extensions/PaginationExtensions.cs @@ -0,0 +1,59 @@ +using PARR.API.Contracts.V1.Responses.Base; +using PARR.DAL.DomainModels; + +namespace PARR.API.Extensions +{ + public static class PaginationExtensions + { + /// + /// Заполняет TotalItems, PageNumber, PageSize, TotalPage + /// + /// + /// + /// + /// + /// + /// + public static PagedResponse GetPaginatedProps( + this PagedResponse pagedResponse, + PaginationFilter paginationFilter, + IQueryable quaryAllItemsApplyFilters + ) + { + // TODO: CountAsync - подумать и затолкать в Task + int totalItems = quaryAllItemsApplyFilters.Count();//.CountAsync().GetAwaiter().GetResult(); + return CreatePaginatedResponse(totalItems, paginationFilter, pagedResponse); + } + + + /// + /// Заполняет TotalItems, PageNumber, PageSize, TotalPage + /// + /// + /// + /// + /// + /// + public static PagedResponse GetPaginatedProps( + this PagedResponse pagedResponse, + PaginationFilter paginationFilter, + int totalItems + ) + { + return CreatePaginatedResponse(totalItems, paginationFilter, pagedResponse); + } + + private static PagedResponse CreatePaginatedResponse(int totalItems, PaginationFilter paginationFilter, PagedResponse pagedResponse) + { + pagedResponse.TotalItems = totalItems; + pagedResponse.PageNumber = paginationFilter.PageNumber >= 1 ? paginationFilter.PageNumber : (int?)null; + pagedResponse.PageSize = paginationFilter.PageSize >= 1 ? paginationFilter.PageSize : (int?)null; + pagedResponse.TotalPage = + (pagedResponse.TotalItems.HasValue && pagedResponse.PageSize.HasValue) + ? (int)Math.Ceiling(pagedResponse.TotalItems.Value / (double)pagedResponse.PageSize.Value) + : (int?)null; + + return pagedResponse; + } + } +} diff --git a/PARR.API/Installers/ApiServicesInstaller.cs b/PARR.API/Installers/ApiServicesInstaller.cs index daa0b8b7..86ef8a54 100644 --- a/PARR.API/Installers/ApiServicesInstaller.cs +++ b/PARR.API/Installers/ApiServicesInstaller.cs @@ -19,7 +19,7 @@ namespace PARR.API.Installers return new UriService(absoluteUri); }); - + services.AddTransient(); //services.AddTransient(); diff --git a/PARR.API/Installers/SwaggerInstaller.cs b/PARR.API/Installers/SwaggerInstaller.cs index e429eff3..fc66b288 100644 --- a/PARR.API/Installers/SwaggerInstaller.cs +++ b/PARR.API/Installers/SwaggerInstaller.cs @@ -19,9 +19,9 @@ namespace PARR.API.Installers "v1", new OpenApiInfo { - Title = "GEO API", + Title = "PARR API", Version = $"v{version}", - Description = "API for the project \"GEO DVGD\"", + Description = "API for the project \"PARR DVGD\"", Contact = new OpenApiContact { Email = "IVC_TrubnikovME@dvgd.rzd;IVC_KuznetsovMV@dvgd.rzd", Name = "Trubnikov M.E., Kuznetsov M.V." }, License = new OpenApiLicense { Name = "© PTK-DVGD Software LLC" } }); diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs index f64d38ef..270d6dcc 100644 --- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs +++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs @@ -1,4 +1,6 @@ using AutoMapper; +using PARR.API.Contracts.V1.Responses; +using PARR.DAL.Models; namespace PARR.API.MappingProfiles { @@ -6,7 +8,11 @@ namespace PARR.API.MappingProfiles { public DomainToResponseProfile() { - // из проекта наружу + // --- Scheduler --- + CreateMap() + .Include() + .ForMember(d => d.FrequencyMinute, o => o.MapFrom(s => s.Frequency)); + CreateMap(); } } } diff --git a/PARR.API/MappingProfiles/RequestToDomainProfile.cs b/PARR.API/MappingProfiles/RequestToDomainProfile.cs index f387c048..74b7107d 100644 --- a/PARR.API/MappingProfiles/RequestToDomainProfile.cs +++ b/PARR.API/MappingProfiles/RequestToDomainProfile.cs @@ -1,4 +1,6 @@ using AutoMapper; +using PARR.API.Contracts.V1.Requests.Queries; +using PARR.DAL.DomainModels; namespace PARR.API.MappingProfiles { @@ -6,7 +8,7 @@ namespace PARR.API.MappingProfiles { public RequestToDomainProfile() { - // снаружи в проект + CreateMap(); } } } diff --git a/PARR.API/PARR.API.csproj b/PARR.API/PARR.API.csproj index 6ec43675..454dd83a 100644 --- a/PARR.API/PARR.API.csproj +++ b/PARR.API/PARR.API.csproj @@ -34,8 +34,6 @@ - - diff --git a/PARR.API/Services/Implementations/ClientService.cs b/PARR.API/Services/Implementations/ClientService.cs new file mode 100644 index 00000000..d269d6a4 --- /dev/null +++ b/PARR.API/Services/Implementations/ClientService.cs @@ -0,0 +1,19 @@ +using PARR.API.Services.Interfaces; +using System.Net; + +namespace PARR.API.Services.Implementations +{ + public class ClientService : IClientService + { + private readonly IHttpContextAccessor httpContextAccessor; + + public ClientService(IHttpContextAccessor httpContextAccessor) + { + this.httpContextAccessor = httpContextAccessor; + } + public IPAddress? GetClientIp() + { + return httpContextAccessor.HttpContext?.Connection.RemoteIpAddress; + } + } +} diff --git a/PARR.API/Services/Interfaces/IClientService.cs b/PARR.API/Services/Interfaces/IClientService.cs new file mode 100644 index 00000000..271ea01f --- /dev/null +++ b/PARR.API/Services/Interfaces/IClientService.cs @@ -0,0 +1,9 @@ +using System.Net; + +namespace PARR.API.Services.Interfaces +{ + public interface IClientService + { + IPAddress? GetClientIp(); + } +} diff --git a/PARR.DAL/Context/DataContext.cs b/PARR.DAL/Context/DataContext.cs index 82f5a5d8..bd5cd88c 100644 --- a/PARR.DAL/Context/DataContext.cs +++ b/PARR.DAL/Context/DataContext.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using PARR.DAL.Contracts; using PARR.DAL.Models; namespace PARR.DAL.Context @@ -19,5 +20,35 @@ namespace PARR.DAL.Context public DbSet ApplicationsInHosts { get; set; } public DbSet Schedulers { get; set; } + //todo init application type+check migrations + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + var dateCreated = new DateTimeOffset(2023, 05, 01, 0, 0, 0, new TimeSpan(0)); + + modelBuilder.Entity(f => + { + f.HasData( + new() { Id = new Guid("FBA4202C-5BAD-49C4-B076-D1CA6E1FB158"), DateCreated = dateCreated, DateModified = null, Name = "auto" }, + new() { Id = new Guid("7516B952-510D-4AAA-971C-A14B184FC1D5"), DateCreated = dateCreated, DateModified = null, Name = "manual" } + ); + }); + + + modelBuilder.Entity(f => + { + f.HasData( + new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Поле СП xml АИХ ИТ" }, + new() { Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.OS.ToString(), Description = "Поле ОС xml АИХ ИТ" }, + new() { Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.DB.ToString(), Description = "Поле СУБД xml АИХ ИТ" } + ); + }); + + } + + + } } diff --git a/PARR.DAL/DomainModels/PaginationFilter.cs b/PARR.DAL/DomainModels/PaginationFilter.cs new file mode 100644 index 00000000..fea6c55b --- /dev/null +++ b/PARR.DAL/DomainModels/PaginationFilter.cs @@ -0,0 +1,8 @@ +namespace PARR.DAL.DomainModels +{ + public class PaginationFilter + { + public int PageNumber { get; set; } + public int PageSize { get; set; } + } +} diff --git a/PARR.DAL/Migrations/20230519051342_AllTbls.Designer.cs b/PARR.DAL/Migrations/20230519051342_AllTbls.Designer.cs deleted file mode 100644 index d102223a..00000000 --- a/PARR.DAL/Migrations/20230519051342_AllTbls.Designer.cs +++ /dev/null @@ -1,315 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using PARR.DAL.Context; - -#nullable disable - -namespace PARR.DAL.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20230519051342_AllTbls")] - partial class AllTbls - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("PARR.DAL.Models.Host", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("EK") - .HasColumnType("text"); - - b.Property("HostName") - .IsRequired() - .HasColumnType("text"); - - b.Property("IP") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Hosts"); - }); - - modelBuilder.Entity("PARR.DAL.Models.Job", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("JobCategoryId") - .HasColumnType("uuid"); - - b.Property("JobModeId") - .HasColumnType("uuid"); - - b.Property("JobTypeId") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("JobCategoryId"); - - b.HasIndex("JobModeId"); - - b.HasIndex("JobTypeId"); - - b.ToTable("Jobs"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobCategory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("JobCategories"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobJournal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("DateOper") - .HasColumnType("text"); - - b.Property("HostId") - .HasColumnType("uuid"); - - b.Property("Info") - .HasColumnType("text"); - - b.Property("JobId") - .HasColumnType("uuid"); - - b.Property("JobStatusId") - .HasColumnType("uuid"); - - b.Property("Other") - .HasColumnType("text"); - - b.Property("TimeOut") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("HostId"); - - b.HasIndex("JobId"); - - b.HasIndex("JobStatusId"); - - b.ToTable("JobJournals"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobModeService", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("JobModes"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("JobStatuses"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("JobTypes"); - }); - - modelBuilder.Entity("PARR.DAL.Models.Job", b => - { - b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") - .WithMany("Jobs") - .HasForeignKey("JobCategoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PARR.DAL.Models.JobModeService", "JobModeService") - .WithMany("Jobs") - .HasForeignKey("JobModeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PARR.DAL.Models.JobType", "JobType") - .WithMany("Jobs") - .HasForeignKey("JobTypeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("JobCategorye"); - - b.Navigation("JobModeService"); - - b.Navigation("JobType"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobJournal", b => - { - b.HasOne("PARR.DAL.Models.Host", "Host") - .WithMany("JobJournals") - .HasForeignKey("HostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PARR.DAL.Models.Job", "Job") - .WithMany("Journals") - .HasForeignKey("JobId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("PARR.DAL.Models.JobStatus", "Status") - .WithMany("Journals") - .HasForeignKey("JobStatusId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Host"); - - b.Navigation("Job"); - - b.Navigation("Status"); - }); - - modelBuilder.Entity("PARR.DAL.Models.Host", b => - { - b.Navigation("JobJournals"); - }); - - modelBuilder.Entity("PARR.DAL.Models.Job", b => - { - b.Navigation("Journals"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobCategory", b => - { - b.Navigation("Jobs"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobModeService", b => - { - b.Navigation("Jobs"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => - { - b.Navigation("Journals"); - }); - - modelBuilder.Entity("PARR.DAL.Models.JobType", b => - { - b.Navigation("Jobs"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/PARR.DAL/Migrations/20230601014714_UpdTblHosts.cs b/PARR.DAL/Migrations/20230601014714_UpdTblHosts.cs deleted file mode 100644 index fd209adb..00000000 --- a/PARR.DAL/Migrations/20230601014714_UpdTblHosts.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace PARR.DAL.Migrations -{ - /// - public partial class UpdTblHosts : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "EK", - table: "Hosts", - newName: "WorkGroup"); - - migrationBuilder.AddColumn( - name: "APP", - table: "Hosts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "DB", - table: "Hosts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "LinkEK", - table: "Hosts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "OS", - table: "Hosts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "RegionalEK", - table: "Hosts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "Responsible", - table: "Hosts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "Status", - table: "Hosts", - type: "text", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "APP", - table: "Hosts"); - - migrationBuilder.DropColumn( - name: "DB", - table: "Hosts"); - - migrationBuilder.DropColumn( - name: "LinkEK", - table: "Hosts"); - - migrationBuilder.DropColumn( - name: "OS", - table: "Hosts"); - - migrationBuilder.DropColumn( - name: "RegionalEK", - table: "Hosts"); - - migrationBuilder.DropColumn( - name: "Responsible", - table: "Hosts"); - - migrationBuilder.DropColumn( - name: "Status", - table: "Hosts"); - - migrationBuilder.RenameColumn( - name: "WorkGroup", - table: "Hosts", - newName: "EK"); - } - } -} diff --git a/PARR.DAL/Migrations/20230601014714_UpdTblHosts.Designer.cs b/PARR.DAL/Migrations/20230616045916_DbV2.Designer.cs similarity index 56% rename from PARR.DAL/Migrations/20230601014714_UpdTblHosts.Designer.cs rename to PARR.DAL/Migrations/20230616045916_DbV2.Designer.cs index 99c91458..16b19552 100644 --- a/PARR.DAL/Migrations/20230601014714_UpdTblHosts.Designer.cs +++ b/PARR.DAL/Migrations/20230616045916_DbV2.Designer.cs @@ -12,8 +12,8 @@ using PARR.DAL.Context; namespace PARR.DAL.Migrations { [DbContext(typeof(DataContext))] - [Migration("20230601014714_UpdTblHosts")] - partial class UpdTblHosts + [Migration("20230616045916_DbV2")] + partial class DbV2 { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -25,18 +25,117 @@ namespace PARR.DAL.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("PARR.DAL.Models.Host", b => + modelBuilder.Entity("PARR.DAL.Models.Application", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("APP") + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("ApplicationTypeId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() .HasColumnType("text"); - b.Property("DB") + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("ApplicationTypeId"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HostId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("HostId"); + + b.ToTable("ApplicationsInHosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") .HasColumnType("text"); + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ApplicationTypes"); + + b.HasData( + new + { + Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Поле СП xml АИХ ИТ", + Name = "APP" + }, + new + { + Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Поле ОС xml АИХ ИТ", + Name = "OS" + }, + new + { + Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Поле СУБД xml АИХ ИТ", + Name = "DB" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.Host", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + b.Property("DateCreated") .HasColumnType("timestamp with time zone"); @@ -44,7 +143,6 @@ namespace PARR.DAL.Migrations .HasColumnType("timestamp with time zone"); b.Property("HostName") - .IsRequired() .HasColumnType("text"); b.Property("IP") @@ -54,9 +152,6 @@ namespace PARR.DAL.Migrations b.Property("LinkEK") .HasColumnType("text"); - b.Property("OS") - .HasColumnType("text"); - b.Property("RegionalEK") .HasColumnType("text"); @@ -80,13 +175,16 @@ namespace PARR.DAL.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ApplicationId") + .HasColumnType("uuid"); + b.Property("DateCreated") .HasColumnType("timestamp with time zone"); b.Property("DateModified") .HasColumnType("timestamp with time zone"); - b.Property("JobCategoryId") + b.Property("JobCategoryId") .HasColumnType("uuid"); b.Property("JobModeId") @@ -99,8 +197,14 @@ namespace PARR.DAL.Migrations .IsRequired() .HasColumnType("text"); + b.Property("ScriptName") + .IsRequired() + .HasColumnType("text"); + b.HasKey("Id"); + b.HasIndex("ApplicationId"); + b.HasIndex("JobCategoryId"); b.HasIndex("JobModeId"); @@ -178,7 +282,7 @@ namespace PARR.DAL.Migrations b.ToTable("JobJournals"); }); - modelBuilder.Entity("PARR.DAL.Models.JobModeService", b => + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -197,6 +301,20 @@ namespace PARR.DAL.Migrations b.HasKey("Id"); b.ToTable("JobModes"); + + b.HasData( + new + { + Id = new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "auto" + }, + new + { + Id = new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "manual" + }); }); modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => @@ -247,15 +365,82 @@ namespace PARR.DAL.Migrations b.ToTable("JobTypes"); }); - modelBuilder.Entity("PARR.DAL.Models.Job", b => + modelBuilder.Entity("PARR.DAL.Models.Scheduler", b => { - b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") - .WithMany("Jobs") - .HasForeignKey("JobCategoryId") + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Frequency") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Schedulers"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.HasOne("PARR.DAL.Models.Application", null) + .WithMany("Applications") + .HasForeignKey("ApplicationId"); + + b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType") + .WithMany() + .HasForeignKey("ApplicationTypeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("PARR.DAL.Models.JobModeService", "JobModeService") + b.Navigation("ApplicationType"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany("ApplicationsInHosts") + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.Host", "Host") + .WithMany("ApplicationsInHosts") + .HasForeignKey("HostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Application"); + + b.Navigation("Host"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany() + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") + .WithMany("Jobs") + .HasForeignKey("JobCategoryId"); + + b.HasOne("PARR.DAL.Models.JobMode", "JobMode") .WithMany("Jobs") .HasForeignKey("JobModeId") .OnDelete(DeleteBehavior.Cascade) @@ -267,9 +452,11 @@ namespace PARR.DAL.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Application"); + b.Navigation("JobCategorye"); - b.Navigation("JobModeService"); + b.Navigation("JobMode"); b.Navigation("JobType"); }); @@ -301,8 +488,17 @@ namespace PARR.DAL.Migrations b.Navigation("Status"); }); + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.Navigation("Applications"); + + b.Navigation("ApplicationsInHosts"); + }); + modelBuilder.Entity("PARR.DAL.Models.Host", b => { + b.Navigation("ApplicationsInHosts"); + b.Navigation("JobJournals"); }); @@ -316,7 +512,7 @@ namespace PARR.DAL.Migrations b.Navigation("Jobs"); }); - modelBuilder.Entity("PARR.DAL.Models.JobModeService", b => + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => { b.Navigation("Jobs"); }); diff --git a/PARR.DAL/Migrations/20230519051342_AllTbls.cs b/PARR.DAL/Migrations/20230616045916_DbV2.cs similarity index 52% rename from PARR.DAL/Migrations/20230519051342_AllTbls.cs rename to PARR.DAL/Migrations/20230616045916_DbV2.cs index 61da2dfd..cddf535e 100644 --- a/PARR.DAL/Migrations/20230519051342_AllTbls.cs +++ b/PARR.DAL/Migrations/20230616045916_DbV2.cs @@ -3,14 +3,31 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + namespace PARR.DAL.Migrations { /// - public partial class AllTbls : Migration + public partial class DbV2 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "ApplicationTypes", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: true), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ApplicationTypes", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Hosts", columns: table => new @@ -18,9 +35,13 @@ namespace PARR.DAL.Migrations Id = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false), DateModified = table.Column(type: "timestamp with time zone", nullable: true), - HostName = table.Column(type: "text", nullable: false), + HostName = table.Column(type: "text", nullable: true), IP = table.Column(type: "text", nullable: false), - EK = table.Column(type: "text", nullable: true) + RegionalEK = table.Column(type: "text", nullable: true), + LinkEK = table.Column(type: "text", nullable: true), + Status = table.Column(type: "text", nullable: true), + WorkGroup = table.Column(type: "text", nullable: true), + Responsible = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -86,6 +107,77 @@ namespace PARR.DAL.Migrations table.PrimaryKey("PK_JobTypes", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Schedulers", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: true), + Name = table.Column(type: "text", nullable: true), + Frequency = table.Column(type: "integer", nullable: false), + StartAt = table.Column(type: "timestamp with time zone", nullable: false), + IsEnabled = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Schedulers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Applications", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: true), + Name = table.Column(type: "text", nullable: false), + ApplicationTypeId = table.Column(type: "uuid", nullable: false), + ApplicationId = table.Column(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Applications", x => x.Id); + table.ForeignKey( + name: "FK_Applications_ApplicationTypes_ApplicationTypeId", + column: x => x.ApplicationTypeId, + principalTable: "ApplicationTypes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Applications_Applications_ApplicationId", + column: x => x.ApplicationId, + principalTable: "Applications", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ApplicationsInHosts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: true), + ApplicationId = table.Column(type: "uuid", nullable: false), + HostId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ApplicationsInHosts", x => x.Id); + table.ForeignKey( + name: "FK_ApplicationsInHosts_Applications_ApplicationId", + column: x => x.ApplicationId, + principalTable: "Applications", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ApplicationsInHosts_Hosts_HostId", + column: x => x.HostId, + principalTable: "Hosts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Jobs", columns: table => new @@ -94,19 +186,26 @@ namespace PARR.DAL.Migrations DateCreated = table.Column(type: "timestamp with time zone", nullable: false), DateModified = table.Column(type: "timestamp with time zone", nullable: true), Name = table.Column(type: "text", nullable: false), + ScriptName = table.Column(type: "text", nullable: false), JobModeId = table.Column(type: "uuid", nullable: false), - JobCategoryId = table.Column(type: "uuid", nullable: false), - JobTypeId = table.Column(type: "uuid", nullable: false) + JobCategoryId = table.Column(type: "uuid", nullable: true), + JobTypeId = table.Column(type: "uuid", nullable: false), + ApplicationId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Jobs", x => x.Id); + table.ForeignKey( + name: "FK_Jobs_Applications_ApplicationId", + column: x => x.ApplicationId, + principalTable: "Applications", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Jobs_JobCategories_JobCategoryId", column: x => x.JobCategoryId, principalTable: "JobCategories", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); table.ForeignKey( name: "FK_Jobs_JobModes_JobModeId", column: x => x.JobModeId, @@ -159,6 +258,45 @@ namespace PARR.DAL.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.InsertData( + table: "ApplicationTypes", + columns: new[] { "Id", "DateCreated", "DateModified", "Description", "Name" }, + values: new object[,] + { + { new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Поле СП xml АИХ ИТ", "APP" }, + { new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Поле ОС xml АИХ ИТ", "OS" }, + { new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Поле СУБД xml АИХ ИТ", "DB" } + }); + + migrationBuilder.InsertData( + table: "JobModes", + columns: new[] { "Id", "DateCreated", "DateModified", "Name" }, + values: new object[,] + { + { new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "manual" }, + { new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "auto" } + }); + + migrationBuilder.CreateIndex( + name: "IX_Applications_ApplicationId", + table: "Applications", + column: "ApplicationId"); + + migrationBuilder.CreateIndex( + name: "IX_Applications_ApplicationTypeId", + table: "Applications", + column: "ApplicationTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_ApplicationsInHosts_ApplicationId", + table: "ApplicationsInHosts", + column: "ApplicationId"); + + migrationBuilder.CreateIndex( + name: "IX_ApplicationsInHosts_HostId", + table: "ApplicationsInHosts", + column: "HostId"); + migrationBuilder.CreateIndex( name: "IX_JobJournals_HostId", table: "JobJournals", @@ -174,6 +312,11 @@ namespace PARR.DAL.Migrations table: "JobJournals", column: "JobStatusId"); + migrationBuilder.CreateIndex( + name: "IX_Jobs_ApplicationId", + table: "Jobs", + column: "ApplicationId"); + migrationBuilder.CreateIndex( name: "IX_Jobs_JobCategoryId", table: "Jobs", @@ -193,9 +336,15 @@ namespace PARR.DAL.Migrations /// protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "ApplicationsInHosts"); + migrationBuilder.DropTable( name: "JobJournals"); + migrationBuilder.DropTable( + name: "Schedulers"); + migrationBuilder.DropTable( name: "Hosts"); @@ -205,6 +354,9 @@ namespace PARR.DAL.Migrations migrationBuilder.DropTable( name: "Jobs"); + migrationBuilder.DropTable( + name: "Applications"); + migrationBuilder.DropTable( name: "JobCategories"); @@ -213,6 +365,9 @@ namespace PARR.DAL.Migrations migrationBuilder.DropTable( name: "JobTypes"); + + migrationBuilder.DropTable( + name: "ApplicationTypes"); } } } diff --git a/PARR.DAL/Migrations/DataContextModelSnapshot.cs b/PARR.DAL/Migrations/DataContextModelSnapshot.cs index 8fd1949b..2d76a45b 100644 --- a/PARR.DAL/Migrations/DataContextModelSnapshot.cs +++ b/PARR.DAL/Migrations/DataContextModelSnapshot.cs @@ -22,18 +22,117 @@ namespace PARR.DAL.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("PARR.DAL.Models.Host", b => + modelBuilder.Entity("PARR.DAL.Models.Application", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("APP") + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("ApplicationTypeId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() .HasColumnType("text"); - b.Property("DB") + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("ApplicationTypeId"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HostId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("HostId"); + + b.ToTable("ApplicationsInHosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") .HasColumnType("text"); + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ApplicationTypes"); + + b.HasData( + new + { + Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Поле СП xml АИХ ИТ", + Name = "APP" + }, + new + { + Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Поле ОС xml АИХ ИТ", + Name = "OS" + }, + new + { + Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Поле СУБД xml АИХ ИТ", + Name = "DB" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.Host", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + b.Property("DateCreated") .HasColumnType("timestamp with time zone"); @@ -41,7 +140,6 @@ namespace PARR.DAL.Migrations .HasColumnType("timestamp with time zone"); b.Property("HostName") - .IsRequired() .HasColumnType("text"); b.Property("IP") @@ -51,9 +149,6 @@ namespace PARR.DAL.Migrations b.Property("LinkEK") .HasColumnType("text"); - b.Property("OS") - .HasColumnType("text"); - b.Property("RegionalEK") .HasColumnType("text"); @@ -77,13 +172,16 @@ namespace PARR.DAL.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ApplicationId") + .HasColumnType("uuid"); + b.Property("DateCreated") .HasColumnType("timestamp with time zone"); b.Property("DateModified") .HasColumnType("timestamp with time zone"); - b.Property("JobCategoryId") + b.Property("JobCategoryId") .HasColumnType("uuid"); b.Property("JobModeId") @@ -96,8 +194,14 @@ namespace PARR.DAL.Migrations .IsRequired() .HasColumnType("text"); + b.Property("ScriptName") + .IsRequired() + .HasColumnType("text"); + b.HasKey("Id"); + b.HasIndex("ApplicationId"); + b.HasIndex("JobCategoryId"); b.HasIndex("JobModeId"); @@ -175,7 +279,7 @@ namespace PARR.DAL.Migrations b.ToTable("JobJournals"); }); - modelBuilder.Entity("PARR.DAL.Models.JobModeService", b => + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -194,6 +298,20 @@ namespace PARR.DAL.Migrations b.HasKey("Id"); b.ToTable("JobModes"); + + b.HasData( + new + { + Id = new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "auto" + }, + new + { + Id = new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "manual" + }); }); modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => @@ -244,15 +362,82 @@ namespace PARR.DAL.Migrations b.ToTable("JobTypes"); }); - modelBuilder.Entity("PARR.DAL.Models.Job", b => + modelBuilder.Entity("PARR.DAL.Models.Scheduler", b => { - b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") - .WithMany("Jobs") - .HasForeignKey("JobCategoryId") + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Frequency") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Schedulers"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.HasOne("PARR.DAL.Models.Application", null) + .WithMany("Applications") + .HasForeignKey("ApplicationId"); + + b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType") + .WithMany() + .HasForeignKey("ApplicationTypeId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("PARR.DAL.Models.JobModeService", "JobModeService") + b.Navigation("ApplicationType"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany("ApplicationsInHosts") + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.Host", "Host") + .WithMany("ApplicationsInHosts") + .HasForeignKey("HostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Application"); + + b.Navigation("Host"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany() + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") + .WithMany("Jobs") + .HasForeignKey("JobCategoryId"); + + b.HasOne("PARR.DAL.Models.JobMode", "JobMode") .WithMany("Jobs") .HasForeignKey("JobModeId") .OnDelete(DeleteBehavior.Cascade) @@ -264,9 +449,11 @@ namespace PARR.DAL.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Application"); + b.Navigation("JobCategorye"); - b.Navigation("JobModeService"); + b.Navigation("JobMode"); b.Navigation("JobType"); }); @@ -298,8 +485,17 @@ namespace PARR.DAL.Migrations b.Navigation("Status"); }); + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.Navigation("Applications"); + + b.Navigation("ApplicationsInHosts"); + }); + modelBuilder.Entity("PARR.DAL.Models.Host", b => { + b.Navigation("ApplicationsInHosts"); + b.Navigation("JobJournals"); }); @@ -313,7 +509,7 @@ namespace PARR.DAL.Migrations b.Navigation("Jobs"); }); - modelBuilder.Entity("PARR.DAL.Models.JobModeService", b => + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => { b.Navigation("Jobs"); }); diff --git a/PARR.DAL/Models/Application.cs b/PARR.DAL/Models/Application.cs index 9df7737b..19692cf3 100644 --- a/PARR.DAL/Models/Application.cs +++ b/PARR.DAL/Models/Application.cs @@ -19,5 +19,6 @@ namespace PARR.DAL.Models public ICollection ApplicationsInHosts { get; set; } = new HashSet(); + public ICollection Applications { get;set; } = new HashSet(); } } diff --git a/PARR.DAL/Models/ApplicationType.cs b/PARR.DAL/Models/ApplicationType.cs index 8bc3b113..f6ed75e6 100644 --- a/PARR.DAL/Models/ApplicationType.cs +++ b/PARR.DAL/Models/ApplicationType.cs @@ -1,10 +1,5 @@ using PARR.DAL.Models.Base; -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace PARR.DAL.Models { diff --git a/PARR.DAL/Models/Job.cs b/PARR.DAL/Models/Job.cs index 5de518aa..63b453ff 100644 --- a/PARR.DAL/Models/Job.cs +++ b/PARR.DAL/Models/Job.cs @@ -12,13 +12,14 @@ namespace PARR.DAL.Models public DateTimeOffset DateCreated { get; set; } public DateTimeOffset? DateModified { get; set; } public required string Name { get; set; } + public required string ScriptName { get; set; } public Guid JobModeId { get; set; } [ForeignKey(nameof(JobModeId))] public JobMode? JobMode { get; set; } - public Guid JobCategoryId { get; set; } + public Guid? JobCategoryId { get; set; } [ForeignKey(nameof(JobCategoryId))] public JobCategory? JobCategorye { get; set; } @@ -26,7 +27,11 @@ namespace PARR.DAL.Models [ForeignKey(nameof(JobTypeId))] public JobType? JobType { get; set; } + public Guid ApplicationId { get; set; } + [ForeignKey(nameof(ApplicationId))] + public Application? Application { get; set; } public ICollection Journals { get; set; } = new HashSet(); + } } diff --git a/PARR.DAL/ParrDalInstaller.cs b/PARR.DAL/ParrDalInstaller.cs index 7a854d28..f6abe67b 100644 --- a/PARR.DAL/ParrDalInstaller.cs +++ b/PARR.DAL/ParrDalInstaller.cs @@ -19,6 +19,7 @@ namespace PARR.DAL services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); //services.AddTransient(); } diff --git a/PARR.DAL/Services/Abstracts/BaseService.cs b/PARR.DAL/Services/Abstracts/BaseService.cs index 64e7b2d1..b2820652 100644 --- a/PARR.DAL/Services/Abstracts/BaseService.cs +++ b/PARR.DAL/Services/Abstracts/BaseService.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using PARR.DAL.Context; +using PARR.DAL.DomainModels; using PARR.DAL.Models.Base; using PARR.DAL.Services.Interfaces.Base; @@ -109,11 +110,11 @@ namespace PARR.DAL.Services.Abstracts return await EntitySet.FirstOrDefaultAsync(t => t.Id == id); } - //public virtual IQueryable GetPage(IQueryable query, PaginationFilter paginationFilter) - //{ - // int skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize; + public virtual IQueryable GetPage(IQueryable query, PaginationFilter paginationFilter) + { + int skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize; - // return query.Skip(skip).Take(paginationFilter.PageSize); - //} + return query.Skip(skip).Take(paginationFilter.PageSize); + } } } diff --git a/PARR.DAL/Services/Implementations/SchedulerService.cs b/PARR.DAL/Services/Implementations/SchedulerService.cs new file mode 100644 index 00000000..69436876 --- /dev/null +++ b/PARR.DAL/Services/Implementations/SchedulerService.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using PARR.DAL.Context; +using PARR.DAL.Models; +using PARR.DAL.Services.Abstracts; +using PARR.DAL.Services.Interfaces; + +namespace PARR.DAL.Services.Implementations +{ + internal class SchedulerService : BaseService, ISchedulerService + { + private readonly DataContext dataContext; + + public SchedulerService(DataContext dataContext, ILogger logger) : base(logger) + { + this.dataContext = dataContext; + } + protected override DbSet EntitySet => dataContext.Schedulers; + + protected override DataContext EntitiContext => dataContext; + } +} diff --git a/PARR.DAL/Services/Interfaces/Base/IBaseService.cs b/PARR.DAL/Services/Interfaces/Base/IBaseService.cs index 1e9c442d..38d42a80 100644 --- a/PARR.DAL/Services/Interfaces/Base/IBaseService.cs +++ b/PARR.DAL/Services/Interfaces/Base/IBaseService.cs @@ -1,4 +1,5 @@ -using PARR.DAL.Models.Base; +using PARR.DAL.DomainModels; +using PARR.DAL.Models.Base; namespace PARR.DAL.Services.Interfaces.Base { @@ -6,7 +7,7 @@ namespace PARR.DAL.Services.Interfaces.Base { Task GetAsync(Guid id); IQueryable Get(); - //IQueryable GetPage(IQueryable query, PaginationFilter paginationFilter); + IQueryable GetPage(IQueryable query, PaginationFilter paginationFilter); Task CreateAsync(T obj); Task AddRangeAsync(List objs); diff --git a/PARR.DAL/Services/Interfaces/ISchedulerService.cs b/PARR.DAL/Services/Interfaces/ISchedulerService.cs new file mode 100644 index 00000000..744f1fec --- /dev/null +++ b/PARR.DAL/Services/Interfaces/ISchedulerService.cs @@ -0,0 +1,9 @@ +using PARR.DAL.Models; +using PARR.DAL.Services.Interfaces.Base; + +namespace PARR.DAL.Services.Interfaces +{ + public interface ISchedulerService : IBaseService + { + } +}