using Furion.DynamicApiController;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common;
using Nirvana.Common.ApiBase;
using System.Threading.Tasks;
using YBDevice.Entity;

namespace YBDevice.Application.ProductInfo
{
    /// <summary>
    /// 出货管理
    /// </summary>
    [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
    public class ProductAppService : IDynamicApiController
    {
        private readonly IProductService _Service;
        public ProductAppService(IProductService Service)
        {
            _Service = Service;
        }
        /// <summary>
        /// 出货列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetListAsync(QueryParams param)
        {
            var result = await _Service.GetListAsync(param);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }
        /// <summary>
        /// 物流列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetExpressListAsync(QueryParams param)
        {
            var result = await _Service.GetExpressListAsync(param);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }
        /// <summary>
        /// 出货设备列表
        /// </summary>
        /// <param name="param"></param>
        /// <param name="id"></param>
        /// <returns></returns>
       [HttpPost]
        public async Task<ResultInfo> GetDevListAsync(QueryParams param, [FromQuery]int id)
        {
            var result = await _Service.GetDevListAsync(param,id);
            return new ResultInfo(ResultState.SUCCESS, "success", result);
        }
        /// <summary>
        /// 信息编辑
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitAsync(YB_OutProduct data)
        {
            return await _Service.SubmitAsync(data);
        }

        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> SetStatusAsync(int id, OutProductStatus status)
        {
            return await _Service.SetStatusAsync(id, status);
        }

        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="id"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        [HttpGet]
        [QueryParameters]
        public async Task<ResultInfo> CancelAsync(int id, string remark)
        {
            return await _Service.CancelAsync(id, remark);
        }

        /// <summary>
        /// 物流信息编辑
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<ResultInfo> SubmitExpressAsync(YB_ExPress data)
        {
            return await _Service.SubmitExpressAsync(data);
        }

        /// <summary>
        /// 批量设置
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> BatchSetAsync(OutProductBatchSetDto data)
        {
            return await _Service.BatchSetAsync(data);
        }
    }
}
