李昊 4 lat temu
rodzic
commit
22bccbc714

+ 9 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/GroupChatController.cs

@@ -186,5 +186,14 @@ namespace GxPress.Api.AppControllers
         {
             return await _groupChatRepository.SetIsOpenQrCoderAsync(groupChatImId, _loginContext.AccountId);
         }
+        /// <summary>
+        /// 获取用户加入的群
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("list")]
+        public async Task<IEnumerable<GroupChat>> GetGroupChatsAsync()
+        {
+            return await _groupChatRepository.GetGroupChatsAsync(_loginContext.AccountId);
+        }
     }
 }

+ 21 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/GroupChatRepository.cs

@@ -173,7 +173,7 @@ namespace GxPress.Repository.Implement
                     if (groupChat == null)
                         return false;
                     //添加用户
-                    
+
                     foreach (var user in request.Users)
                     {
                         if (user.Id == groupChat.UserId)
@@ -432,5 +432,25 @@ namespace GxPress.Repository.Implement
             return await _repository.UpdateAsync(Q.Set(nameof(groupChat.IsOpenQrCoder), !groupChat.IsOpenQrCoder)
                        .Where(nameof(groupChat.Id), groupChat.Id)) > 0;
         }
+        /// <summary>
+        /// 获取用户加入的群
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<GroupChat>> GetGroupChatsAsync(int userId)
+        {
+            string sql = $@"SELECT * FROM ccpph_tede.tede_group_chat where id in(
+                          select GroupChatId from tede_group_chat_user where UserId={userId}) order by CreatedDate desc";
+            var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
+            var database = new Database(databaseType, _connectionString);
+            var connection = database.GetConnection();
+            var result = await connection.QueryAsync<GroupChat>(sql);
+            foreach (var item in result)
+            {
+                item.QRCoder = StringUtils.AddDomain(item.QRCoder);
+                item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
+            }
+            return result;
+        }
     }
 }

+ 2 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/Note/NoteRepository.cs

@@ -594,6 +594,8 @@ namespace GxPress.Repository.Implement.Note
                                 a.CreatedDate,
                                 a.MediaId,
                                 a.ReadCount,
+                               (select FolderName from  tede_middle where id= (select ParentId from tede_middle where MiddleId=a.Id AND FolderType = {noteConstValue})) as FolderName,
+                                (select Id from  tede_middle where id= (select ParentId from tede_middle where MiddleId=a.Id AND FolderType = {noteConstValue})) as FolderId,
                                 (SELECT 
                                         COUNT(1)
                                     FROM

+ 2 - 2
gx_api/GxPress/Repository/GxPress.Repository.Implement/NoticeRepository.cs

@@ -341,7 +341,7 @@ namespace GxPress.Repository.Implement
                             OR c.Name LIKE '%{request.Keyword}%'
                             OR d.UserName LIKE '%{request.Keyword}%'
                             OR a.CreatedDate LIKE '%{request.Keyword}%' or a.MiddleId in (SELECT 
-                                                                                            g.NoticeId
+                                                                                            g.SourceId
                                                                                         FROM
                                                                                             tede_addressee g
                                                                                                 INNER JOIN
@@ -354,7 +354,7 @@ namespace GxPress.Repository.Implement
                             OR c.Name LIKE '%{request.Keyword}%'
                             OR d.UserName LIKE '%{request.Keyword}%'
                             OR a.CreatedDate LIKE '%{request.Keyword}%'  or a.MiddleId in (SELECT 
-                                                                                            g.NoticeId
+                                                                                            g.SourceId
                                                                                         FROM
                                                                                             tede_addressee g
                                                                                                 INNER JOIN

+ 6 - 0
gx_api/GxPress/Repository/GxPress.Repository.Interface/IGroupChatRepository.cs

@@ -80,5 +80,11 @@ namespace GxPress.Repository.Interface
         /// <param name="imId"></param>
         /// <returns></returns>
          Task<GroupChatInfoResult> GetGroupChatInfoByImIdAsync(string imId);
+          /// <summary>
+        /// 获取用户加入的群
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+         Task<IEnumerable<GroupChat>> GetGroupChatsAsync(int userId);
    }
 }

+ 2 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Note/NoteService.cs

@@ -573,6 +573,8 @@ namespace GxPress.Service.Implement.Note
             var result = await _noteRepository.GetNoteNotFolderPageResult(request);
             foreach (var item in result.Items)
             {
+                if (string.IsNullOrEmpty(item.FolderName))
+                    item.FolderName = "根目录";
                 item.MiddleId = item.Id;
                 //是否摘录
                 if (item.MediaId > 0)