feat(api,dal): в модель JobGroupType добавлено поле description. В job контроллерах убрано поле isUmbrella, добавлено JobType.
This commit is contained in:
@@ -389,6 +389,11 @@
|
||||
public const string getParam = "{id}";
|
||||
}
|
||||
|
||||
public static class JobGroupType
|
||||
{
|
||||
public const string GetAll = Base + "/job-group-types/";
|
||||
}
|
||||
|
||||
public static class JobAutoControl
|
||||
{
|
||||
public const string Get = Base + "/jobs/" + appInWorkId + "/auto-control";
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
|
||||
public bool? IsUmbrella { get; set; }
|
||||
//public bool? IsUmbrella { get; set; }
|
||||
|
||||
public Guid GroupTypeId { get; set; }
|
||||
|
||||
public required string ShortDescription { get; set; }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace PARR.API.Contracts.V1.Responses
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public bool? IsUmbrella { get; set; }
|
||||
//public bool? IsUmbrella { get; set; }
|
||||
|
||||
public required string ShortDescription { get; set; }
|
||||
|
||||
@@ -20,15 +20,17 @@ namespace PARR.API.Contracts.V1.Responses
|
||||
|
||||
public DateTimeOffset ReferenceDate { get; set; }
|
||||
|
||||
// public bool IsAutoDistributionEnabled { get; set; }
|
||||
public JobGroupTypeResponse GroupType { get; set; }
|
||||
|
||||
// public bool IsAgent { get; set; }
|
||||
// public bool IsAutoDistributionEnabled { get; set; }
|
||||
|
||||
// public string? AgentName { get; set; }
|
||||
// public bool IsAgent { get; set; }
|
||||
|
||||
// public int? AgentTimeOutSec { get; set; }
|
||||
// public string? AgentName { get; set; }
|
||||
|
||||
// public string? AgentScript { get; set; }
|
||||
// public int? AgentTimeOutSec { get; set; }
|
||||
|
||||
// public string? AgentScript { get; set; }
|
||||
}
|
||||
|
||||
public class JobGroupResponse : JobGroupBaseResponse
|
||||
|
||||
15
PARR.API/Contracts/V1/Responses/JobGroupTypeResponse.cs
Normal file
15
PARR.API/Contracts/V1/Responses/JobGroupTypeResponse.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using PARR.DAL.Contracts;
|
||||
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class JobGroupTypeResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required JobGroupTypesEnum Code { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
query = query
|
||||
.Include(t => t.Tnk)
|
||||
.Include(t => t.Group);
|
||||
.Include(t => t.Group).ThenInclude(t=>t.GroupType);
|
||||
|
||||
query = query
|
||||
.Include(t => t.UnitFilters)
|
||||
@@ -117,7 +117,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
var job = await jobService.Get()
|
||||
.Include(t => t.Tnk)
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.Group).ThenInclude(t=>t.GroupType)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
@@ -178,7 +178,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
var createdJob = await jobService.Get()
|
||||
.Include(t => t.Tnk)
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.Group).ThenInclude(t=>t.GroupType)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
@@ -211,7 +211,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
var orig = await jobService.Get()
|
||||
.Include(t => t.Tnk)
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.Group).ThenInclude(t=>t.GroupType)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.Include(t => t.UnitFilters)
|
||||
@@ -298,7 +298,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
var updatedJob = await jobService.Get()
|
||||
.Include(t => t.Tnk)
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.Group).ThenInclude(t => t.GroupType)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<JobGroup> query = groupService.Get();
|
||||
IQueryable<JobGroup> query = groupService.Get().Include(t => t.GroupType);
|
||||
|
||||
query = query.OrderBy(t => t.GroupName);
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
var jobGroup = await groupService.Get()
|
||||
.Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
||||
.Include(t => t.GroupType)
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (jobGroup == null)
|
||||
@@ -133,7 +134,8 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
GroupName = request.Name.Trim(),
|
||||
IsUmbrella = request.IsUmbrella,
|
||||
//IsUmbrella = request.IsUmbrella,
|
||||
GroupTypeId = request.GroupTypeId,
|
||||
ShortDescription = request.ShortDescription.Trim(),
|
||||
FullDescription = request.FullDescription.Trim(),
|
||||
Solution = request.Solution.Trim(),
|
||||
@@ -164,6 +166,7 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
|
||||
var createdJobGroup = await groupService.Get().Include(t => t.Jobs).ThenInclude(t => t.Tnk)
|
||||
.Include(t => t.GroupType)
|
||||
.FirstAsync(t => t.Id == jobGroup.Id);
|
||||
|
||||
var locationUri = uriService.GetUri(ApiRoutes.JobGroup.Get, ApiRoutes.JobGroup.getParam, createdJobGroup.Id);
|
||||
@@ -201,7 +204,8 @@ namespace PARR.API.Controllers.V1
|
||||
var isScheduleChanged = IsScheduleChanged(orig, request);
|
||||
|
||||
orig.GroupName = request.Name.Trim();
|
||||
orig.IsUmbrella = request.IsUmbrella;
|
||||
//orig.IsUmbrella = request.IsUmbrella;
|
||||
orig.GroupTypeId = request.GroupTypeId;
|
||||
orig.ShortDescription = request.ShortDescription.Trim();
|
||||
orig.FullDescription = request.FullDescription.Trim();
|
||||
orig.Solution = request.Solution.Trim();
|
||||
@@ -258,6 +262,7 @@ namespace PARR.API.Controllers.V1
|
||||
var updatedJobGroup = await groupService.Get()
|
||||
.Include(t => t.Jobs)
|
||||
.ThenInclude(t => t.Tnk)
|
||||
.Include(t => t.GroupType)
|
||||
.FirstAsync(t => t.Id == orig.Id);
|
||||
|
||||
var response = mapper.Map<JobGroupResponse>(updatedJobGroup);
|
||||
|
||||
48
PARR.API/Controllers/V1/JobGroupTypeController.cs
Normal file
48
PARR.API/Controllers/V1/JobGroupTypeController.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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.Job;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Список типов групп работ
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class JobGroupTypeController : BaseApiController
|
||||
{
|
||||
private readonly IJobGroupTypeService jobGroupTypeService;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public JobGroupTypeController(
|
||||
IJobGroupTypeService jobGroupTypeService,
|
||||
IMapper mapper
|
||||
)
|
||||
{
|
||||
this.jobGroupTypeService = jobGroupTypeService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet(ApiRoutes.JobGroupType.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var query = jobGroupTypeService.Get().OrderBy(t => t.Description);
|
||||
|
||||
var types = await query.ToListAsync();
|
||||
|
||||
if (!types.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<JobGroupTypeResponse>>(types);
|
||||
|
||||
return Ok(new Response<List<JobGroupTypeResponse>>(response, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ namespace PARR.API.MappingProfiles
|
||||
},
|
||||
Values = fieldGroup.Select(s => new UnitFieldValueResponse { Id = s.ValueId, Value = s.Value!.Value }).ToList()
|
||||
}
|
||||
).OrderBy(o=>o.Field.Name)
|
||||
).OrderBy(o => o.Field.Name)
|
||||
));
|
||||
#endregion
|
||||
|
||||
@@ -332,7 +332,8 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
#region JobGroup
|
||||
CreateMap<JobGroup, JobGroupBaseResponse>()
|
||||
.Include<JobGroup, JobGroupResponse>();
|
||||
.Include<JobGroup, JobGroupResponse>()
|
||||
.ForMember(d => d.GroupType, o => o.MapFrom(s => s.GroupType));
|
||||
|
||||
CreateMap<JobGroup, JobGroupBaseResponse>()
|
||||
.ForMember(d => d.Name, o => o.MapFrom(s => s.GroupName));
|
||||
@@ -340,6 +341,12 @@ namespace PARR.API.MappingProfiles
|
||||
CreateMap<JobGroup, JobGroupResponse>();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region JobGroupType
|
||||
|
||||
CreateMap<JobGroupType, JobGroupTypeResponse>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region JobAutoControl
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using FluentValidation;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
|
||||
namespace PARR.API.Validators
|
||||
{
|
||||
public class JobGroupValidator : AbstractValidator<JobGroupRequest>
|
||||
{
|
||||
public JobGroupValidator()
|
||||
public JobGroupValidator(IJobGroupTypeService jobGroupTypeService)
|
||||
{
|
||||
RuleFor(t => t.Name)
|
||||
.NotNull().NotEmpty();
|
||||
@@ -21,6 +22,10 @@ namespace PARR.API.Validators
|
||||
|
||||
RuleFor(t => t.TemplateDuration)
|
||||
.NotNull().NotEmpty();
|
||||
|
||||
RuleFor(t => t.GroupTypeId)
|
||||
.MustAsync(async (entity, value, c) => await jobGroupTypeService.GetAsync(value) != null)
|
||||
.WithMessage("Указан несуществующий Id типа");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user