feat(api): ApplicationTypeController, GetAll. Application GetAll исправлен фильтр по TypeId
This commit is contained in:
@@ -301,6 +301,11 @@
|
|||||||
public const string GetAll = Base + "/applications/";
|
public const string GetAll = Base + "/applications/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ApplicationType
|
||||||
|
{
|
||||||
|
public const string GetAll = Base + "/application-types/";
|
||||||
|
}
|
||||||
|
|
||||||
public static class EkStatus
|
public static class EkStatus
|
||||||
{
|
{
|
||||||
public const string GetAll = Base + "/ek-statuses/";
|
public const string GetAll = Base + "/ek-statuses/";
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ namespace PARR.API.Contracts.V1.Requests.Queries
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поиск по типу: 0 - APP, 1 - OS, 2 - DB
|
/// Поиск по типу
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ApplicationTypesEnum? Type { get; set; }
|
public Guid? TypeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Cors.Infrastructure;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using PARR.API.Contracts.V1;
|
using PARR.API.Contracts.V1;
|
||||||
@@ -23,17 +22,14 @@ namespace PARR.API.Controllers.V1
|
|||||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||||
public class ApplicationController : BaseApiController
|
public class ApplicationController : BaseApiController
|
||||||
{
|
{
|
||||||
private readonly ILogger<ApplicationController> logger;
|
|
||||||
private readonly IMapper mapper;
|
private readonly IMapper mapper;
|
||||||
private readonly IApplicationService applicationService;
|
private readonly IApplicationService applicationService;
|
||||||
|
|
||||||
public ApplicationController(
|
public ApplicationController(
|
||||||
ILogger<ApplicationController> logger,
|
|
||||||
IMapper mapper,
|
IMapper mapper,
|
||||||
IApplicationService applicationService
|
IApplicationService applicationService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
this.applicationService = applicationService;
|
this.applicationService = applicationService;
|
||||||
}
|
}
|
||||||
@@ -56,8 +52,8 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (!string.IsNullOrWhiteSpace(filter.Name))
|
if (!string.IsNullOrWhiteSpace(filter.Name))
|
||||||
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
|
||||||
|
|
||||||
if (filter.Type.HasValue)
|
if (filter.TypeId.HasValue)
|
||||||
query = query.Where(t => t.ApplicationType!.Name == filter.Type.Value.ToString());
|
query = query.Where(t => t.ApplicationTypeId == filter.TypeId);
|
||||||
|
|
||||||
|
|
||||||
var apps = await applicationService.GetPage(query, paginationFilter).ToListAsync();
|
var apps = await applicationService.GetPage(query, paginationFilter).ToListAsync();
|
||||||
|
|||||||
53
PARR.API/Controllers/V1/ApplicationTypeController.cs
Normal file
53
PARR.API/Controllers/V1/ApplicationTypeController.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
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.Constants;
|
||||||
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
|
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.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
if (!appTypes.Any())
|
||||||
|
return NoContent();
|
||||||
|
|
||||||
|
var response = mapper.Map<List<ApplicationTypeResponse>>(appTypes);
|
||||||
|
|
||||||
|
return Ok(new Response<List<ApplicationTypeResponse>>(response, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user