using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
using Furion.DynamicApiController;
using System.ComponentModel.DataAnnotations;
using Mapster;
using Microsoft.AspNetCore.Authorization;
namespace IStation.Application
{
///
/// Camera
///
[AllowAnonymous]
[Route("Camera/Video")]
[ApiDescriptionSettings("Product", Name = "视频监控", Order = 781)]
public class Camera_Controller : IDynamicApiController
{
///
/// 通过 StationID 获取海康列表
///
[Route("GetHikListByStationID@V1.0")]
[HttpGet]
public List GetHikListByStationID(long CorpID, long StationID)
{
var corpId = CorpID;
var stationId = StationID;
var cacheKey = $"Camera_GetHikListByStationID_{corpId}_{stationId}";
var vm_list = MemoryCacheHelper.GetSet(cacheKey, () =>
{
var cameralList = new Service.Product().GetCameraListByBelongTypeAndBelongID(corpId, ObjectType.Station, stationId);
cameralList = cameralList?.Where(x => x.RatedParas.ProviderType == Model.Camera.eProviderType.Hik).ToList();
if (cameralList == null || cameralList.Count < 1)
return default;
var manufacturerList = new Service.Manufacturer().GetByCorpID(corpId);
var vmCacheList = new List();
foreach (var camera in cameralList)
{
var manufacturer = manufacturerList.Find(x => x.ID == camera.ManufacturerID);
var vm = new CameraHikLogicDto(camera, manufacturer?.Name);
vmCacheList.Add(vm);
}
return vmCacheList;
}, CacheHelper.CacheLevel3);
return vm_list;
}
}
}