feat(dal, api): в таблицу RobotHistories добавлено поле RobotIp. Из таблицы AppInWorks удалены поля Next/LastRun. В историю работы роботов, пишется ip робота.
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
|
||||
public RobotResponse? Robot { get; set; }
|
||||
|
||||
public string? RobotIp { get; set; }
|
||||
|
||||
public UserBaseResponse? User { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)));
|
||||
|
||||
|
||||
2923
PARR.DAL/Migrations/20240722042527_tblRobotHistoriesAddRobotIp.Designer.cs
generated
Normal file
2923
PARR.DAL/Migrations/20240722042527_tblRobotHistoriesAddRobotIp.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblRobotHistoriesAddRobotIp : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "LastRun",
|
||||
table: "ApplicationsInWorks");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NextRun",
|
||||
table: "ApplicationsInWorks");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "RobotIp",
|
||||
table: "RobotHistories",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RobotIp",
|
||||
table: "RobotHistories");
|
||||
|
||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||
name: "LastRun",
|
||||
table: "ApplicationsInWorks",
|
||||
type: "timestamp with time zone",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||
name: "NextRun",
|
||||
table: "ApplicationsInWorks",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,12 +269,6 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<bool>("IsAutoDistributionEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset?>("LastRun")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset>("NextRun")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset>("ReferenceDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@@ -1896,6 +1890,9 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<Guid>("RobotConfigurationId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("RobotIp")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("RobotMessage")
|
||||
.HasColumnType("text");
|
||||
|
||||
|
||||
@@ -26,6 +26,11 @@ namespace PARR.DAL.Models
|
||||
|
||||
public Guid RobotConfigurationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// IP адрес робота
|
||||
/// </summary>
|
||||
public string? RobotIp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// Уникальный идентификатор серии выполнения, нужен для сопоставления истории
|
||||
///// </summary>
|
||||
|
||||
Reference in New Issue
Block a user