using Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Controllers
{
    /// <summary>
    /// 流程模版详细信息（包含 context、历史信息）
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WFSchemeController : ControllerBase
    {
        WFSchemeApp schemeApp;
        WFSchemeInfoApp schemeInfoApp;
        public WFSchemeController(WFSchemeApp wFSchemeApp, WFSchemeInfoApp schemeInfoApp)
        {
            schemeApp = wFSchemeApp;
            this.schemeInfoApp = schemeInfoApp;
        }

        #region 分页
        /// <summary>
        /// 模版历史记录分页数据
        /// </summary>
        /// <param name="FromQuery">分页参数</param>
        /// <param name="id">流程模板信息主键</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<WFScheme>>>> LoadPage(string id, [FromQuery] PageReq pageReq)
        {
            var pageInfo = await schemeApp.GetSchemePageList(pageReq, id);
            return new Response<PageInfo<List<WFScheme>>>
            {
                Result = pageInfo,
                Message = "success"
            };
        }
        #endregion

        #region SchemeList
        /// <summary>
        /// 获取x模板历史数据
        /// </summary>
        /// <param name="id">流程模板信息主键</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<WFScheme>>> Load(string id)
        {
            var data = await schemeApp.GetSchemeList(id);
            return new Response<List<WFScheme>>
            {
                Result = data,
                Message = "success"
            };
        }
        #endregion

    }
}
