using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.ServiceApp;
using OpenAuth.App.ServiceApp.Response;
using OpenAuth.WebApi.Model.CustomAttribute;

namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
    /// <summary>
    /// 统计分析
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DataAnalysisController : ControllerBase
    {
        readonly DataAnalysisApp _app;
        public DataAnalysisController(DataAnalysisApp app)
        {
            _app = app;
        }
        /// <summary>
        /// 小组或人员统计
        /// </summary>
        /// <param name="type">2-小组，1-人员</param>
        /// <param name="dateType">1-本月，2-本周，3-本日</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<UserOrGroupTaskResp>>> GetGroupOrUserTaskAndTuBan(int type, int dateType)
        {
            Response<List<UserOrGroupTaskResp>> response = new Response<List<UserOrGroupTaskResp>>();
            try
            {
                return await _app.GetGroupOrUserTaskAndTuBan(type, dateType);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }
        /// <summary>
        /// 解译分析数据交付与费用记账表
        /// </summary>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<AiShpDataExpenseAccountingTableResp>> GetAiShpDataExpenseAccountingTable(DateTime beginTime, DateTime endTime)
        {
            Response<AiShpDataExpenseAccountingTableResp> response = new Response<AiShpDataExpenseAccountingTableResp>();
            try
            {
                return await _app.GetAiShpDataExpenseAccountingTable(beginTime, endTime);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return response;
        }
    }
}
