feat(dal, api): в таблицу RobotHistories добавлено поле RobotIp. Из таблицы AppInWorks удалены поля Next/LastRun. В историю работы роботов, пишется ip робота.

This commit is contained in:
Mikhail Trubnikov
2024-07-22 14:48:44 +10:00
parent fc197a6a5b
commit 08b8fba8a5
9 changed files with 3015 additions and 14 deletions

View File

@@ -24,7 +24,9 @@
public RobotResponse? Robot { get; set; }
public string? RobotIp { get; set; }
public UserBaseResponse? User { get; set; }
}
}

View File

@@ -1,19 +1,29 @@
namespace PARR.API.Contracts.V1.Responses
{
public class UserResponse
public class UserResponse : UserBaseResponse
{
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public required string Ip { get; set; }
//public required string Ip { get; set; }
public string Name { get; set; } = string.Empty;
//public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
//public string Description { get; set; } = string.Empty;
public DateTimeOffset? LastLogon { get; set; }
public List<RoleResponse>? Roles { get; set; }
}
public class UserBaseResponse
{
public required string Ip { get; set; }
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}
}

View File

@@ -27,13 +27,15 @@ namespace PARR.API.Controllers.V1
private readonly IUriService uriService;
private readonly IRobotHistoryService robotHistoryService;
private readonly IRobotConfigurationService robotConfigurationService;
private readonly IClientService clientService;
public RobotHistoryController(
IValidator<RobotHistoryRequest> validator,
IMapper mapper,
IUriService uriService,
IRobotHistoryService robotHistoryService,
IRobotConfigurationService robotConfigurationService
IRobotConfigurationService robotConfigurationService,
IClientService clientService
)
{
this.validator = validator;
@@ -41,6 +43,7 @@ namespace PARR.API.Controllers.V1
this.uriService = uriService;
this.robotHistoryService = robotHistoryService;
this.robotConfigurationService = robotConfigurationService;
this.clientService = clientService;
}
@@ -109,7 +112,8 @@ namespace PARR.API.Controllers.V1
RobotMessage = request.RobotMessage,
EsppMessage = request.EsppMessage,
TaskStatusCode = config.TaskStatusCode,
RobotConfigurationId = request.TaskId
RobotConfigurationId = request.TaskId,
RobotIp = clientService.GetClientIp()?.ToString()
};
if (!await robotHistoryService.CreateAsync(history) || !await robotHistoryService.CommitAsync())

View File

@@ -7,6 +7,7 @@ using PARR.API.Contracts.V1.Requests;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Services.Interfaces;
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
@@ -20,16 +21,19 @@ namespace PARR.API.Controllers.V1
private readonly IRobotConfigurationService robotConfigurationService;
private readonly IRobotHistoryService robotHistoryService;
private readonly IMapper mapper;
private readonly IClientService clientService;
public RobotTaskRobotStatusController(
IRobotConfigurationService robotConfigurationService,
IRobotHistoryService robotHistoryService,
IMapper mapper
IMapper mapper,
IClientService clientService
)
{
this.robotConfigurationService = robotConfigurationService;
this.robotHistoryService = robotHistoryService;
this.mapper = mapper;
this.clientService = clientService;
}
@@ -67,7 +71,8 @@ namespace PARR.API.Controllers.V1
Id = Guid.NewGuid(),
HistoryLevel = (int)historyLevel,
TaskStatusCode = config.TaskStatusCode,
RobotConfigurationId = config.Id
RobotConfigurationId = config.Id,
RobotIp = clientService.GetClientIp()?.ToString()
};
await robotHistoryService.CreateAsync(history);
await robotHistoryService.CommitAsync();

View File

@@ -232,6 +232,11 @@ namespace PARR.API.MappingProfiles
#region User
CreateMap<User, UserBaseResponse>()
.Include<User, UserResponse>();
CreateMap<User, UserBaseResponse>();
CreateMap<User, UserResponse>()
.ForMember(t => t.Roles, o => o.MapFrom(s => s.Roles.Select(t => t.Role).OrderBy(t => t!.Description)));