using Infrastructure;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.App.ServiceApp.DroneCaseInfo;
using OpenAuth.App.ServiceApp.DroneCaseInfoDev;
using OpenAuth.App.ServiceApp.DroneCaseInfoDev.Request;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    class DroneCaseInfoDevController : ControllerBase
    {
        readonly DroneCaseInfoDevApp _app;

        public DroneCaseInfoDevController(DroneCaseInfoDevApp app)
        {
            _app = app;
        }

        /// <summary>
        /// Dev  分页获取案件信息列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<Response<PageInfo<List<DroneCaseInfoSingle>>>> LoadCaseInfoPageList([FromQuery] CaseInfoDev request)
        {
            return await _app.LoadCaseInfoPageList(request);
        }

        /// <summary>
        /// 添加模板信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<bool> AddSchemeDev(WFScheme req)
        {
            var result = new Response<bool>();
            try
            {
                result = _app.AddSchemeDev(req);
            }
            catch (Exception ex)
            {
                result.Code = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }
            return result;
        }
        [HttpGet]
        [AllowAnonymous]
        public async Task<List<SysOrg>> LoadChildren(long? parentId)
        {
            return await _app.LoadChildren(parentId);
        }

        /// <summary>
        /// 查询案件相关信息
        /// </summary>
        /// <param name="caseId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<CaseInfoAbout> LoadCaseInfoAbout(string caseId)
        {
            return await _app.LoadCaseInfoAbout(caseId);
        }
    }
}
