using Microsoft.AspNetCore.Mvc;
using WCS.BLL.Services.IService;
using WCS.BLL.Services.Service;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.Stocktaking;

namespace WCS.WebApi.Controllers
{
    /// <summary>
    /// PDA货架绑定解绑 相关接口
    /// </summary>
    [ApiController]
    [Route("[controller]")]
    public class PDAShelfLocationBindUnbindController : ControllerBase
    {
        public IStockTakingService _stockTakingService { get; set; }
        public PDAShelfLocationBindUnbindController(IStockTakingService stockTakingService)
        {
            _stockTakingService = stockTakingService;
        }

        [Route("getLocationInfoByShelfCode")]
        [HttpPost(Name = "getLocationInfoByShelfCode")]
        public async Task<ResponseCommon> getLocationInfoByShelfCode(StockTakingByIdRequest request)
        {
            try
            {
                #region 参数校验
                //判断参数  //数量可以为空 数量为空盘点确认 这边删除对应数据即可
                if (request.MatDetailCurrentInfoId == 0)
                {
                    return new ResponseCommon()
                    {
                        Code = 201,
                        Message = $"操作失败:参数传入错误(Id为0)!",
                        Data = null,
                    };
                }

                if (request.StocktakingQty < 0)
                {
                    return new ResponseCommon()
                    {
                        Code = 201,
                        Message = $"操作失败:数量应大于等于0!",
                        Data = null,
                    };
                }
                #endregion

                return await _stockTakingService.stockTakingById(request);
            }
            catch (Exception ex)
            {
                return new ResponseCommon()
                {
                    Code = 201,
                    Message = ex.Message,
                    Data = null,
                };
            }
        }

    }
}
