|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Infrastructure.Extensions;
|
|
|
|
|
using IoT.Shared.Application.Domain.Entities;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
@ -14,13 +14,10 @@ namespace Platform.Areas.IoTCenter.Controllers
|
|
|
|
|
[Area("IoTCenter")]
|
|
|
|
|
public class AjaxController : IoT.Shared.Areas.IoTCenter.Controlls.AjaxBaseController
|
|
|
|
|
{
|
|
|
|
|
private readonly IRepository<Area> _areaRepo;
|
|
|
|
|
private readonly IRepository<Building> _buildingRepo;
|
|
|
|
|
private readonly IRepository<Role> _roleRepo;
|
|
|
|
|
|
|
|
|
|
public AjaxController(IServiceProvider services,
|
|
|
|
|
ILogger<AjaxController> logger,
|
|
|
|
|
IHttpContextAccessor httpContxt,
|
|
|
|
|
IRepository<IoTProductCategory> categoryRepo,
|
|
|
|
|
IRepository<IoTProduct> productRepo,
|
|
|
|
|
IRepository<Organ> organRepo,
|
|
|
|
@ -32,13 +29,9 @@ namespace Platform.Areas.IoTCenter.Controllers
|
|
|
|
|
IRepository<IoTDevice> deviceRepo,
|
|
|
|
|
IRepository<IoTData> dataRepo,
|
|
|
|
|
IRepository<IoTApi> apiRepo,
|
|
|
|
|
IRepository<IoTSceneTigger> sceneTiggerRepo,
|
|
|
|
|
IRepository<Area> areaRepo,
|
|
|
|
|
IRepository<Building> buildingRepo,
|
|
|
|
|
IRepository<Role> roleRepo)
|
|
|
|
|
IRepository<IoTSceneTigger> sceneTiggerRepo)
|
|
|
|
|
: base(services,
|
|
|
|
|
logger,
|
|
|
|
|
httpContxt,
|
|
|
|
|
categoryRepo,
|
|
|
|
|
productRepo,
|
|
|
|
|
organRepo,
|
|
|
|
@ -52,14 +45,13 @@ namespace Platform.Areas.IoTCenter.Controllers
|
|
|
|
|
apiRepo,
|
|
|
|
|
sceneTiggerRepo)
|
|
|
|
|
{
|
|
|
|
|
this._areaRepo = areaRepo;
|
|
|
|
|
this._buildingRepo = buildingRepo;
|
|
|
|
|
this._roleRepo = roleRepo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult GetArea(Guid? selected = null, Guid? currentId = null, string search = null)
|
|
|
|
|
{
|
|
|
|
|
var list = this._areaRepo.ReadOnlyTable()
|
|
|
|
|
using var scope = this._services.CreateScope();
|
|
|
|
|
var repo = scope.ServiceProvider.GetRequiredService<IRepository<Area>>();
|
|
|
|
|
var list = repo.ReadOnlyTable()
|
|
|
|
|
.Where(o => o.ParentId != null)
|
|
|
|
|
.WhereIf(selected.HasValue, o => o.Id == selected.Value)
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(search), o => o.Name.Contains(search) || o.Number.Contains(search))
|
|
|
|
@ -74,7 +66,9 @@ namespace Platform.Areas.IoTCenter.Controllers
|
|
|
|
|
|
|
|
|
|
public JsonResult GetOrganBuilding(Guid parentId, Guid? selected = null, Guid? currentId = null)
|
|
|
|
|
{
|
|
|
|
|
var list = this._buildingRepo.ReadOnlyTable()
|
|
|
|
|
using var scope = this._services.CreateScope();
|
|
|
|
|
var repo = scope.ServiceProvider.GetRequiredService<IRepository<Building>>();
|
|
|
|
|
var list = repo.ReadOnlyTable()
|
|
|
|
|
.Where(o => o.ParentId != null)
|
|
|
|
|
.Where(o => o.OrganId == parentId)
|
|
|
|
|
.WhereIf(currentId.HasValue, o => o.Id != currentId.Value)
|
|
|
|
|