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,6 +20,8 @@ namespace PARR.API.Contracts.V1.Responses
|
||||
|
||||
public DateTimeOffset ReferenceDate { get; set; }
|
||||
|
||||
public JobGroupTypeResponse GroupType { get; set; }
|
||||
|
||||
// public bool IsAutoDistributionEnabled { get; set; }
|
||||
|
||||
// public bool IsAgent { get; set; }
|
||||
|
||||
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 типа");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ namespace PARR.DAL.Context
|
||||
modelBuilder.Entity<JobGroupType>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
new() { Id = new Guid("4FA62E79-86BB-47C2-BE1A-72A716A170FA"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Simple.ToString(), Code = JobGroupTypesEnum.Simple },
|
||||
new() { Id = new Guid("6EC58B1A-5C40-47B9-B036-4FA490E8D503"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Umbrella.ToString(), Code = JobGroupTypesEnum.Umbrella },
|
||||
new() { Id = new Guid("318625E5-F833-436A-99DF-2A382A1E71C7"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Group.ToString(), Code = JobGroupTypesEnum.Group }
|
||||
new() { Id = new Guid("4FA62E79-86BB-47C2-BE1A-72A716A170FA"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Simple.ToString(), Code = JobGroupTypesEnum.Simple, Description = "Обычный" },
|
||||
new() { Id = new Guid("6EC58B1A-5C40-47B9-B036-4FA490E8D503"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Umbrella.ToString(), Code = JobGroupTypesEnum.Umbrella, Description = "Зонтик" },
|
||||
new() { Id = new Guid("318625E5-F833-436A-99DF-2A382A1E71C7"), DateCreated = dateCreated, DateModified = null, Name = JobGroupTypesEnum.Group.ToString(), Code = JobGroupTypesEnum.Group, Description = "Сгруппированный" }
|
||||
);
|
||||
});
|
||||
#endregion
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace PARR.DAL.DomainServices.Implementations
|
||||
//фильтруем по количеству связей
|
||||
if (job.Group?.IsUmbrella == true)
|
||||
{
|
||||
if (job.isParentRelationships == true)
|
||||
if (job.IsParentRelationships == true)
|
||||
query = query.Where(t => t.ParentUnits.Count >= job.MinValueRelationships && t.ParentUnits.Count <= job.MaxValueRelationships);
|
||||
else
|
||||
query = query.Where(t => t.ChildUnits.Count >= job.MinValueRelationships && t.ChildUnits.Count <= job.MaxValueRelationships);
|
||||
|
||||
3967
PARR.DAL/Migrations/20251117012034_tblJobGroupTypeAddDescription.Designer.cs
generated
Normal file
3967
PARR.DAL/Migrations/20251117012034_tblJobGroupTypeAddDescription.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblJobGroupTypeAddDescription : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Description",
|
||||
schema: "job",
|
||||
table: "GroupTypes",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
schema: "job",
|
||||
table: "GroupTypes",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("318625e5-f833-436a-99df-2a382a1e71c7"),
|
||||
column: "Description",
|
||||
value: "Сгруппированный");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
schema: "job",
|
||||
table: "GroupTypes",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("4fa62e79-86bb-47c2-be1a-72a716a170fa"),
|
||||
column: "Description",
|
||||
value: "Обычный");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
schema: "job",
|
||||
table: "GroupTypes",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("6ec58b1a-5c40-47b9-b036-4fa490e8d503"),
|
||||
column: "Description",
|
||||
value: "Зонтик");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Description",
|
||||
schema: "job",
|
||||
table: "GroupTypes");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1709,6 +1709,10 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@@ -1726,6 +1730,7 @@ namespace PARR.DAL.Migrations
|
||||
Id = new Guid("4fa62e79-86bb-47c2-be1a-72a716a170fa"),
|
||||
Code = 0,
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Обычный",
|
||||
Name = "Simple"
|
||||
},
|
||||
new
|
||||
@@ -1733,6 +1738,7 @@ namespace PARR.DAL.Migrations
|
||||
Id = new Guid("6ec58b1a-5c40-47b9-b036-4fa490e8d503"),
|
||||
Code = 1,
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Зонтик",
|
||||
Name = "Umbrella"
|
||||
},
|
||||
new
|
||||
@@ -1740,6 +1746,7 @@ namespace PARR.DAL.Migrations
|
||||
Id = new Guid("318625e5-f833-436a-99df-2a382a1e71c7"),
|
||||
Code = 2,
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Сгруппированный",
|
||||
Name = "Group"
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace PARR.DAL.Models.Job
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
|
||||
public ICollection<JobGroup> JobGroups { get; set; } = new HashSet<JobGroup>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user