using Com.FirmLib.Entity;
using FirmHttpDao;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.Bll
{
    /// <summary>
    /// 设备种族编码
    /// </summary>
    public class EquipmentFamilyBll:BaseHttpBll
    {
        private EquipmentFamilyBll() : base(@"")
        {

        }
        /// <summary>
        /// 获取基础地址
        /// </summary>
        /// <returns></returns>
        protected override string BaseEndUri()
        {
            return BllHttpSetting.Instance.EquipmentUri;
        }
        /// <summary>
        /// 获取全部设备族信息
        /// </summary>
        /// <returns></returns>
        public List<EquipmentFamilyItem> GetAllItems()
        {
            var items = new List<EquipmentFamilyItem>();
            string tempUrlExtension = @"/dict/query/equipment_family";
            var client = CreateHttpClient();
            var useUri = GetEndUri() + tempUrlExtension;
            var result = client.GetAsync(new Uri(useUri, UriKind.RelativeOrAbsolute));
             var stringResult = HandlerTaskResponse(result, new RequestInfo(useUri));
             HandlerResult(stringResult, (jo) =>
             {
                 var listStr = jo["Content"].ToString();
                 items = JsonConvert.DeserializeObject<List<EquipmentFamilyItem>>(listStr);
             });
            return items;

        }
    }
}
