using System;
using System.Collections.Generic;
using System.Web.Http;
using FactorySystemApi.Sap_Group;
using FactorySystemBll;
using FactorySystemCommon;
using FactorySystemModel.BusinessModel;
using FactorySystemModel.EnumModel;
using FactorySystemModel.RequestModel;
using FactorySystemModel.ResponseModel;
using FactorySystemModel.SqlSugarModel;

namespace FactorySystemApi.Controllers
{
    /// <summary>
    /// 任务
    /// </summary>
    [UserLoginFilter]
    public class HalfMaterialTaskController : ApiController
    {
        private readonly HalfMaterialTaskBll _taskBll = new HalfMaterialTaskBll();

        /// <summary>
        /// 根据当前用户获取任务列表
        /// </summary>
        [HttpPost]
        public ApiResult GetPageList(TaskQuery tq)
        {
            ApiResult apiResult = new ApiResult();
            return ExceptionHelper.TryReturnException(() =>
            {
                if (tq.FIsUser && Request.Properties["token"] is ApiAuthInfo user)
                {
                    tq.FUserID = user.FID.ToString();
                }
                apiResult.Data = new
                {
                    List = _taskBll.GetList(tq, out var totalNumber),
                    Total = totalNumber
                };
            }, apiResult, Request);
        }

    }
}
