
using IoC;
using Microsoft.AspNetCore.Mvc;
using NPOI.HPSF;
using System.Threading.Tasks;
using XYY.Core.Standard.Mvc;
using XYY.Service.Standard.Order;

namespace XYY.Api.Order.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AddressVerifController : ApiControllerBase
    {
        IAddressVerifService _addressVerifService;

        public AddressVerifController(IAddressVerifService addressVerifService)
        {
            _addressVerifService = addressVerifService;

        }
        public async Task<IActionResult> LoadDHLAddressFile()
        {
            var filelist = (await Request.ReadFormAsync()).Files;
            if (filelist != null && filelist.Count > 0)
            {
                var file = filelist[0];
                var result= await _addressVerifService.DHLAddressVerify(file.OpenReadStream());
                string Path = System.IO.Path.Combine(HttpContext.Request.Host.Value,"temp", "DHLAddressVerifyResult", result+".xlsx");
                return Ok("http://"+Path);
            }
            else
            {
                return Error("请上传一个文件");
            }
        }
    }
}
