李昊 4 years ago
parent
commit
6ab6d91f37

+ 1 - 1
GxPress/Api/GxPress.Api/AdminControllers/AdminUtilsController.cs

@@ -423,7 +423,7 @@ namespace GxPress.Api.AdminControllers
         [HttpGet("im-user")]
         public async Task<bool> SetImUser()
         {
-            var users = await _userRepository.GetAllAsync(Q.Where(nameof(Entity.User.Id), "=", ""));
+            var users = await _userRepository.GetAllUserIm();
             foreach (var item in users)
             {
                 await _userRepository.CreateMiUserAsync(item);

+ 11 - 4
GxPress/Repository/GxPress.Repository.Implement/UserRepository.cs

@@ -166,7 +166,7 @@ namespace GxPress.Repository.Implement
             //用户不存在,自动注册
             if (user == null)
                 throw new BusinessException("用户不存在");
-            
+
             return await _repository.UpdateAsync(Q.Where(nameof(User.Phone), request.Phone).Set(nameof(User.OpenId), request.OpenId)) > 0;
         }
         public async Task<bool> DeleteUsersAsync(IEnumerable<int> userIds)
@@ -649,7 +649,7 @@ namespace GxPress.Repository.Implement
             try
             {
                 var imServiceUrl = ConfigHelper.GetValue("ServiceAddress:ImUrl");
-                var httpClientHandler=new HttpClientHandler{ServerCertificateCustomValidationCallback=HttpClientHandler.DangerousAcceptAnyServerCertificateValidator};
+                var httpClientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator };
                 HttpClient httpClient = new HttpClient(httpClientHandler); //http对象
                 HttpResponseMessage response = await httpClient.PostAsync(
                     $"{imServiceUrl}/users",
@@ -694,7 +694,7 @@ namespace GxPress.Repository.Implement
                     if (request.SearchType == 2 && !string.IsNullOrWhiteSpace(request.Key) && request.DepartmentId > 0)
                         notInUserIds = "and a.Id not in(";
                     if (request.SearchType == 1 && !string.IsNullOrWhiteSpace(request.Key) && request.DepartmentId > 0)
-                        notInUserIds = "and Id not in("; 
+                        notInUserIds = "and Id not in(";
                     foreach (var userId in request.UserIds)
                     {
                         notInUserIds += $"{userId},";
@@ -785,7 +785,14 @@ namespace GxPress.Repository.Implement
             user.QRCoder = StringUtils.AddDomain(user.QRCoder);
             return _mapper.Map<UserDetail>(user);
         }
-
+        public async Task<IEnumerable<Entity.User>> GetAllUserIm()
+        {
+            string sql = "SELECT * FROM tede_user where ImId =''";
+            var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
+            var database = new Database(databaseType, _connectionString);
+            var connection = database.GetConnection();
+            return await connection.QueryAsync<User>(sql);
+        }
         public async Task<int> CountAsync(Query query)
         {
             return await _repository.CountAsync(query);

+ 1 - 1
GxPress/Repository/GxPress.Repository.Interface/IUserRepository.cs

@@ -21,7 +21,7 @@ namespace GxPress.Repository.Interface
         Task<string> GetAvatarUrlAsync(int id);
 
         string GetAvatarUrl(User user);
-
+        Task<IEnumerable<Entity.User>> GetAllUserIm();
         Task<User> GetByPhoneAsync(string phone);
 
         Task<bool> DeleteUsersAsync(IEnumerable<int> userIds);