using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.ServiceApp.TaxManage;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Controllers
{
    /// <summary>
    /// 地图
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TaxManagementController : ControllerBase
    {
        TaxManagementApp _taxApp;
        SysDataItemApp dataItemApp;
        public TaxManagementController(
            TaxManagementApp taxApp, SysDataItemApp dataItemApp)
        {
            _taxApp = taxApp;
            this.dataItemApp = dataItemApp;
        }

        #region 税源地图页面所需接口
        /// <summary>
        /// 查询图层
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<TaxTuceng>>> GetTucengInfo()
        {
            var result = new Response<List<TaxTuceng>>();
            try
            {
                var data = await _taxApp.GetTucengInfo();
                result.Result = data;
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return result;
        }

        /// <summary>
        /// 房屋图层查询
        /// </summary>
        /// <param name="name">宗地编码或者企业名称</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<dynamic>>> GetTaxBuildingInfo(string name)
        {
            var result = new Response<List<dynamic>>();
            try
            {
                var data = await _taxApp.GetTaxBuildingInfo(name);
                result.Result = data;
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return result;
        }

        /// <summary>
        /// 宗地图层查询
        /// </summary>
        /// <param name="name">宗地编码或者企业名称</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<dynamic>>> GetTaxZongdiInfo(string name)
        {
            var result = new Response<List<dynamic>>();
            try
            {
                var data = await _taxApp.GetTaxZongdiInfo(name);
                result.Result = data;
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return result;
        }
        #endregion
    }
}
