using Microsoft.AspNetCore.Mvc;
using WCS.BLL.Services.IService;
using WCS.BLL.Services.Service;
using WCS.Model;
using WCS.Model.ApiModel;
using WCS.Model.ApiModel.SingleLight;
using WCS.Model.ApiModel.Stocktaking;
using WCS.Model.ApiModel.UpLoad;
using WCS.Model.ApiModel.User;
using WCS.Model.WebSocketModel;

namespace WCS.WebApi.Controllers
{
    /// <summary>
    /// 本地化Controller 离线点料机上传数据
    /// </summary>
    [ApiController]
    [Route("[controller]")]
    public class UpLoadController : ControllerBase
    {
        public IUploadService _uploadService { get; set; }
        public UpLoadController(IUploadService uploadService)
        {
            _uploadService = uploadService;
        }


        [Route("uploadReelInfo")]
        [HttpPost(Name = "uploadReelInfo")]
        public async Task<ResponseBase> uploadReelInfo(UploadReelInfoRequest request)
        {
            try
            {
                var IPAdress = HttpContext?.Connection?.RemoteIpAddress?.ToString();
                request.IPAddress = IPAdress;

                return await _uploadService.UploadReelInfo(request);
            }
            catch (Exception ex)
            {
                return new ResponseBase()
                {
                    Code = 300,
                    Message = "操作失败：" + ex.Message,
                };
            }
        }

        [Route("getReelInfo")]
        [HttpGet(Name = "getReelInfo")]
        public async Task<ResponseBase> getReelInfo(string MatSN)
        {
            try
            {
                return await _uploadService.GetReelInfo(MatSN);
            }
            catch (Exception ex)
            {
                return new ResponseBase()
                {
                    Code = 300,
                    Message = "操作失败：" + ex.Message,
                };
            }
        }

    }
}
