Дополнить исправления

This commit is contained in:
Roman Efremov 2024-12-04 16:29:15 +05:00
parent dd888793fd
commit 2228c84139
5 changed files with 9 additions and 11 deletions

View File

@ -101,10 +101,11 @@ public class SetpointController : ControllerBase, ISetpointApi
/// <param name="token"></param>
/// <returns></returns>
[HttpPost]
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
public async Task<IActionResult> Add(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
[ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
public async Task<IActionResult> Add(Guid setpointKey, object newValue, CancellationToken token)
{
await setpointRepository.Add(setpointKey, newValue, idUser, token);
var userId = User.GetUserId<Guid>();
await setpointRepository.Add(setpointKey, newValue, userId, token);
return CreatedAtAction(nameof(Add), true);
}

View File

@ -110,12 +110,8 @@ public class TechMessagesController : ControllerBase
public async Task<IActionResult> AddRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token)
{
var userId = User.GetUserId<Guid>();
foreach (var dto in dtos)
{
dto.UserId = userId;
}
var result = await techMessagesRepository.AddRange(dtos, token);
var result = await techMessagesRepository.AddRange(dtos, userId, token);
return CreatedAtAction(nameof(AddRange), result);
}

View File

@ -88,7 +88,7 @@ namespace Persistence.Repository.Repositories
return result;
}
public async Task<int> AddRange(IEnumerable<TechMessageDto> dtos, CancellationToken token)
public async Task<int> AddRange(IEnumerable<TechMessageDto> dtos, Guid userId, CancellationToken token)
{
var entities = new List<TechMessage>();
@ -100,6 +100,7 @@ namespace Persistence.Repository.Repositories
?? await CreateDrillingSystem(dto.System, token);
entity.SystemId = systemId;
entity.UserId = userId;
entities.Add(entity);
}

View File

@ -40,5 +40,5 @@ public interface ISetpointApi : ISyncApi<SetpointLogDto>
/// <param name="newValue">значение</param>
/// <param name="token"></param>
/// <returns></returns>
Task<IActionResult> Add(Guid setpointKey, object newValue, Guid userId, CancellationToken token);
Task<IActionResult> Add(Guid setpointKey, object newValue, CancellationToken token);
}

View File

@ -22,7 +22,7 @@ namespace Persistence.Repositories
/// <param name="dtos"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<int> AddRange(IEnumerable<TechMessageDto> dtos, CancellationToken token);
Task<int> AddRange(IEnumerable<TechMessageDto> dtos, Guid userId, CancellationToken token);
/// <summary>
/// Получение списка уникальных названий систем АБ