using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using Zxd.Core.Shared; using Zxd.Entity.UserCenter; namespace Zxd.Domain { public class UserInfoDomain : IUserInfoDomain { private readonly IHttpClient _httpClient; private readonly SystemConfig _systemConfig; public UserInfoDomain( IConfiguration configuration, IHttpClient httpClient) { _systemConfig = configuration.GetSection("SystemConfig").Get(); _httpClient = httpClient; } /* public async Task> GetUserInfo(string? appid, string? appuserid) { List res = new List(); var userinfos = await _userCenterRepository.GetRepository().Query() .Where(x => x.Appid == appid && x.Appuserid == appuserid) .ToListAsync(); if (userinfos == null || !userinfos.Any()) { return res; } var customerid = userinfos[0].Customerid; userinfos = await _userCenterRepository.GetRepository().Query() .Where(x => x.Customerid == customerid) .ToListAsync(); if (userinfos == null || !userinfos.Any()) { return res; } foreach (var userinfo in userinfos) { if (!string.IsNullOrWhiteSpace(userinfo.Resid)) { UserInfoDto newModel = new UserInfoDto { Resid = userinfo.Resid, }; res.Add(newModel); } } return res; }*/ public async Task> GetUserInfoByApi(string? appid, string? userid) { Stopwatch stopWatch = Stopwatch.StartNew(); stopWatch.Start(); var res = new List(); var url = _systemConfig.ZXDCoreUrl; // _basParameterService.GetParameterValue("Zxd_CoreApiUrl"); url = $"{url}Api/UserInfo/list"; var resModel = await _httpClient.GetAsync>>($"{url}?appid={appid}&appuserid={userid}", timeout: 2000); res = resModel.data; stopWatch.Stop(); Log.Warning($"GetUserInfoByApi:{stopWatch.ElapsedMilliseconds}"); return res; } public async Task> GetUserInfoByApi(string? resid) { Stopwatch stopWatch = Stopwatch.StartNew(); stopWatch.Start(); var res = new List(); var url = _systemConfig.ZXDCoreUrl; // _basParameterService.GetParameterValue("Zxd_CoreApiUrl"); url = $"{url}Api/UserInfo/list"; var resModel = await _httpClient.GetAsync>>($"{url}?resid={resid}", timeout: 2000); res = resModel.data; stopWatch.Stop(); Log.Warning($"GetUserInfoByApi:{stopWatch.ElapsedMilliseconds}"); return res; } } }