forked from ddrilling/AsbCloudServer
Rename ICrudWellRelatedService to IRepositoryWellRelated, and related services
This commit is contained in:
parent
8bf7a03821
commit
0486dd9462
@ -9,7 +9,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// РТК
|
/// РТК
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDrillFlowChartService : ICrudWellRelatedService<DrillFlowChartDto>
|
public interface IDrillFlowChartRepository : IRepositoryWellRelated<DrillFlowChartDto>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить параметры бурения начиная с даты.
|
/// Получить параметры бурения начиная с даты.
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
using AsbCloudApp.Data;
|
|
||||||
|
|
||||||
namespace AsbCloudApp.Services
|
|
||||||
{
|
|
||||||
// TODO: Remove this
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public interface IOperationValueService : ICrudWellRelatedService<OperationValueDto>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,12 +5,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис получения, добавления, изменения, удаления данных<br/>
|
/// Репозиторий получения, добавления, изменения, удаления данных<br/>
|
||||||
/// Для сущностей относящихся к скважине
|
/// Для сущностей относящихся к скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="Tdto"></typeparam>
|
/// <typeparam name="Tdto"></typeparam>
|
||||||
public interface ICrudWellRelatedService<Tdto> : ICrudService<Tdto>
|
public interface IRepositoryWellRelated<Tdto> : ICrudService<Tdto>
|
||||||
where Tdto : IId, IWellRelated
|
where Tdto : IId, IWellRelated
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -19,7 +20,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idWell">id скважины</param>
|
/// <param name="idWell">id скважины</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns>emptyList if nothing found</returns>
|
/// <returns>emptyList if nothing found</returns>
|
||||||
Task<IEnumerable<Tdto>> GetByIdWellAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<Tdto>?> GetByIdWellAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение всех записей по нескольким скважинам
|
/// Получение всех записей по нескольким скважинам
|
||||||
@ -27,7 +28,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idsWells">id скважин</param>
|
/// <param name="idsWells">id скважин</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns>emptyList if nothing found</returns>
|
/// <returns>emptyList if nothing found</returns>
|
||||||
Task<IEnumerable<Tdto>> GetByIdWellAsync(IEnumerable<int> idsWells, CancellationToken token);
|
Task<IEnumerable<Tdto>?> GetByIdWellAsync(IEnumerable<int> idsWells, CancellationToken token);
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
|||||||
namespace AsbCloudApp.Services
|
namespace AsbCloudApp.Services
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис расписания смен бурильщика
|
/// Репозиторий расписания смен бурильщика
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IScheduleService : ICrudWellRelatedService<ScheduleDto>
|
public interface IScheduleRepository : IRepositoryWellRelated<ScheduleDto>
|
||||||
{
|
{
|
||||||
// TODO: this should be nullable.
|
// TODO: this should be nullable.
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -92,7 +92,7 @@ namespace AsbCloudInfrastructure
|
|||||||
|
|
||||||
services.AddTransient<IAuthService, AuthService>();
|
services.AddTransient<IAuthService, AuthService>();
|
||||||
services.AddTransient<IClusterService, ClusterService>();
|
services.AddTransient<IClusterService, ClusterService>();
|
||||||
services.AddTransient<IDrillFlowChartService, DrillFlowChartService>();
|
services.AddTransient<IDrillFlowChartRepository, DrillFlowChartRepository>();
|
||||||
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
|
services.AddTransient<IDrillingProgramService, DrillingProgramService>();
|
||||||
services.AddTransient<IDrillParamsService, DrillParamsService>();
|
services.AddTransient<IDrillParamsService, DrillParamsService>();
|
||||||
services.AddTransient<IEventService, EventService>();
|
services.AddTransient<IEventService, EventService>();
|
||||||
@ -115,8 +115,8 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<IDailyReportService, DailyReportService>();
|
services.AddTransient<IDailyReportService, DailyReportService>();
|
||||||
services.AddTransient<IDetectedOperationService, DetectedOperationService>();
|
services.AddTransient<IDetectedOperationService, DetectedOperationService>();
|
||||||
services.AddTransient<IDrillerService, DrillerService>();
|
services.AddTransient<IDrillerService, DrillerService>();
|
||||||
services.AddTransient<IScheduleService, ScheduleService>();
|
services.AddTransient<IScheduleRepository, ScheduleRepository>();
|
||||||
services.AddTransient<IOperationValueService, OperationValueService>();
|
services.AddTransient<IRepositoryWellRelated<OperationValueDto>, CrudWellRelatedServiceBase<OperationValueDto, OperationValue>>();
|
||||||
services.AddTransient<IUserSettingsRepository, UserSettingsRepository>();
|
services.AddTransient<IUserSettingsRepository, UserSettingsRepository>();
|
||||||
|
|
||||||
// admin crud services:
|
// admin crud services:
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
public class CrudWellRelatedCacheServiceBase<TDto, TEntity> : CrudCacheServiceBase<TDto, TEntity>, ICrudWellRelatedService<TDto>
|
public class CrudWellRelatedCacheServiceBase<TDto, TEntity> : CrudCacheServiceBase<TDto, TEntity>, IRepositoryWellRelated<TDto>
|
||||||
where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated
|
where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated
|
||||||
where TEntity : class, IId, IWellRelated
|
where TEntity : class, IId, IWellRelated
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
namespace AsbCloudInfrastructure.Repository
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
public class CrudWellRelatedServiceBase<TDto, TEntity> : CrudServiceBase<TDto, TEntity>, ICrudWellRelatedService<TDto>
|
public class CrudWellRelatedServiceBase<TDto, TEntity> : CrudServiceBase<TDto, TEntity>, IRepositoryWellRelated<TDto>
|
||||||
where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated
|
where TDto : AsbCloudApp.Data.IId, AsbCloudApp.Data.IWellRelated
|
||||||
where TEntity : class, IId, IWellRelated
|
where TEntity : class, IId, IWellRelated
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Repository;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
@ -10,18 +9,16 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
public class DrillFlowChartService : CrudWellRelatedServiceBase<DrillFlowChartDto, DrillFlowChart>,
|
public class DrillFlowChartRepository : CrudWellRelatedServiceBase<DrillFlowChartDto, DrillFlowChart>,
|
||||||
IDrillFlowChartService
|
IDrillFlowChartRepository
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
public DrillFlowChartService(IAsbCloudDbContext context, IWellService wellService)
|
public DrillFlowChartRepository(IAsbCloudDbContext context, IWellService wellService)
|
||||||
: base(context)
|
: base(context)
|
||||||
{
|
{
|
||||||
this.db = context;
|
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Repository;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
@ -9,14 +8,14 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
#nullable enable
|
#nullable enable
|
||||||
public class ScheduleService : CrudWellRelatedServiceBase<ScheduleDto, Schedule>, IScheduleService
|
public class ScheduleRepository : CrudWellRelatedServiceBase<ScheduleDto, Schedule>, IScheduleRepository
|
||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
|
|
||||||
public ScheduleService(IAsbCloudDbContext context, IWellService wellService)
|
public ScheduleRepository(IAsbCloudDbContext context, IWellService wellService)
|
||||||
: base(context, dbSet => dbSet.Include(s => s.Driller))
|
: base(context, dbSet => dbSet.Include(s => s.Driller))
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
@ -40,7 +39,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var time = new TimeOnly(remoteDate.Hour, remoteDate.Minute, remoteDate.Second);
|
var time = new TimeOnly(remoteDate.Hour, remoteDate.Minute, remoteDate.Second);
|
||||||
|
|
||||||
var entity = entities.FirstOrDefault(s =>
|
var entity = entities.FirstOrDefault(s =>
|
||||||
(s.ShiftStart > s.ShiftEnd) ^
|
s.ShiftStart > s.ShiftEnd ^
|
||||||
(time >= s.ShiftStart && time < s.ShiftEnd)
|
(time >= s.ShiftStart && time < s.ShiftEnd)
|
||||||
);
|
);
|
||||||
|
|
@ -9,7 +9,7 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Repository
|
||||||
{
|
{
|
||||||
public class WitsRecordRepository<TDto, TEntity> : IWitsRecordRepository<TDto>
|
public class WitsRecordRepository<TDto, TEntity> : IWitsRecordRepository<TDto>
|
||||||
where TEntity : class, ITelemetryData
|
where TEntity : class, ITelemetryData
|
@ -38,10 +38,10 @@ namespace AsbCloudInfrastructure.Services.DetectOperations
|
|||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IOperationValueService operationValueService;
|
private readonly IOperationValueService operationValueService;
|
||||||
private readonly IScheduleService scheduleService;
|
private readonly IScheduleRepository scheduleService;
|
||||||
|
|
||||||
public DetectedOperationService(IAsbCloudDbContext db, IWellService wellService,
|
public DetectedOperationService(IAsbCloudDbContext db, IWellService wellService,
|
||||||
IOperationValueService operationValueService, IScheduleService scheduleService)
|
IOperationValueService operationValueService, IScheduleRepository scheduleService)
|
||||||
{
|
{
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
using AsbCloudApp.Data;
|
|
||||||
using AsbCloudApp.Services;
|
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using AsbCloudInfrastructure.Repository;
|
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
|
||||||
{
|
|
||||||
public class OperationValueService : CrudWellRelatedServiceBase<OperationValueDto, OperationValue>, IOperationValueService
|
|
||||||
{
|
|
||||||
public OperationValueService(IAsbCloudDbContext context) : base(context)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -125,7 +125,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
|
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
|
||||||
wellServiceMock.Setup(s => s.GetOrDefaultAsync(It.IsAny<int>(),CancellationToken.None)).Returns(Task.Run(() => wellDto));
|
wellServiceMock.Setup(s => s.GetOrDefaultAsync(It.IsAny<int>(),CancellationToken.None)).Returns(Task.Run(() => wellDto));
|
||||||
var operationValueService = new OperationValueService(context);
|
var operationValueService = new OperationValueService(context);
|
||||||
var scheduleService = new ScheduleService(context, wellServiceMock.Object);
|
var scheduleService = new ScheduleRepository(context, wellServiceMock.Object);
|
||||||
|
|
||||||
service = new DetectedOperationService(context, wellServiceMock.Object, operationValueService, scheduleService);
|
service = new DetectedOperationService(context, wellServiceMock.Object, operationValueService, scheduleService);
|
||||||
request = new DetectedOperationRequest
|
request = new DetectedOperationRequest
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Services;
|
using AsbCloudInfrastructure.Repository;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -14,7 +14,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
public class ScheduleServiceTest
|
public class ScheduleServiceTest
|
||||||
{
|
{
|
||||||
private readonly AsbCloudDbContext context;
|
private readonly AsbCloudDbContext context;
|
||||||
private readonly ScheduleService scheduleService;
|
private readonly ScheduleRepository scheduleService;
|
||||||
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
|
private Deposit deposit = new Deposit { Id = 1, Caption = "Депозит 1" };
|
||||||
private Cluster clater = new Cluster { Id = 1, Caption = "Кластер 1", IdDeposit = 1, Timezone = new SimpleTimezone() };
|
private Cluster clater = new Cluster { Id = 1, Caption = "Кластер 1", IdDeposit = 1, Timezone = new SimpleTimezone() };
|
||||||
private Schedule scd = new Schedule
|
private Schedule scd = new Schedule
|
||||||
@ -71,7 +71,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
var timezone = new SimpleTimezoneDto { Hours = 5 };
|
var timezone = new SimpleTimezoneDto { Hours = 5 };
|
||||||
var wellServiceMock = new Mock<IWellService>();
|
var wellServiceMock = new Mock<IWellService>();
|
||||||
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
|
wellServiceMock.Setup(s => s.GetTimezone(It.IsAny<int>())).Returns(timezone);
|
||||||
scheduleService = new ScheduleService(context, wellServiceMock.Object);
|
scheduleService = new ScheduleRepository(context, wellServiceMock.Object);
|
||||||
AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
|
AsbCloudInfrastructure.DependencyInjection.MapsterSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public abstract class CrudWellRelatedController<T, TService> : CrudController<T, TService>
|
public abstract class CrudWellRelatedController<T, TService> : CrudController<T, TService>
|
||||||
where T : IId, IWellRelated
|
where T : IId, IWellRelated
|
||||||
where TService : ICrudWellRelatedService<T>
|
where TService : IRepositoryWellRelated<T>
|
||||||
{
|
{
|
||||||
protected readonly IWellService wellService;
|
protected readonly IWellService wellService;
|
||||||
|
|
||||||
|
@ -15,11 +15,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class DrillFlowChartController : CrudWellRelatedController<DrillFlowChartDto, IDrillFlowChartService>
|
public class DrillFlowChartController : CrudWellRelatedController<DrillFlowChartDto, IDrillFlowChartRepository>
|
||||||
{
|
{
|
||||||
private readonly ITelemetryService telemetryService;
|
private readonly ITelemetryService telemetryService;
|
||||||
|
|
||||||
public DrillFlowChartController(IWellService wellService, IDrillFlowChartService service,
|
public DrillFlowChartController(IWellService wellService, IDrillFlowChartRepository service,
|
||||||
ITelemetryService telemetryService)
|
ITelemetryService telemetryService)
|
||||||
: base(wellService, service)
|
: base(wellService, service)
|
||||||
{
|
{
|
||||||
|
@ -11,9 +11,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Route("api/operationValue")]
|
[Route("api/operationValue")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class OperationValueController : CrudWellRelatedController<OperationValueDto, IOperationValueService>
|
public class OperationValueController : CrudWellRelatedController<OperationValueDto, IRepositoryWellRelated<OperationValueDto>>
|
||||||
{
|
{
|
||||||
public OperationValueController(IOperationValueService service, IWellService wellService) : base(wellService, service)
|
public OperationValueController(IRepositoryWellRelated<OperationValueDto> service, IWellService wellService) : base(wellService, service)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Route("api/schedule")]
|
[Route("api/schedule")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class ScheduleController : CrudWellRelatedController<ScheduleDto, IScheduleService>
|
public class ScheduleController : CrudWellRelatedController<ScheduleDto, IScheduleRepository>
|
||||||
{
|
{
|
||||||
private readonly IScheduleService scheduleService;
|
private readonly IScheduleRepository scheduleService;
|
||||||
|
|
||||||
public ScheduleController(IScheduleService scheduleService, IWellService wellService)
|
public ScheduleController(IScheduleRepository scheduleService, IWellService wellService)
|
||||||
: base(wellService, scheduleService)
|
: base(wellService, scheduleService)
|
||||||
{
|
{
|
||||||
this.scheduleService = service;
|
this.scheduleService = service;
|
||||||
|
Loading…
Reference in New Issue
Block a user