using FactorySystemBll;
using FactorySystemCommon;
using FactorySystemModel.ResponseModel;
using FactorySystemModel.SqlSugarModel;
using System.Collections.Generic;
using System.Web.Http;

namespace FactorySystemApi.Controllers
{
    /// <summary>
    /// 工厂接口
    /// </summary>
    [UserLoginFilter]
    public class FactoryController : BaseController<TFS_Factory>
    {
        private readonly FactoryBll FactoryBll = new FactoryBll();
        /// <summary>
        /// 初始化
        /// </summary>
        public FactoryController()
        {
            //设置可新增、修改字段
            InsertField = UpdateField = "FName,FCode,FType,FFactoryID,FChargePerson,FPhone,FState,FEditUser,FEditDate";
        }

        /// <summary>
        /// 获取工厂集合
        /// </summary>
        [HttpPost]
        public ApiResult GetFactoryList()
        {
            ApiResult apiResult = new ApiResult();
            return ExceptionHelper.TryReturnException(() =>
            {
                apiResult.Data = FactoryBll.GetFactoryList();
            }, apiResult, Request);
        }

        /// <summary>
        /// 验证工厂代码是否重复
        /// </summary>
        [HttpPost]
        public ApiResult CheckHasCode(Dictionary<string, object> insertData)
        {
            ApiResult apiResult = new ApiResult();
            return ExceptionHelper.TryReturnException(() =>
            {
                apiResult.Data = FactoryBll.CheckHasCode(insertData);
            }, apiResult, Request);
        }
    }
}