using Hopetry;

using Hopetry.WebApi;
using Hopetry.WebApi.Controllers;


using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using OpenAuth.App;
using System;
using System.Collections.Generic;

namespace Hopetry.WebApi.Controllers
{
    /// <summary>
    /// 根据网格获取资源
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]

    public class FireGrideResourceController : ControllerBase
    {
        IConfiguration _configuration;
        private FireGrideResourceApp _firegridapp;
        public FireGrideResourceController(IConfiguration configuration, FireGrideResourceApp firegridapp)
        {
            _configuration = configuration;
            _firegridapp = firegridapp;
        }

        /// <summary>
        /// 根据起火点坐标，查询起火点所在的网格
        /// </summary>
        /// <param name="lng">坐标</param>
        /// <param name="lat">坐标</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<dynamic> GetGridInfoByLngLat(string lng, string lat)
        {
            Response<dynamic> response = new Response<dynamic>();
            try
            {
                response.Result = _firegridapp.GetGridInfoByLngLat(lng, lat);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }

        /// <summary>
        /// 根据网格id获取水源地信息
        /// </summary>
        /// <param name="id">网格id</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetWaterResource()
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetWaterResource();
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }
        /// <summary>
        /// 根据网格id获取水源地信息
        /// </summary>
        /// <param name="id">网格id</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetWuziResource()
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetWuziResource();
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }
        /// <summary>
        /// 根据网格id获取防火营房信息
        /// </summary>
        /// <param name="id">网格id</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetWg_Barrack(long id)
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetWg_Barrack(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }

        /// <summary>
        /// 根据网格id获取水防火物资数据
        /// </summary>
        /// <param name="id">网格id</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetMaterials(long id)
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetMaterials(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }

        /// <summary>
        /// 根据网格id获取道路信息
        /// </summary>
        /// <param name="id">网格id</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetWgRoad(long id)
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetWgRoad(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }
        /// <summary>
        /// 获取所有道路信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetAllWgRoad()
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetAllWgRoad();
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }

        /// <summary>
        /// 根据网格id获取水网信息
        /// </summary>
        /// <param name="id">网格id</param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetWgWaterNetwork(long id)
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetWgWaterNetwork(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }


        /// <summary>
        /// 查询全部道路信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetAllRode()
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetAllRode();
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }

        /// <summary>
        /// 查询全部营房信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public Response<List<dynamic>> GetAllYingFang()
        {
            Response<List<dynamic>> response = new Response<List<dynamic>>();
            try
            {
                response.Result = _firegridapp.GetAllYingFang();
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }
    }
}
