You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.3 KiB
54 lines
2.3 KiB
using Application.Domain.Entities;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Extensions;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace IoT.Shared.Controllers.Onvif
|
|
{
|
|
[SwaggerTag("Swagger")]
|
|
public class SwaggerController : Controller
|
|
{
|
|
private readonly IRepository<Product> _productRepo;
|
|
private readonly IRepository<Device> _deviceRepo;
|
|
private readonly IRepository<Node> _nodeRepo;
|
|
|
|
public SwaggerController(IRepository<Product> productRepo, IRepository<Device> deviceRepo, IRepository<Node> nodeRepo)
|
|
{
|
|
this._productRepo = productRepo;
|
|
this._deviceRepo = deviceRepo;
|
|
this._nodeRepo = nodeRepo;
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("设备型号列表")]
|
|
public List<Product> GetDeviceInfos([SwaggerParameter("当前页序号")]int pageIndex = 1, [SwaggerParameter("单页数量")]int pageSize = 10)
|
|
{
|
|
return this._productRepo.ReadOnlyTable().Paged(pageIndex, pageSize);
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("节点列表")]
|
|
public List<Node> GetNodes([SwaggerParameter("当前页序号")]int pageIndex = 1, [SwaggerParameter("单页数量")]int pageSize = 10)
|
|
{
|
|
return this._nodeRepo.ReadOnlyTable().Paged(pageIndex, pageSize);
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("设备列表")]
|
|
public List<Device> GetDevices([SwaggerParameter("当前页序号")]int pageIndex = 1, [SwaggerParameter("单页数量")]int pageSize = 10)
|
|
{
|
|
return this._deviceRepo.ReadOnlyTable().Paged(pageIndex, pageSize);
|
|
}
|
|
|
|
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("设备")]
|
|
public Device GetDevice([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number)
|
|
{
|
|
return this._deviceRepo.ReadOnlyTable()
|
|
.Include(o => o.Data)
|
|
.WhereIf(!string.IsNullOrEmpty(gateway), o => o.Gateway == gateway)
|
|
.Where(o => o.Number == number)
|
|
.FirstOrDefault();
|
|
}
|
|
}
|
|
} |