diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs
index 0696bbcf..e3b408cd 100644
--- a/PARR.API/Contracts/V1/ApiRoutes.cs
+++ b/PARR.API/Contracts/V1/ApiRoutes.cs
@@ -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 Расписание ЕСПП
diff --git a/PARR.API/Contracts/V1/Responses/AttributeResponse.cs b/PARR.API/Contracts/V1/Responses/AttributeResponse.cs
index 56ee4557..5d635976 100644
--- a/PARR.API/Contracts/V1/Responses/AttributeResponse.cs
+++ b/PARR.API/Contracts/V1/Responses/AttributeResponse.cs
@@ -10,6 +10,6 @@
///
/// Соответствующее полю значение
///
- public required ValueResponse Value { get; set; }
+ public required UnitFieldValueResponse Value { get; set; }
}
}
diff --git a/PARR.API/Contracts/V1/Responses/UnitFieldValueResponse.cs b/PARR.API/Contracts/V1/Responses/UnitFieldValueResponse.cs
new file mode 100644
index 00000000..c25b46eb
--- /dev/null
+++ b/PARR.API/Contracts/V1/Responses/UnitFieldValueResponse.cs
@@ -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 { }
+}
diff --git a/PARR.API/Contracts/V1/Responses/ValueBaseResponse.cs b/PARR.API/Contracts/V1/Responses/ValueBaseResponse.cs
deleted file mode 100644
index 0786ca52..00000000
--- a/PARR.API/Contracts/V1/Responses/ValueBaseResponse.cs
+++ /dev/null
@@ -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
- {
-
- }
-}
diff --git a/PARR.API/Controllers/UnitFieldController.cs b/PARR.API/Controllers/V1/UnitFieldController.cs
similarity index 97%
rename from PARR.API/Controllers/UnitFieldController.cs
rename to PARR.API/Controllers/V1/UnitFieldController.cs
index 0e078d5d..692145fd 100644
--- a/PARR.API/Controllers/UnitFieldController.cs
+++ b/PARR.API/Controllers/V1/UnitFieldController.cs
@@ -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
{
///
/// Справочник полей
diff --git a/PARR.API/Controllers/V1/UnitFieldValueController.cs b/PARR.API/Controllers/V1/UnitFieldValueController.cs
new file mode 100644
index 00000000..387b9269
--- /dev/null
+++ b/PARR.API/Controllers/V1/UnitFieldValueController.cs
@@ -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
+{
+ ///
+ /// Управление значениями атрибутов
+ ///
+ [Authorize(Roles = ParrRoles.Administrator.Role)]
+ public class UnitFieldValueController : BaseApiController
+ {
+ private readonly ILogger logger;
+ private readonly IMapper mapper;
+ private readonly IUnitFieldService unitFieldService;
+ private readonly IUnitFieldValueService unitFieldValueService;
+
+ public UnitFieldValueController(
+ ILogger logger,
+ IMapper mapper,
+ IUnitFieldService unitFieldService,
+ IUnitFieldValueService unitFieldValueService
+ )
+ {
+ this.logger = logger;
+ this.mapper = mapper;
+ this.unitFieldService = unitFieldService;
+ this.unitFieldValueService = unitFieldValueService;
+ }
+
+ ///
+ /// Список доступных значений аттрибутов
+ ///
+ ///
+ ///
+ [HttpGet(ApiRoutes.UnitField.GetAllValues)]
+ public async Task GetAll([FromQuery] PaginationQuery paginationQuery, [FromRoute] Guid id)
+ {
+ var paginationFilter = mapper.Map(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>(fieldValues);
+ var paginationResponse = new PagedResponse(fielsValuesResponse, true).GetPaginatedProps(paginationFilter, query);
+
+ return Ok(paginationResponse);
+ }
+
+ }
+}
diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
index 459207e9..a73e0bb7 100644
--- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs
+++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
@@ -108,7 +108,7 @@ namespace PARR.API.MappingProfiles
CreateMap()
.ForMember(d => d.Name, o => o.MapFrom(s => (string.IsNullOrEmpty(s.DisplayName)) ? s.AihitName : s.DisplayName));
- CreateMap();
+ CreateMap();
CreateMap()
.ForMember(d => d.Field, o => o.MapFrom(s => s.Field))
@@ -353,9 +353,6 @@ namespace PARR.API.MappingProfiles
CreateMap();
- CreateMap()
- .ForMember(d => d.Name, o => o.MapFrom(s => (s.DisplayName == null) ? s.AihitName : s.DisplayName));
-
#region TemplateHistory
CreateMap()