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