feat(api): в ApplicationInWorkResponse добавлены данные о расписании
This commit is contained in:
@@ -27,5 +27,20 @@
|
|||||||
public WorkResponse? Work { get; set; }
|
public WorkResponse? Work { get; set; }
|
||||||
|
|
||||||
public ApplicationResponse? Application { get; set; }
|
public ApplicationResponse? Application { get; set; }
|
||||||
|
|
||||||
|
public int TemplatesCount { get; set; }
|
||||||
|
|
||||||
|
public ApplicationInWorkScheduleResponse? Schedule { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class ApplicationInWorkScheduleResponse
|
||||||
|
{
|
||||||
|
public string Timezone { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public EsppScheduleTypeScheduleResponse? TypeSchedule { get; set; }
|
||||||
|
|
||||||
|
public List<EsppScheduleValResponse>? Values { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
IQueryable<ApplicationsInWork> query = applicationsInWorkService.Get()
|
IQueryable<ApplicationsInWork> query = applicationsInWorkService.Get()
|
||||||
.Include(t => t.Application).ThenInclude(t=>t!.ApplicationType)
|
.Include(t => t.Application).ThenInclude(t=>t!.ApplicationType)
|
||||||
.Include(t => t.Work)
|
.Include(t => t.Work)
|
||||||
|
.Include(t => t.Templates)
|
||||||
.OrderBy(t => t.ShortDescription);
|
.OrderBy(t => t.ShortDescription);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter.ShortDescription))
|
if (!string.IsNullOrEmpty(filter.ShortDescription))
|
||||||
@@ -144,6 +145,7 @@ namespace PARR.API.Controllers.V1
|
|||||||
var applicationInWork = await applicationsInWorkService.Get()
|
var applicationInWork = await applicationsInWorkService.Get()
|
||||||
.Include(t => t.Application).ThenInclude(t => t!.ApplicationType)
|
.Include(t => t.Application).ThenInclude(t => t!.ApplicationType)
|
||||||
.Include(t => t.Work)
|
.Include(t => t.Work)
|
||||||
|
.Include(t=>t.Templates)
|
||||||
.FirstOrDefaultAsync(t => t.Id == id);
|
.FirstOrDefaultAsync(t => t.Id == id);
|
||||||
|
|
||||||
if (applicationInWork == null)
|
if (applicationInWork == null)
|
||||||
|
|||||||
@@ -214,7 +214,9 @@ namespace PARR.API.MappingProfiles
|
|||||||
|
|
||||||
CreateMap<ApplicationsInWork, ApplicationInWorkResponse>()
|
CreateMap<ApplicationsInWork, ApplicationInWorkResponse>()
|
||||||
.ForMember(d => d.Work, o => o.MapFrom(s => s.Work))
|
.ForMember(d => d.Work, o => o.MapFrom(s => s.Work))
|
||||||
.ForMember(d => d.Application, o => o.MapFrom(s => s.Application));
|
.ForMember(d => d.Application, o => o.MapFrom(s => s.Application))
|
||||||
|
.ForMember(d => d.TemplatesCount, o => o.MapFrom(s => s.Templates.Count()))
|
||||||
|
.ForMember(d => d.Schedule, o => o.MapFrom<ApplicationInWorkScheduleResolver>());
|
||||||
|
|
||||||
|
|
||||||
CreateMap<EkStatus, EkStatusResponse>();
|
CreateMap<EkStatus, EkStatusResponse>();
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using PARR.API.Contracts.V1.Responses;
|
||||||
|
using PARR.DAL.Contracts;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
|
namespace PARR.API.MappingProfiles.Resolvers
|
||||||
|
{
|
||||||
|
public class ApplicationInWorkScheduleResolver : IValueResolver<ApplicationsInWork, ApplicationInWorkResponse, ApplicationInWorkScheduleResponse?>
|
||||||
|
{
|
||||||
|
private readonly IEsppSchTypeConfigService esppConfigService;
|
||||||
|
private readonly ILogger<ApplicationInWorkScheduleResolver> logger;
|
||||||
|
private readonly IMapper mapper;
|
||||||
|
private readonly SettingsFromDb settingsFromDb;
|
||||||
|
|
||||||
|
public ApplicationInWorkScheduleResolver(
|
||||||
|
IEsppSchTypeConfigService esppConfigService,
|
||||||
|
ILogger<ApplicationInWorkScheduleResolver> logger,
|
||||||
|
IMapper mapper,
|
||||||
|
SettingsFromDb settingsFromDb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.esppConfigService = esppConfigService;
|
||||||
|
this.logger = logger;
|
||||||
|
this.mapper = mapper;
|
||||||
|
this.settingsFromDb = settingsFromDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationInWorkScheduleResponse? Resolve(ApplicationsInWork source, ApplicationInWorkResponse destination, ApplicationInWorkScheduleResponse? destMember, ResolutionContext context)
|
||||||
|
{
|
||||||
|
var schedule = esppConfigService.GetEsppScheduleDto(source.Id);
|
||||||
|
|
||||||
|
if (schedule == null)
|
||||||
|
{
|
||||||
|
logger.LogError($"ApplicationInWorkScheduleResolver: Не смог замапить расписание, так как оно null. appInWorksId: {source.Id}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = new ApplicationInWorkScheduleResponse
|
||||||
|
{
|
||||||
|
Timezone = settingsFromDb.ScheduleTimezone,
|
||||||
|
TypeSchedule = mapper.Map<EsppScheduleTypeScheduleResponse>(schedule.TypeSchedule),
|
||||||
|
Values = mapper.Map<List<EsppScheduleValResponse>>(schedule.Values).OrderBy(t => t.Order).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user