using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.ServiceApp.AchievementManage;
using OpenAuth.App.ServiceApp.Request;
using OpenAuth.App.ServiceApp.Response;

namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
    /// <summary>
    /// 成果管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AchievementManageController : ControllerBase
    {
        private AchievementManageApp _app;

        public AchievementManageController(AchievementManageApp app)
        {
            _app = app;
        }

        /// <summary>
        /// 添加成果
        /// </summary>
        /// <param name="exifs"></param>
        /// <returns></returns>
        [HttpPost]
        [Obsolete]
        public Response<bool> AddImageexif(List<Imageexif> exifs)
        {
            var response = new Response<bool>();
            try
            {
                response = _app.AddImageexif(exifs);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        /// <summary>
        /// 案件判读
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> IntactById(long id)
        {
            var response = new Response<bool>();
            try
            {
                response = await _app.IntactById(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> AddTask()
        {
            return   await _app.AddTask();
            /*var response = new Response<bool>();
            try
            {
                response = await _app.AddTask();
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;*/
        }

        /// <summary>
        /// 任务查询
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="taskName">任务名称</param>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <param name="createUser">创建人</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<TaskResp>>>> ListTask(int pageIndex, int pageSize, string taskName,
            string beginDate, string endDate, string createUser)
        {
            return await _app.ListTask(pageIndex, pageSize, taskName, beginDate, endDate, createUser);
        }

        /// <summary>
        /// 查询成果
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="taskId"></param>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<DroneShpImageResp>>>> ListDroneShpImageexif(long taskId,
            string beginDate, string endDate, int pageIndex = 1, int pageSize = 10)
        {
            return await _app.ListDroneShpImageexif(pageIndex, pageSize, taskId, beginDate, endDate);
        }
    }
}