feat(dal,api): в таблицу Tnk, добавлено поле ShortName
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
public class TnkRequest
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public int EsppId { get; set; }
|
||||
public string? ShortName { get; set; }
|
||||
public int? EsppId { get; set; }
|
||||
public Guid SubprocessId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public int EsppId { get; set; }
|
||||
public string? ShortName { get; set; }
|
||||
|
||||
public int? EsppId { get; set; }
|
||||
|
||||
public Guid SubprocessId { get; set; }
|
||||
}
|
||||
|
||||
@@ -135,16 +135,17 @@ namespace PARR.API.Controllers.V1
|
||||
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 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,
|
||||
SubprocessId = request.SubprocessId,
|
||||
ShortName = request.ShortName?.Trim(),
|
||||
SubprocessId = request.SubprocessId
|
||||
};
|
||||
|
||||
if (!await tnkService.CreateAsync(tnk) || !await tnkService.CommitAsync())
|
||||
@@ -171,10 +172,10 @@ namespace PARR.API.Controllers.V1
|
||||
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}" } }));
|
||||
////проверка на уникальность 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);
|
||||
@@ -185,6 +186,7 @@ namespace PARR.API.Controllers.V1
|
||||
orig.Name = request.Name.Trim();
|
||||
orig.EsppId = request.EsppId;
|
||||
orig.SubprocessId = request.SubprocessId;
|
||||
orig.ShortName = request.ShortName?.Trim();
|
||||
orig.DateModified = DateTimeOffset.UtcNow;
|
||||
|
||||
if (!await tnkService.CommitAsync())
|
||||
|
||||
@@ -210,7 +210,11 @@ namespace PARR.API.MappingProfiles
|
||||
.ForMember(d => d.SubprocessName, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Subprocess!.Name))
|
||||
.ForMember(d => d.SubprocessEsppId, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Subprocess!.EsppId))
|
||||
.ForMember(d => d.TnkName, o => o.MapFrom(s => s.Template!.Job!.Tnk!.Name))
|
||||
.ForMember(d => d.TnkEsppId, o => o.MapFrom(s => s.Template!.Job!.Tnk!.EsppId))
|
||||
.ForMember(d => d.TnkEsppId, o => o.MapFrom(s =>
|
||||
s.Template!.Job!.Tnk!.EsppId.HasValue
|
||||
? s.Template!.Job!.Tnk!.EsppId.Value.ToString()
|
||||
: string.Empty
|
||||
))
|
||||
.ForMember(d => d.WorkName, o => o.MapFrom(s => s.Template!.Job!.WorkName))
|
||||
//.ForMember(d => d.WorkEsppId, o => o.MapFrom(s => s.Template!.Job!.EsppId))
|
||||
.ForMember(d => d.ScheduleEsppId, o => o.MapFrom(s => s.Template!.ScheduleEsppId));
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace PARR.API.Validators
|
||||
|
||||
RuleFor(t => t.Name).NotEmpty().NotNull();
|
||||
|
||||
RuleFor(t => t.EsppId).NotEmpty().NotNull().WithMessage("EsppId не может быть пустым");
|
||||
//RuleFor(t => t.EsppId).NotEmpty().NotNull().WithMessage("EsppId не может быть пустым");
|
||||
|
||||
RuleFor(t => t.SubprocessId).NotEmpty().NotNull();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user