using Microsoft.AspNetCore.Http; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using XYY.Core.Standard.Data.Infrastructure; using XYY.Model.Standard.OrderAddressCheck; using System.Linq; using XYY.PerformanceCount.Standard; namespace XYY.Service.Standard.AddressCheck { public class AssistantAddressService : IAssistantAddressService { private readonly IEnumerable _adderssServicesList; public AssistantAddressService(IEnumerable adderssServicesList) { _adderssServicesList = adderssServicesList; } private IAdderssService GetAdderssService(string receiverCountryCode) { var service = _adderssServicesList.Where(x => x.CountryCode == receiverCountryCode).FirstOrDefault(); if (service == null) throw new Exception("未注册【" + receiverCountryCode + "】相关检索服务"); else return service; } [MethodPerformanceAttrice("GetRecommendedAddresses")] public Task GetRecommendedAddresses(AssistantOrderAddress address) { var _adderssService = GetAdderssService(address.CountryCode); return _adderssService.GetRecommendedAddresses(address.OrderAddress); } } }