using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.Response;
using OpenAuth.App.ServiceApp.FireManagement;

namespace OpenAuth.WebApi.Controllers.ServiceControllers.FireManagement;

[Route("api/[controller]/[action]")]
[ApiController]
public class CameraController : ControllerBase
{
    private readonly FireManagementApp _app;

    public CameraController(FireManagementApp app)
    {
        _app = app;
    }

    /// <summary>
    /// 查询指定范围内的摄像机
    /// </summary>
    /// <param name="lng"></param>
    /// <param name="lat"></param>
    /// <param name="radius"></param>
    /// <returns></returns>
    [HttpGet]
    public async Task<Response<dynamic>> ListCameraWithInRange(string lng, string lat, int radius = 10000)
    {
        return await _app.ListCameraWithInRange(lng, lat, radius);
    }

    [HttpGet]
    public async Task<Response<dynamic>> ListDaHuaCameraInfo(int pageNum = 1, int pageSize = 10, int isOnline = 1)
    {
        return await _app.ListDaHuaCameraInfo(pageNum, pageSize, isOnline);
    }

    [HttpGet]
    public async Task<Response<dynamic>> GetDaHuaRtsp(string channelCode, string streamType = "1")
    {
        return await _app.GetDaHuaRtsp(channelCode, streamType);
    }
    
    /// <summary>
    /// 获取设备信息
    /// </summary>
    /// <param name="county">县区</param>
    /// <param name="pageIndex"></param>
    /// <param name="pageSize"></param>
    /// <returns></returns>
    [HttpGet]
    [AllowAnonymous]
    public TableData LoadCameraInfo(string county, int pageIndex, int pageSize)
    {
        return _app.LoadCameraInfo(county, pageIndex, pageSize);
    }

}