forked from ddrilling/AsbCloudServer
wellService.CheckWellOwnership rename to wellService.IsCompanyOwnsWell
This commit is contained in:
parent
1325663d7e
commit
05cf7244ef
@ -7,6 +7,7 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
IEnumerable<WellDto> GetWellsByCompany(int idCompany);
|
||||
IEnumerable<WellDto> GetTransmittingWells(int idCompany);
|
||||
bool CheckWellOwnership(int idCompany, int wellId);
|
||||
bool IsCompanyOwnsWell(int idCompany, int wellId);
|
||||
IEnumerable<WellSectionDto> GetStat(int wellId, int idCompany);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace AsbCloudInfrastructure.Services
|
||||
return wells.Select(w => From(w));
|
||||
}
|
||||
|
||||
public bool CheckWellOwnership(int idCompany, int idWell)
|
||||
public bool IsCompanyOwnsWell(int idCompany, int idWell)
|
||||
=> cacheRelationCompaniesWells.Contains(r => r.IdWell == idWell && r.IdCompany == idCompany);
|
||||
|
||||
private static WellDto From(Well well)
|
||||
@ -56,5 +56,9 @@ namespace AsbCloudInfrastructure.Services
|
||||
return wellDto;
|
||||
}
|
||||
|
||||
public IEnumerable<WellSectionDto> GetStat(int wellId, int idCompany)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
||||
analyticsService.Setup(s => s.GetWellDepthToDay(It.IsAny<int>()))
|
||||
.Returns(depthToDayDtos);
|
||||
|
||||
wellService.Setup(s => s.CheckWellOwnership(It.IsAny<int>(), It.IsAny<int>()))
|
||||
wellService.Setup(s => s.IsCompanyOwnsWell(It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
controller = new AnalyticsController(analyticsService.Object,
|
||||
@ -94,7 +94,7 @@ namespace AsbCloudWebApi.Tests.ControllersTests
|
||||
{
|
||||
var wellServiceReturnsFalse = new Mock<IWellService>();
|
||||
|
||||
wellServiceReturnsFalse.Setup(s => s.CheckWellOwnership(It.IsAny<int>(), It.IsAny<int>()))
|
||||
wellServiceReturnsFalse.Setup(s => s.IsCompanyOwnsWell(It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
var newControllerInstance = new AnalyticsController(analyticsService.Object,
|
||||
|
@ -40,7 +40,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var analytics = analyticsService.GetOperationsByWell(wellId, categoryIds, begin, end, skip, take);
|
||||
@ -63,7 +63,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var wellDepthToDayData = analyticsService.GetWellDepthToDay(wellId);
|
||||
@ -89,7 +89,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var wellDepthToIntervalData = analyticsService.GetWellDepthToInterval(wellId,
|
||||
@ -115,7 +115,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var analytics = analyticsService.GetOperationsSummary(wellId, begin, end);
|
||||
@ -141,7 +141,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var analytics = analyticsService.GetOperationsToInterval(wellId, intervalSeconds, workBeginSeconds);
|
||||
|
@ -59,7 +59,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
bool isCompanyOwnsWell = wellService.CheckWellOwnership((int)idCompany, wellId);
|
||||
bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, wellId);
|
||||
|
||||
if (!isCompanyOwnsWell)
|
||||
return Forbid();
|
||||
|
@ -42,7 +42,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var fileInfoCollection = files.Select(f =>
|
||||
@ -87,7 +87,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
int? idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (idCompany is null || !wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var filesInfo = fileService.GetFilesInfo(wellId, idCategory,
|
||||
@ -117,7 +117,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var fileInfo = fileService.GetFileInfo(fileId);
|
||||
|
@ -58,7 +58,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
bool isCompanyOwnsWell = wellService.CheckWellOwnership((int)idCompany, wellId);
|
||||
bool isCompanyOwnsWell = wellService.IsCompanyOwnsWell((int)idCompany, wellId);
|
||||
|
||||
if (!isCompanyOwnsWell)
|
||||
return Forbid();
|
||||
|
@ -68,7 +68,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var id = reportService.CreateReport(wellId, stepSeconds, format, begin, end, HandleReportProgressAsync, HandleReportNameAsync);
|
||||
@ -94,7 +94,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
// TODO: словарь content typoв
|
||||
var relativePath = Path.Combine(reportService.RootPath, $"{wellId}", reportName);
|
||||
@ -149,7 +149,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
int reportSize = reportService.GetReportPagesCount(wellId, begin, end, stepSeconds, format);
|
||||
@ -172,7 +172,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null)
|
||||
return Forbid();
|
||||
|
||||
if (!wellService.CheckWellOwnership((int)idCompany, wellId))
|
||||
if (!wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
DatesRangeDto wellReportsDatesRange = reportService.GetReportsDatesRange(wellId);
|
||||
|
@ -38,6 +38,24 @@ namespace AsbCloudWebApi.Controllers
|
||||
return Ok(wells);
|
||||
}
|
||||
|
||||
[HttpGet("{wellId}/sections")]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellSectionDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public IActionResult GetSections(int wellId)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null)
|
||||
return NoContent();
|
||||
|
||||
if (wellService.IsCompanyOwnsWell((int)idCompany, wellId))
|
||||
return Forbid();
|
||||
|
||||
var dto = wellService.GetStat(wellId, (int)idCompany);
|
||||
|
||||
return Ok(dto);
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("transmittingWells")]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public IActionResult GetTransmittingWells()
|
||||
|
Loading…
Reference in New Issue
Block a user