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