using Ashermed.BaseFramework;
using ASHermed.SinoInterface.Api.ContractModel.Framework.Login;
using ASHermed.SinoInterface.ContractModel;
using ASHermed.SinoInterface.IFramework.SingleSignOn;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ASHermed.SingleSignOnFramework
{
    /// <summary>
	/// 系统管理服务
	/// 创建人：杨江军
	/// 创建时间：2020/7/8/星期三 14:13:48
	/// </summary>
	public class SystemManageService : ISystemManageService
    {
        #region 初始化

        /// <summary>
        /// HttpClientHelp
        /// </summary>
        private readonly IHttpClientHelp httpClient;

        /// <summary>
        /// 登录服务
        /// </summary>
        /// <param name="_httpClient"></param>
        public SystemManageService(IHttpClientHelp _httpClient)
        {
            httpClient = _httpClient;
        }

        #endregion

        #region 获取所有系统信息

        /// <summary>
        /// 获取所有系统信息
        /// </summary>
        /// <returns></returns>
        public async Task<BaseResponse<GetSystemInfoAllModel>> GetSystemInfoAll()
        {
            var headers = new Dictionary<string, string>
            {
                { "Token", (PoJun.Util.Helpers.Encrypt.Md5By16($"{SingleSignOnConfig.GetInstance().Key}-{DateTime.Now:yyyyMMddHHmm}")).ToLower() }
            };
            var result = await httpClient.HttpGetAsync<BaseResponse<GetSystemInfoAllModel>>(SingleSignOnConfig.GetInstance().ApiHost, "/api/v1/SystemManage/GetSystemAll", headers: headers);
            return result.Data;
        }

        #endregion
    }
}
