李昊 4 年之前
父節點
當前提交
0470ab406b

+ 3 - 0
GxPress/Api/GxPress.Api/AppControllers/UserController.cs

@@ -101,6 +101,9 @@ namespace GxPress.Api.AppControllers
             if (success)
             {
                 var result = await _userRepository.SignInAsync(request);
+                if (result.IsAddUser)
+                    //添加环信
+                    await _userRepository.CreateMiUserAsync(result.UserEntity);
                 var claims = new[]
                 {
                 new Claim(ClaimTypes.NameIdentifier, result.UserId.ToString()),

+ 6 - 0
GxPress/Model/GxPress.Result/User/UserSignInResult.cs

@@ -23,5 +23,11 @@ namespace GxPress.Result.User
         public TokenResult Token { get; set; }
 
         public UserResult User { get; set; }
+        public Entity.User UserEntity { get; set; }
+        /// <summary>
+        /// 是否新增用户
+        /// </summary>
+        /// <value></value>
+        public bool IsAddUser { get; set; }
     }
 }

+ 3 - 1
GxPress/Repository/GxPress.Repository.Implement/UserRepository.cs

@@ -311,13 +311,15 @@ namespace GxPress.Repository.Implement
                     //用户不存在,自动注册
                     if (user == null)
                     {
-                        user=new User();
+                        user = new User();
                         user.Name = request.Phone;
                         user.Phone = request.Phone;
                         user.Id = await InsertAsync(user);
                         result.UserId = user.Id;
                         result.DepartmentId = user.DepartmentId;
                         result.User = _mapper.Map<UserResult>(user);
+                        result.IsAddUser = true;
+                        result.UserEntity = user;
                         return result;
                     }
                 }