forked from ddrilling/AsbCloudServer
Merge branch 'master' of https://bitbucket.org/frolovng/asbcloudserver
This commit is contained in:
commit
5c783b332b
@ -11,6 +11,7 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
IEnumerable<DepositDto> GetDeposits(int idCustomer);
|
||||
IEnumerable<ClusterDto> GetClusters(int idCustomer, int depositId);
|
||||
IEnumerable<ClusterDto> GetClusters(int idCustomer);
|
||||
IEnumerable<WellDto> GetWells(int idCustomer, int clusterId);
|
||||
IEnumerable<ClusterAnalysisDto> GetAnalysis(int idCustomer, int clusterId);
|
||||
}
|
||||
|
@ -176,22 +176,33 @@ namespace AsbCloudDb.Model
|
||||
modelBuilder.Entity<Deposit>(entity =>
|
||||
{
|
||||
entity.HasData(new List<Deposit> {
|
||||
new Deposit{Id = 1, Caption = "м/р 1" },
|
||||
new Deposit{Id = 1, Caption = "м/р 1", Latitude = 60.8705722222222, Longitude = 70.3811888888889 },
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Cluster>(entity =>
|
||||
{
|
||||
entity.HasData(new List<Cluster> {
|
||||
new Cluster{Id = 1, Caption = "куст 1", IdDeposit = 1 },
|
||||
new Cluster{Id = 1, Caption = "к221", IdDeposit = 1, Latitude = 60.8705722222222, Longitude = 70.3811888888889},
|
||||
new Cluster{Id = 2, Caption = "к151", IdDeposit = 1, Latitude = 60.8205750000000, Longitude = 70.1343833333334},
|
||||
new Cluster{Id = 3, Caption = "к611", IdDeposit = 1, Latitude = 60.8100666666667, Longitude = 69.7778388888889},
|
||||
new Cluster{Id = 4, Caption = "к203", IdDeposit = 1, Latitude = 60.8928805555556, Longitude = 70.3272055555556},
|
||||
new Cluster{Id = 5, Caption = "к39.1", IdDeposit = 1, Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Well>(entity =>
|
||||
{
|
||||
entity.HasData(new List<Well> {
|
||||
new Well{Id = 1, IdCluster = 1, IdCustomer = 1, Caption = "скв 1" },
|
||||
new Well{Id = 2, IdCluster = 1, IdCustomer = 1, Caption = "скв 2" },
|
||||
new Well{Id = 1, IdCluster = 1, IdCustomer = 1, Caption = "скв 42669", Latitude = 60.8705722222222, Longitude = 70.3811888888889},
|
||||
new Well{Id = 2, IdCluster = 1, IdCustomer = 1, Caption = "скв 16311", Latitude = 60.8705722222222, Longitude = 70.3811888888889},
|
||||
new Well{Id = 3, IdCluster = 2, IdCustomer = 1, Caption = "скв 16315", Latitude = 60.8205750000000, Longitude = 70.1343833333334},
|
||||
new Well{Id = 4, IdCluster = 2, IdCustomer = 1, Caption = "скв 16318", Latitude = 60.8205750000000, Longitude = 70.1343833333334},
|
||||
new Well{Id = 5, IdCluster = 3, IdCustomer = 1, Caption = "скв 16310", Latitude = 60.8100666666667, Longitude = 69.7778388888889},
|
||||
new Well{Id = 6, IdCluster = 4, IdCustomer = 1, Caption = "скв 16316", Latitude = 60.8928805555556, Longitude = 70.3272055555556},
|
||||
new Well{Id = 7, IdCluster = 5, IdCustomer = 1, Caption = "скв 16312", Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
||||
new Well{Id = 8, IdCluster = 5, IdCustomer = 1, Caption = "скв 16313", Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
||||
new Well{Id = 9, IdCluster = 5, IdCustomer = 1, Caption = "скв 16314", Latitude = 60.6672055555556, Longitude = 69.6603861111111},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -38,6 +38,24 @@ namespace AsbCloudInfrastructure.Services
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public IEnumerable<ClusterDto> GetClusters(int idCustomer)
|
||||
{
|
||||
var entities = db.GetWellsByCustomer(idCustomer)
|
||||
.Select(e => e.Cluster)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
var dtos = entities.Select(e => new ClusterDto
|
||||
{
|
||||
Id = e.Id,
|
||||
Name = e.Caption,
|
||||
Latitude = e.Latitude,
|
||||
Longitude = e.Longitude,
|
||||
});
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public IEnumerable<ClusterDto> GetClusters(int idCustomer, int depositId)
|
||||
{
|
||||
var entities = db.GetWellsByCustomer(idCustomer)
|
||||
|
@ -13,7 +13,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <summary>
|
||||
/// Контроллер кустов
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[Route("api/cluster")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class ClusterController : ControllerBase
|
||||
@ -25,6 +25,23 @@ namespace AsbCloudWebApi.Controllers
|
||||
this.clusterService = clusterService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получает список доступных пользователю кустов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet()]
|
||||
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||
public IActionResult GetClusters()
|
||||
{
|
||||
int? idCustomer = User.GetCustomerId();
|
||||
|
||||
if (idCustomer is null)
|
||||
return Forbid();
|
||||
|
||||
var result = clusterService.GetClusters((int)idCustomer);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение доступных пользователю скважин
|
||||
/// </summary>
|
||||
|
@ -13,7 +13,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <summary>
|
||||
/// Контроллер для месторождений
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[Route("api/deposit")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class DepositController : ControllerBase
|
||||
|
Loading…
Reference in New Issue
Block a user