Эх сурвалжийг харах

Merge branch 'master' of http://110.188.24.182:10023/Fengwo/hotline

田爽 1 жил өмнө
parent
commit
fa1bc04d28

+ 5 - 4
src/Hotline.Api/Controllers/OrderController.cs

@@ -36,6 +36,7 @@ using Hotline.Share.Enums.Quality;
 using Hotline.Share.Enums.Settings;
 using Hotline.Share.Requests;
 using Hotline.Users;
+using Hotline.YbEnterprise.Sdk;
 using MapsterMapper;
 using MediatR;
 using Microsoft.AspNetCore.Authorization;
@@ -100,7 +101,7 @@ public class OrderController : BaseController
     private readonly IEnterpriseService _enterpriseService;
     private readonly IPushDomainService _pushDomainService;
     private readonly ILogger<OrderController> _logger;
-    private readonly ITypedCache<EnterpriseVo> _cacheResponse;
+    private readonly ITypedCache<YbEnterpriseToken> _cacheResponse;
     private readonly IRepository<OrderSendBackAudit> _orderSendBackAuditRepository;
     private readonly IRepository<User> _userRepository;
     private readonly IExportApplication _exportApplication;
@@ -150,7 +151,7 @@ public class OrderController : BaseController
         IEnterpriseService enterpriseService,
         IPushDomainService pushDomainService,
         ILogger<OrderController> logger,
-        ITypedCache<EnterpriseVo> cacheResponse,
+        ITypedCache<YbEnterpriseToken> cacheResponse,
         IRepository<OrderSendBackAudit> orderSendBackAuditRepository,
         IRepository<User> userRepository,
         IExportApplication exportApplication
@@ -3989,9 +3990,9 @@ public class OrderController : BaseController
     /// <returns></returns>
     [HttpGet("enterprise/list")]
     [LogFilter("查询企业列表")]
-    public async Task<EnterpriseListData> GetEnterpriseList([FromQuery] PagedKeywordRequest dto)
+    public async Task<YbEnterprisePaged> QueryYbEnterprises([FromQuery] PagedKeywordRequest dto)
     {
-        return await _enterpriseService.GetEnterpriseList(dto.Keyword!, dto.PageIndex, dto.PageSize, HttpContext.RequestAborted, _cacheResponse);
+        return await _enterpriseService.QueryYbEnterprisesAsync(dto.Keyword!, dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
     }
     #endregion
 

+ 3 - 3
src/Hotline.Api/StartupExtensions.cs

@@ -107,9 +107,9 @@ internal static class StartupExtensions
 		services.AddAiJths(configuration.GetSection("AiQuality").Get<AiQualityConfig>().Url);
 
         //宜宾企业服务
+        services.Configure<EnterpriseConfig>(d => configuration.GetSection("Enterprise").Bind(d));
         var enterpriseConfig = configuration.GetSection("Enterprise").Get<EnterpriseConfig>();
-
-		services.AddYbEnterpriseSdk(enterpriseConfig);
+        services.AddYbEnterpriseSdk(enterpriseConfig?.AddressUrl);
 
         var aiVisitConfig = configuration.GetSection("AiVisit").Get<AiVisitConfig>();
         services.AddAiVisitService(aiVisitConfig.Url, aiVisitConfig.Appkey, aiVisitConfig.ServiceVersion, aiVisitConfig.SceneUid, aiVisitConfig.RuleUid,aiVisitConfig.VisitFromNameKey,aiVisitConfig.VisitFromGenderKey,aiVisitConfig.VisitCreationTimeKey,aiVisitConfig.VisitOrderTitleKey);
@@ -117,7 +117,7 @@ internal static class StartupExtensions
         //sqlsugar
         services.AddSqlSugar(configuration);
         //services.AddWexDb(configuration);
-
+        
         //validator
         services.AddFluentValidationAutoValidation(config =>
         {

+ 0 - 29
src/Hotline.Share/Dtos/Enterprise/EnterpriseDto.cs

@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Hotline.Share.Dtos.Enterprise
-{
-	public class EnterpriseListData
-	{
-		public EnterpriseListDataRecords records { get; set; }
-
-		public int total { get; set; }
-
-		public int size { get; set; }
-
-		public int current { get; set; }
-
-		public int pages { get; set; }
-	}
-
-	public class EnterpriseListDataRecords
-	{
-		public string enterpriseCode { get; set; }
-		public string enterpriseName { get; set; }
-		public string specialTeamCode { get; set; }
-		public string specialTeamName { get; set; }
-	}
-}

+ 44 - 0
src/Hotline.Share/Dtos/Enterprise/YbEnterprisePaged.cs

@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Dtos.Enterprise
+{
+	public class YbEnterprise
+	{
+		[JsonPropertyName("enterpriseCode")]
+		public string EnterpriseCode { get; set; }
+		
+		[JsonPropertyName("enterpriseName")]
+		public string EnterpriseName { get; set; }
+		
+		[JsonPropertyName("specialTeamCode")]
+		public string SpecialTeamCode { get; set; }
+		
+		[JsonPropertyName("specialTeamName")]
+		public string SpecialTeamName { get; set; }
+	}
+	
+	
+	public class YbEnterprisePaged
+	{
+		[JsonPropertyName("records")]
+		public List<YbEnterprise> Records { get; set; }
+		
+		[JsonPropertyName("total")]
+		public int Total { get; set; }
+
+		[JsonPropertyName("size")]
+		public int Size { get; set; }
+
+		[JsonPropertyName("current")]
+		public int Current { get; set; }
+
+		[JsonPropertyName("pages")]
+		public int Pages { get; set; }
+	}
+
+}

+ 10 - 0
src/Hotline.Share/Dtos/Enterprise/YbEnterprisesRequest.cs

@@ -0,0 +1,10 @@
+namespace Hotline.Share.Dtos.Enterprise;
+
+public class YbEnterprisesRequest
+{
+    public string EnterpriseName { get; set; }
+
+    public int Current {  get; set; }
+
+    public int Size { get; set; }
+}

+ 66 - 280
src/Hotline.YbEnterprise.Sdk/EnterpriseService.cs

@@ -2,25 +2,34 @@
 using Hotline.Share.Dtos;
 using RestSharp;
 using System.Collections;
-using System.Net;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
 using System.Text;
 using Hotline.Share.Dtos.Enterprise;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
 using XF.Domain.Cache;
 using XF.Domain.Exceptions;
-using Newtonsoft.Json.Linq;
-using Newtonsoft.Json;
+using XF.Domain.Dependency;
 
 namespace Hotline.YbEnterprise.Sdk
 {
-    public class EnterpriseService : IEnterpriseService
+    public class EnterpriseService : IEnterpriseService, IScopeDependency
     {
-        private readonly RestClient _client;
-        private readonly EnterpriseConfig _config;
-
-        public EnterpriseService(EnterpriseConfig config)
+        private readonly IHttpClientFactory _httpClientFactory;
+        private readonly IOptionsSnapshot<EnterpriseConfig> _enterpriseOptions;
+        private readonly ITypedCache<YbEnterpriseToken> _tokenCache;
+        private readonly ILogger<EnterpriseService> _logger;
+        public EnterpriseService(
+            IHttpClientFactory httpClientFactory,
+            IOptionsSnapshot<EnterpriseConfig> enterpriseOptions,
+            ITypedCache<YbEnterpriseToken> tokenCache,
+            ILogger<EnterpriseService> logger)
         {
-            _client = new RestClient();
-            _config = config;
+            _httpClientFactory = httpClientFactory;
+            _enterpriseOptions = enterpriseOptions;
+            _tokenCache = tokenCache;
+            _logger = logger;
         }
 
         /// <summary>
@@ -31,288 +40,65 @@ namespace Hotline.YbEnterprise.Sdk
         /// <param name="size"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public async Task<EnterpriseListData> GetEnterpriseList(string name = "", int current = 1, int size = 10, CancellationToken cancellationToken = default, ITypedCache<EnterpriseVo> cacheResponse = default)
+        public async Task<YbEnterprisePaged> QueryYbEnterprisesAsync(
+            string name, int current, int size, CancellationToken cancellationToken)
         {
-            //var request = new EnterpriseListRequest
-            //{
-            //    EnterpriseName = name,
-            //    Current = current,
-            //    Size = size
-            //};
-            string postJson = "{";
-            postJson += "\"enterpriseName\":\"" + name + "\",";
-            postJson += "\"current\":\"" + current + "\",";
-            postJson += "\"size\":\"" + size + "\"";
-            postJson += "}";
-			var token = await cacheResponse.GetAsync("EnterpriseResponse", cancellationToken);
-            if (token == null || (token != null && token.EndTime > DateTime.Now))
+            var request = new YbEnterprisesRequest()
             {
-                token = await GetTokenAsync(cancellationToken);
-                token.EndTime = DateTime.Now.AddMinutes(45);
-                await cacheResponse.SetAsync("EnterpriseResponse", token, cancellationToken: cancellationToken);
-            }
-            var path = _config.AddressUrl + "platform/12345/selectEnterpriseList";
-            //var rest = new RestRequest(path, Method.Post);
-            ////rest.AddHeader("content-type", "application/json");
-            ////rest.AddHeader("Blade-Auth", token.TokenType + " " + token.AccessToken);
-            //rest.AddHeaders(new[] {
-            // new KeyValuePair<string, string>("content-type", "application/json"),
-            // new KeyValuePair<string, string>("Blade-Auth", token.TokenType + " " + token.AccessToken)
-            //});
-
-            List<KeyValuePair<string, string>> headers = new List<KeyValuePair<string, string>>();
-            headers.Add(new KeyValuePair<string, string>("Blade-Auth", token.TokenType + " " + token.AccessToken));
+                EnterpriseName = name,
+                Current = current,
+                Size = size
+            };
 
-			string strResult = HttpPost(path, postJson, "UTF-8", "application/json", headers);
-            //var res = await ExecuteAsync<EnterpriseListRequest, EnterpriseListResponse>(path, Method.Post, request, rest, cancellationToken);
-            var res = new EnterpriseListResponse();
-			if (false == string.IsNullOrEmpty(strResult))
-			{
-				res = (EnterpriseListResponse)JsonConvert.DeserializeObject(strResult)!;
-			}
-			return res.data;
+            var token = await GetTokenAsync(YbEnterpriseDefaults.KeyOfToken, cancellationToken);
+            var result = await ExecuteAsync<YbEnterprisesRequest, YbEnterpriseResponse<YbEnterprisePaged>>(
+                YbEnterpriseDefaults.PathEnterprises,
+                request,
+                d => d.DefaultRequestHeaders.Add("Blade-Auth", $"{token.TokenType} {token.AccessToken}"),
+                cancellationToken);
+            if (result is null || !result.Success)
+                throw new UserFriendlyException("未获取到企业专班数据");
+            return result.Data;
         }
 
-        /// <summary>
-        /// 获取TOKEN
-        /// </summary>
-        /// <param name="cancellationToken"></param>
-        /// <returns></returns>
-        /// <exception cref="UserFriendlyException"></exception>
-        public async Task<EnterpriseVo> GetTokenAsync(CancellationToken cancellationToken)
-        {
-
-            string authorization = _config.ClientId + ":" + _config.ClientSecret;
-            authorization = Encoder.Base64Code(authorization);
-            authorization = authorization.Replace("@", "=");
-
-            var path = _config.AddressUrl + "blade-auth/oauth/getAccessToken";
-            //var rest = new RestRequest(path, Method.Post);
-            //rest.AddHeader("content-type", "application/json");
-            //rest.AddHeader("Authorization", "Basic " + authorization);
-            //rest.AddHeader("Tenant-Id", _config.TenantId);
-            //rest.AddHeaders(new[] { 
-            //    new KeyValuePair<string, string>("content-type", "application/json"),
-	           // new KeyValuePair<string, string>("Authorization", "Basic " + authorization),
-	           // new KeyValuePair<string, string>("Tenant-Id", _config.TenantId)});
-            string json = "{\"a\":\"1\"}";
-			//var res = await ExecuteAsync<string, EnterpriseServiceResponse>(path, Method.Post, "", rest, cancellationToken);
-			List<KeyValuePair<string, string>> headers = new List<KeyValuePair<string, string>>();
-			headers.Add(new KeyValuePair<string, string>("Authorization", "Basic " + authorization));
-			headers.Add(new KeyValuePair<string, string>("Tenant-Id", _config.TenantId));
-			string strResult = HttpPost(path, json, "UTF-8", "application/json", headers);
-            EnterpriseServiceResponse? res = new EnterpriseServiceResponse();
-			if (false == string.IsNullOrEmpty(strResult))
-			{
-				 res = (EnterpriseServiceResponse)JsonConvert.DeserializeObject(strResult)!;
-			}
-			if (res is null)
-                throw new UserFriendlyException("获取token请求失败 authorization:" + authorization + " ,path:" + path + " , res:" + strResult);
-            if (!res.success)
-                throw new UserFriendlyException("获取token请求失败  authorization2:" + authorization + " ,path:" + path + " , res:" + System.Text.Json.JsonSerializer.Serialize(res));
-            return res.data;
-        }
-        public async Task<TResponse> ExecuteAsync<TRequest, TResponse>(string path, Method httpMethod, TRequest request, RestRequest restRequest = null,
-            CancellationToken cancellationToken = default)
-            where TRequest : class
+        private async Task<YbEnterpriseToken> GetTokenAsync(string key, CancellationToken cancellationToken)
         {
-            var req = new RestRequest(path, httpMethod);
-            if (httpMethod is Method.Get)
-            {
-                req.AddObject(request);
-            }
-            else
-            {
-                req.AddJsonBody(request);
-            }
-
-            try
-            {
-                var response = await _client.ExecuteAsync<TResponse>(req, cancellationToken);
-                return response.Data;
-            }
-            catch (Exception e)
-            {
-                throw new HttpRequestException($"企业服务数据错误,Error: {e.Message}");
-            }
+            var token = await _tokenCache.GetAsync(key, cancellationToken);
+            if (token is not null) return token;
+            token = await GetTokenAsync(cancellationToken);
+            await _tokenCache.SetAsync(key, token, TimeSpan.FromSeconds(token.ExpiresIn - 5), cancellationToken);
+            return token;
         }
 
-        public static string HttpPost(string strUrl, string strPar = "", string strEncoding = "UTF-8", string strContentType = "application/x-www-form-urlencoded", List<KeyValuePair<string, string>> headers = null)
+        private async Task<YbEnterpriseToken> GetTokenAsync(CancellationToken cancellationToken)
         {
-	        // 返回数据
-	        string strResult = "";
-	        // 网页客户端,用于打开链接,获取返回参数
-	        WebClient wc = new WebClient();
-	        try
-	        {
-		        byte[] responseData = null;
-		        wc.Headers.Add("Content-Type", strContentType);
-		        if (null != headers && headers.Count > 0)
-		        {
-			        headers.ForEach(p =>
-			        {
-				        wc.Headers.Add(p.Key, p.Value);
-			        });
-		        }
-		        byte[] postData = Encoding.GetEncoding(strEncoding).GetBytes(strPar);
-		        responseData = wc.UploadData(strUrl, "POST", postData);
-		        strResult = Encoding.GetEncoding(strEncoding).GetString(responseData);
-		        strResult = strResult.Trim();
-	        }
-	        catch (Exception)
-	        {
-		        strResult = "";
-	        }
-	        finally
-	        {
-		        wc.Dispose();
-		        wc = null;
-	        }
+            var config = _enterpriseOptions.Value;
+            string authorization = config.ClientId + ":" + config.ClientSecret;
+            authorization = Convert.ToBase64String(Encoding.UTF8.GetBytes(authorization));
+            var result = await ExecuteAsync<object, YbEnterpriseResponse<YbEnterpriseToken>>(
+                YbEnterpriseDefaults.PathToken,
+                new(),
+                d =>
+                {
+                    d.DefaultRequestHeaders.Authorization = AuthenticationHeaderValue.Parse($"Basic {authorization}");
+                    d.DefaultRequestHeaders.Add("Tenant-Id", config.TenantId);
+                }, cancellationToken);
 
-	        return strResult;
+            if (result is null || !result.Success)
+                throw new UserFriendlyException("获取enterprise token失败");
+            return result.Data;
         }
 
-		public static class Encoder
+        private async Task<TResponse?> ExecuteAsync<TRequest, TResponse>(string path, TRequest request,
+            Action<HttpClient>? clientInitialize = null, CancellationToken cancellationToken = default)
         {
-            /// <summary>
-            /// 对string 进行 Base64 编码 
-            /// </summary>
-            /// <param name="strMessage">string 参数</param>
-            /// <returns> Base64 编码</returns>
-            public static string Base64Code(string strMessage)
-            {
-                bool flag = string.IsNullOrEmpty(strMessage);
-                string result;
-                if (flag)
-                {
-                    result = "";
-                }
-                else
-                {
-                    char[] array = new char[]
-                    {
-            'A',
-            'B',
-            'C',
-            'D',
-            'E',
-            'F',
-            'G',
-            'H',
-            'I',
-            'J',
-            'K',
-            'L',
-            'M',
-            'N',
-            'O',
-            'P',
-            'Q',
-            'R',
-            'S',
-            'T',
-            'U',
-            'V',
-            'W',
-            'X',
-            'Y',
-            'Z',
-            'a',
-            'b',
-            'c',
-            'd',
-            'e',
-            'f',
-            'g',
-            'h',
-            'i',
-            'j',
-            'k',
-            'l',
-            'm',
-            'n',
-            'o',
-            'p',
-            'q',
-            'r',
-            's',
-            't',
-            'u',
-            'v',
-            'w',
-            'x',
-            'y',
-            'z',
-            '0',
-            '1',
-            '2',
-            '3',
-            '4',
-            '5',
-            '6',
-            '7',
-            '8',
-            '9',
-            '+',
-            '/',
-            '='
-                    };
-                    byte b = 0;
-                    ArrayList arrayList = new ArrayList(Encoding.Default.GetBytes(strMessage));
-                    int count = arrayList.Count;
-                    int num = count / 3;
-                    int num2 = count % 3;
-                    bool flag2 = num2 > 0;
-                    if (flag2)
-                    {
-                        for (int i = 0; i < 3 - num2; i++)
-                        {
-                            arrayList.Add(b);
-                        }
-                        num++;
-                    }
-                    StringBuilder stringBuilder = new StringBuilder(num * 4);
-                    for (int i = 0; i < num; i++)
-                    {
-                        byte[] array2 = new byte[]
-                        {
-                (byte)arrayList[i * 3],
-                (byte)arrayList[i * 3 + 1],
-                (byte)arrayList[i * 3 + 2]
-                        };
-                        int[] array3 = new int[4];
-                        array3[0] = array2[0] >> 2;
-                        array3[1] = ((int)(array2[0] & 3) << 4 ^ array2[1] >> 4);
-                        bool flag3 = !array2[1].Equals(b);
-                        if (flag3)
-                        {
-                            array3[2] = ((int)(array2[1] & 15) << 2 ^ array2[2] >> 6);
-                        }
-                        else
-                        {
-                            array3[2] = 64;
-                        }
-                        bool flag4 = !array2[2].Equals(b);
-                        if (flag4)
-                        {
-                            array3[3] = (int)(array2[2] & 63);
-                        }
-                        else
-                        {
-                            array3[3] = 64;
-                        }
-                        stringBuilder.Append(array[array3[0]]);
-                        stringBuilder.Append(array[array3[1]]);
-                        stringBuilder.Append(array[array3[2]]);
-                        stringBuilder.Append(array[array3[3]]);
-                    }
-                    string text = stringBuilder.ToString();
-                    text = text.Replace("=", "@");
-                    text = text.Replace("+", "%2B");
-                    result = text;
-                }
-                return result;
-            }
+            var client = _httpClientFactory.CreateClient(YbEnterpriseDefaults.HttpName);
+            clientInitialize?.Invoke(client);
+
+            using var responseMessage = await client.PostAsJsonAsync(path, request, cancellationToken);
+            responseMessage.EnsureSuccessStatusCode();
+            var result = await responseMessage.Content.ReadFromJsonAsync<TResponse>(cancellationToken: cancellationToken);
+            return result;
         }
     }
-}
+}

+ 0 - 29
src/Hotline.YbEnterprise.Sdk/EnterpriseServiceResponse.cs

@@ -1,29 +0,0 @@
-using Hotline.Share.Dtos;
-using Hotline.Share.Dtos.Enterprise;
-
-namespace Hotline.YbEnterprise.Sdk
-{
-	public class EnterpriseServiceResponse
-	{
-		public int code {  get; set; }
-		public bool success { get; set; }
-		public EnterpriseVo data { get; set; }
-		public string msg { get; set; }
-	}
-
-	public class EnterpriseListRequest 
-	{
-		public string EnterpriseName { get; set; }
-
-		public int Current {  get; set; }
-
-		public int Size { get; set; }
-	}
-
-	public class EnterpriseListResponse
-	{
-		public int code { get; set; }
-		public bool success { get; set; }
-		public EnterpriseListData data { get; set; }
-	}
-}

+ 7 - 3
src/Hotline.YbEnterprise.Sdk/HotlineYbEnterpriseStartupExtensions.cs

@@ -7,10 +7,14 @@ namespace Hotline.Api.Sdk
 {
     public static class HotlineYbEnterpriseStartupExtensions
     {
-        public static IServiceCollection AddYbEnterpriseSdk(this IServiceCollection services, EnterpriseConfig config)
+        public static IServiceCollection AddYbEnterpriseSdk(this IServiceCollection services, string? baseAddress)
         {
-			services.AddSingleton<IEnterpriseService, EnterpriseService>(_ => new EnterpriseService(config));
-			return services;
+            if (!string.IsNullOrEmpty(baseAddress))
+                services.AddHttpClient(YbEnterpriseDefaults.HttpName, d =>
+                {
+                    d.BaseAddress = new Uri(baseAddress);
+                });
+            return services;
         }
     }
 }

+ 9 - 0
src/Hotline.YbEnterprise.Sdk/YbEnterpriseDefaults.cs

@@ -0,0 +1,9 @@
+namespace Hotline.YbEnterprise.Sdk;
+
+public class YbEnterpriseDefaults
+{
+    public const string HttpName = "yb_enterprise";
+    public const string KeyOfToken = "YbEnterprise";
+    public const string PathToken = "blade-auth/oauth/getAccessToken";
+    public const string PathEnterprises = "platform/12345/selectEnterpriseList";
+}

+ 18 - 0
src/Hotline.YbEnterprise.Sdk/YbEnterpriseResponse.cs

@@ -0,0 +1,18 @@
+using System.Text.Json.Serialization;
+
+namespace Hotline.YbEnterprise.Sdk;
+
+public class YbEnterpriseResponse<TData>
+{
+    [JsonPropertyName("code")]
+    public int Code { get; set; }
+
+    [JsonPropertyName("success")]
+    public bool Success { get; set; }
+
+    [JsonPropertyName("data")]
+    public TData Data { get; set; }
+
+    [JsonPropertyName("msg")]
+    public string Message { get; set; }
+}

+ 4 - 11
src/Hotline.Share/Dtos/EnterpriseDto.cs → src/Hotline.YbEnterprise.Sdk/YbEnterpriseToken.cs

@@ -1,13 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
+using System.Text.Json.Serialization;
 
-namespace Hotline.Share.Dtos
+namespace Hotline.YbEnterprise.Sdk
 {
-	public class EnterpriseVo 
+	public class YbEnterpriseToken 
 	{
 		/// <summary>
 		/// access_token
@@ -32,7 +27,5 @@ namespace Hotline.Share.Dtos
 		/// </summary>
 		[JsonPropertyName("expires_in")]
 		public int ExpiresIn { get; set; }
-
-		public DateTime? EndTime { get; set; }
-	}
+    }
 }

+ 1 - 1
src/Hotline/Enterprise/IEnterpriseService.cs

@@ -6,6 +6,6 @@ namespace Hotline.Enterprise
 {
 	public interface IEnterpriseService
 	{
-		Task<EnterpriseListData> GetEnterpriseList(string name = "", int current = 1, int size = 10, CancellationToken cancellationToken = default, ITypedCache<EnterpriseVo> cacheResponse =default);
+		Task<YbEnterprisePaged> QueryYbEnterprisesAsync(string name, int current, int size, CancellationToken cancellationToken);
 	}
 }

+ 4 - 3
src/Hotline/Push/MessageCodeDomainService.cs

@@ -59,10 +59,11 @@ namespace Hotline.Push
                 return false;
 
             var settingWhite = _systemSettingCacheManager.GetSetting(SettingConstants.LoginCodeWhiteList);
-            if (settingWhite != null && settingWhite.SettingValue.Exists(p => p == UserName))
-                return false;
+       
+            if (settingWhite == null || !settingWhite.SettingValue.Exists(p => p == UserName))
+                return true;
 
-            return true;
+            return false;
         }
 
         /// <summary>