feat(api): реализован GetAll UnitFieldValue по Id FieldValue
This commit is contained in:
@@ -431,13 +431,16 @@
|
||||
public const string getParam = "{id}";
|
||||
}
|
||||
|
||||
#region UnitField
|
||||
public static class UnitField
|
||||
{
|
||||
public const string GetAll = Base + "/unit-fields/";
|
||||
public const string Get = Base + "/unit-fields/" + getParam;
|
||||
public const string GetAllValues = Base + "/unit-fields/" + getParam+"/values";
|
||||
|
||||
public const string getParam = "{id}";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Расписание ЕСПП
|
||||
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
/// <summary>
|
||||
/// Соответствующее полю значение
|
||||
/// </summary>
|
||||
public required ValueResponse Value { get; set; }
|
||||
public required UnitFieldValueResponse Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
11
PARR.API/Contracts/V1/Responses/UnitFieldValueResponse.cs
Normal file
11
PARR.API/Contracts/V1/Responses/UnitFieldValueResponse.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class UnitFieldValueBaseResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
|
||||
public class UnitFieldValueResponse : UnitFieldValueBaseResponse { }
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class ValueBaseResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ValueResponse : ValueBaseResponse
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,11 @@ 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;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
|
||||
namespace PARR.API.Controllers
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Справочник полей
|
||||
67
PARR.API/Controllers/V1/UnitFieldValueController.cs
Normal file
67
PARR.API/Controllers/V1/UnitFieldValueController.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
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.Constants;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Services.Interfaces.Unit;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Управление значениями атрибутов
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class UnitFieldValueController : BaseApiController
|
||||
{
|
||||
private readonly ILogger<TnkController> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IUnitFieldService unitFieldService;
|
||||
private readonly IUnitFieldValueService unitFieldValueService;
|
||||
|
||||
public UnitFieldValueController(
|
||||
ILogger<TnkController> logger,
|
||||
IMapper mapper,
|
||||
IUnitFieldService unitFieldService,
|
||||
IUnitFieldValueService unitFieldValueService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.unitFieldService = unitFieldService;
|
||||
this.unitFieldValueService = unitFieldValueService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Список доступных значений аттрибутов
|
||||
/// </summary>
|
||||
/// <param name="paginationQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.UnitField.GetAllValues)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromRoute] Guid id)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
var query = unitFieldValueService.Get()
|
||||
.Where(t => t.UnitInValues.Any(t => t.FieldId == id))
|
||||
.OrderBy(t => t.Value);
|
||||
|
||||
var fieldValues = await unitFieldValueService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!fieldValues.Any())
|
||||
return NoContent();
|
||||
|
||||
var fielsValuesResponse = mapper.Map<List<UnitFieldValueResponse>>(fieldValues);
|
||||
var paginationResponse = new PagedResponse<UnitFieldValueResponse>(fielsValuesResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ namespace PARR.API.MappingProfiles
|
||||
CreateMap<UnitField, FieldResponse>()
|
||||
.ForMember(d => d.Name, o => o.MapFrom(s => (string.IsNullOrEmpty(s.DisplayName)) ? s.AihitName : s.DisplayName));
|
||||
|
||||
CreateMap<UnitFieldValue, ValueResponse>();
|
||||
CreateMap<UnitFieldValue, UnitFieldValueResponse>();
|
||||
|
||||
CreateMap<UnitInValue, AttributeResponse>()
|
||||
.ForMember(d => d.Field, o => o.MapFrom(s => s.Field))
|
||||
@@ -353,9 +353,6 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
CreateMap<WeekendDay, WeekendResponse>();
|
||||
|
||||
CreateMap<UnitField, FieldResponse>()
|
||||
.ForMember(d => d.Name, o => o.MapFrom(s => (s.DisplayName == null) ? s.AihitName : s.DisplayName));
|
||||
|
||||
#region TemplateHistory
|
||||
|
||||
CreateMap<TemplateHistory, TemplateHistoryResponse>()
|
||||
|
||||
Reference in New Issue
Block a user