feat(api): В ТНК добавлено поле продолжительность минут.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
namespace PARR.API.Contracts.V1.Requests
|
||||
{
|
||||
public class TnkRequest
|
||||
public record TnkRequest
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public string? ShortName { get; set; }
|
||||
public int? EsppId { get; set; }
|
||||
public Guid SubprocessId { get; set; }
|
||||
public required string Name { get; init; }
|
||||
public string? ShortName { get; init; }
|
||||
public int? EsppId { get; init; }
|
||||
public int? DurationMinutes { get; init; }
|
||||
public Guid SubprocessId { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
public int? EsppId { get; set; }
|
||||
|
||||
public int? DurationMinutes { get; set; }
|
||||
|
||||
public Guid SubprocessId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -27,21 +27,18 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ILogger<TnkController> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ITnkRepository tnkService;
|
||||
//private readonly IValidator<TnkRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
|
||||
public TnkController(
|
||||
ILogger<TnkController> logger,
|
||||
IMapper mapper,
|
||||
ITnkRepository tnkService,
|
||||
//IValidator<TnkRequest> validator,
|
||||
IUriService uriService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.tnkService = tnkService;
|
||||
//this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
}
|
||||
|
||||
@@ -127,23 +124,16 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Tnk.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] TnkRequest request)
|
||||
{
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var existName = await tnkService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower());
|
||||
if (existName != null)
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.Name), Message = $"Вид работы с именем \"{request.Name}\" уже существует." } }));
|
||||
|
||||
//var existEsppId = await tnkService.Get().FirstOrDefaultAsync(t => t.EsppId == request.EsppId);
|
||||
//if (existEsppId != null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.EsppId), Message = $"ТНК с EsppId: {request.EsppId} уже существует." } }));
|
||||
|
||||
var tnk = new Tnk
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = request.Name.Trim(),
|
||||
EsppId = request.EsppId,
|
||||
DurationMinutes = request.DurationMinutes,
|
||||
ShortName = request.ShortName?.Trim(),
|
||||
SubprocessId = request.SubprocessId
|
||||
};
|
||||
@@ -168,15 +158,6 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.Tnk.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] TnkRequest request)
|
||||
{
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
////проверка на уникальность esppId
|
||||
//var existEsppId = await tnkService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);
|
||||
//if (existEsppId != null)
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.EsppId), Message = $"Уже есть ТНК с EsppId: {request.EsppId}" } }));
|
||||
|
||||
var orig = await tnkService.Get()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
@@ -186,6 +167,7 @@ namespace PARR.API.Controllers.V1
|
||||
orig.Name = request.Name.Trim();
|
||||
orig.EsppId = request.EsppId;
|
||||
orig.SubprocessId = request.SubprocessId;
|
||||
orig.DurationMinutes = request.DurationMinutes;
|
||||
orig.ShortName = request.ShortName?.Trim();
|
||||
orig.DateModified = DateTimeOffset.UtcNow;
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace PARR.API.Validators
|
||||
|
||||
//RuleFor(t => t.EsppId).NotEmpty().NotNull().WithMessage("EsppId не может быть пустым");
|
||||
|
||||
RuleFor(t => t.DurationMinutes)
|
||||
.GreaterThanOrEqualTo(0)
|
||||
.When(t => t.DurationMinutes.HasValue)
|
||||
.WithMessage("Значение не может быть отрицательным");
|
||||
|
||||
RuleFor(t => t.SubprocessId).NotEmpty().NotNull();
|
||||
|
||||
RuleFor(t => t.SubprocessId)
|
||||
|
||||
4144
PARR.DAL/Migrations/20260915013519_tblTnkAddDurationMinutes.Designer.cs
generated
Normal file
4144
PARR.DAL/Migrations/20260915013519_tblTnkAddDurationMinutes.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblTnkAddDurationMinutes : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterTable(
|
||||
name: "Tnks",
|
||||
comment: "ТНК");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "DurationMinutes",
|
||||
table: "Tnks",
|
||||
type: "integer",
|
||||
nullable: true,
|
||||
comment: "Трудозатраты, минут");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DurationMinutes",
|
||||
table: "Tnks");
|
||||
|
||||
migrationBuilder.AlterTable(
|
||||
name: "Tnks",
|
||||
oldComment: "ТНК");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2990,6 +2990,10 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int?>("DurationMinutes")
|
||||
.HasColumnType("integer")
|
||||
.HasComment("Трудозатраты, минут");
|
||||
|
||||
b.Property<int?>("EsppId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@@ -3007,7 +3011,10 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasIndex("SubprocessId");
|
||||
|
||||
b.ToTable("Tnks");
|
||||
b.ToTable("Tnks", t =>
|
||||
{
|
||||
t.HasComment("ТНК");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.Domain.Entities.Unit.Unit", b =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PARR.Domain.Entities.Base;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.Domain.Entities.Base;
|
||||
using PARR.Domain.Entities.JobEntities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
@@ -6,6 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
namespace PARR.Domain.Entities
|
||||
{
|
||||
[Table("Tnks")]
|
||||
[Comment("ТНК")]
|
||||
//[Index(nameof(EsppId), IsUnique = true)]
|
||||
public class Tnk : IBaseEntity
|
||||
{
|
||||
@@ -25,6 +27,9 @@ namespace PARR.Domain.Entities
|
||||
|
||||
public int? EsppId { get; set; }
|
||||
|
||||
[Comment("Трудозатраты, минут")]
|
||||
public int? DurationMinutes { get; set; }
|
||||
|
||||
public Guid SubprocessId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(SubprocessId))]
|
||||
|
||||
Reference in New Issue
Block a user