feat(dal,api): Удалены старые таблицы AppInWorks
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Управление приложениями
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ApplicationController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationService applicationService;
|
||||
|
||||
public ApplicationController(
|
||||
IMapper mapper,
|
||||
IApplicationService applicationService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.applicationService = applicationService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список приложений постранично
|
||||
/// </summary>
|
||||
/// <param name="paginationQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Application.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] ApplicationQuery filter)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<Application> query = applicationService.Get()
|
||||
.Include(t => t.ApplicationType)
|
||||
.OrderBy(t => t.Name);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filter.Name))
|
||||
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
||||
|
||||
if (filter.TypeId.HasValue)
|
||||
query = query.Where(t => t.ApplicationTypeId == filter.TypeId);
|
||||
|
||||
if (filter.Id.HasValue)
|
||||
query = query.Where(t => t.Id == filter.Id);
|
||||
|
||||
|
||||
var apps = await applicationService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!apps.Any())
|
||||
return NoContent();
|
||||
|
||||
var appsResponse = mapper.Map<List<ApplicationResponse>>(apps);
|
||||
var paginationResponse = new PagedResponse<ApplicationResponse>(appsResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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 PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Управление типами приложений
|
||||
/// </summary>
|
||||
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ApplicationTypeController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationTypeService applicationTypeService;
|
||||
|
||||
public ApplicationTypeController(
|
||||
IMapper mapper,
|
||||
IApplicationTypeService applicationTypeService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.applicationTypeService = applicationTypeService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список типов приложений
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.ApplicationType.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var appTypes = await applicationTypeService.Get().OrderBy(t => t.Description)
|
||||
.ToListAsync();
|
||||
|
||||
if (!appTypes.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<ApplicationTypeResponse>>(appTypes);
|
||||
|
||||
return Ok(new Response<List<ApplicationTypeResponse>>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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 PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Статусы ЭК
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class EkStatusController : BaseApiController
|
||||
{
|
||||
private readonly IEkStatusService ekStatusService;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public EkStatusController(
|
||||
IEkStatusService ekStatusService,
|
||||
IMapper mapper
|
||||
)
|
||||
{
|
||||
this.ekStatusService = ekStatusService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить список статусов ЭК
|
||||
/// </summary>
|
||||
/// <returns></returns>млни
|
||||
[HttpGet(ApiRoutes.EkStatus.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var statuses = await ekStatusService.Get().OrderBy(t => t.Name).ToListAsync();
|
||||
|
||||
if (!statuses.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<EkStatusResponse>>(statuses);
|
||||
|
||||
return Ok(new Response<List<EkStatusResponse>>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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 PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Roles;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Зоны ответственности
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class ResponseAreaController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IResponseAreaService responseAreaService;
|
||||
|
||||
public ResponseAreaController(
|
||||
IMapper mapper,
|
||||
IResponseAreaService responseAreaService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.responseAreaService = responseAreaService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список зон ответственности
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.ResponseArea.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var query = responseAreaService.Get().OrderBy(t => t.Name);
|
||||
|
||||
var responseAreas = await query.ToListAsync();
|
||||
|
||||
if (!responseAreas.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<ResponseAreaResponse>>(responseAreas);
|
||||
|
||||
return Ok(new Response<List<ResponseAreaResponse>>(response, true));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить зону ответственности по коду
|
||||
/// </summary>
|
||||
/// <param name="responseAreaCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.ResponseArea.Get)]
|
||||
public async Task<IActionResult> Get([FromRoute] int responseAreaCode)
|
||||
{
|
||||
var responseArea = await responseAreaService.Get().FirstOrDefaultAsync(t => t.Code == responseAreaCode);
|
||||
|
||||
if (responseArea == null)
|
||||
return NotFound();
|
||||
|
||||
var response = mapper.Map<ResponseAreaResponse>(responseArea);
|
||||
|
||||
return Ok(new Response<ResponseAreaResponse>(response, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,19 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
public class StatResponseAreaWorkLoadController : BaseApiController
|
||||
{
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IResponseAreaService responseAreaService;
|
||||
//private readonly IResponseAreaService responseAreaService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IWorkLoadService workLoadService;
|
||||
|
||||
public StatResponseAreaWorkLoadController(
|
||||
ITemplateService templateService,
|
||||
IResponseAreaService responseAreaService,
|
||||
//IResponseAreaService responseAreaService,
|
||||
IMapper mapper,
|
||||
IWorkLoadService workLoadService
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.responseAreaService = responseAreaService;
|
||||
//this.responseAreaService = responseAreaService;
|
||||
this.mapper = mapper;
|
||||
this.workLoadService = workLoadService;
|
||||
}
|
||||
|
||||
@@ -19,20 +19,20 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class StatUnitFieldValuesController : BaseApiController
|
||||
{
|
||||
private readonly IApplicationService applicationService;
|
||||
//private readonly IApplicationService applicationService;
|
||||
private readonly IUnitFieldValueService unitFieldValueService;
|
||||
private readonly INextRunService nextRunService;
|
||||
|
||||
//private readonly ICalendarService calendarService;
|
||||
|
||||
public StatUnitFieldValuesController(
|
||||
IApplicationService applicationService,
|
||||
//IApplicationService applicationService,
|
||||
IUnitFieldValueService unitFieldValueService,
|
||||
//ICalendarService calendarService
|
||||
INextRunService nextRunService
|
||||
)
|
||||
{
|
||||
this.applicationService = applicationService;
|
||||
//this.applicationService = applicationService;
|
||||
this.unitFieldValueService = unitFieldValueService;
|
||||
this.nextRunService = nextRunService;
|
||||
//this.calendarService = calendarService;
|
||||
|
||||
@@ -20,21 +20,21 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
private readonly ITemplateService templateService;
|
||||
private readonly IWorkLoadService workLoadService;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
//private readonly IWorkGroupService workGroupService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ILogger<StatWorkGroupWorkLoadController> logger;
|
||||
|
||||
public StatWorkGroupWorkLoadController(
|
||||
ITemplateService templateService,
|
||||
IWorkLoadService workLoadService,
|
||||
IWorkGroupService workGroupService,
|
||||
//IWorkGroupService workGroupService,
|
||||
IMapper mapper,
|
||||
ILogger<StatWorkGroupWorkLoadController> logger
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.workLoadService = workLoadService;
|
||||
this.workGroupService = workGroupService;
|
||||
//this.workGroupService = workGroupService;
|
||||
this.mapper = mapper;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@@ -23,21 +23,21 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
private readonly IWorkLoadService workLoadService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ILogger<StatWorkWorkLoadController> logger;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
//private readonly IWorkGroupService workGroupService;
|
||||
|
||||
public StatWorkWorkLoadController(
|
||||
ITemplateService templateService,
|
||||
IWorkLoadService workLoadService,
|
||||
IMapper mapper,
|
||||
ILogger<StatWorkWorkLoadController> logger,
|
||||
IWorkGroupService workGroupService
|
||||
ILogger<StatWorkWorkLoadController> logger
|
||||
//IWorkGroupService workGroupService
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.workLoadService = workLoadService;
|
||||
this.mapper = mapper;
|
||||
this.logger = logger;
|
||||
this.workGroupService = workGroupService;
|
||||
//this.workGroupService = workGroupService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Enums;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Рабочие группы
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class WorkGroupController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IWorkGroupService workGroupService;
|
||||
|
||||
public WorkGroupController(
|
||||
IMapper mapper,
|
||||
IWorkGroupService workGroupService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.workGroupService = workGroupService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список рабочих групп постранично
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.WorkGroup.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WorkGroupQuery filter)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<WorkGroup> query = workGroupService.Get()
|
||||
.Include(t => t.ResponseArea)
|
||||
.OrderBy(t => t.Name);
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Name))
|
||||
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
||||
|
||||
if (filter.ResponseAreaCode.HasValue)
|
||||
{
|
||||
//todo: validate ResponseAreaEnum
|
||||
if (!Enum.IsDefined(typeof(ResponseAreaEnum), filter.ResponseAreaCode.Value))
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(filter.ResponseAreaCode), Message = "Неверное значение" } }));
|
||||
|
||||
query = query.Where(t => t.ResponseAreaCode == filter.ResponseAreaCode.Value);
|
||||
}
|
||||
|
||||
var workGroups = await workGroupService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!workGroups.Any())
|
||||
return NoContent();
|
||||
|
||||
var workGroupResponse = mapper.Map<List<WorkGroupResponse>>(workGroups);
|
||||
var paginationResponse = new PagedResponse<WorkGroupResponse>(workGroupResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить рабочую группу по id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.WorkGroup.Get)]
|
||||
public async Task<IActionResult> Get([FromRoute] Guid id)
|
||||
{
|
||||
var workGroup = await workGroupService.Get().Include(t => t.ResponseArea).FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (workGroup == null)
|
||||
return NotFound();
|
||||
|
||||
var response = mapper.Map<WorkGroupResponse>(workGroup);
|
||||
|
||||
return Ok(new Response<WorkGroupResponse>(response, true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user