李昊 4 年之前
父節點
當前提交
7e546e0c53

+ 4 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/OftenContactController.cs

@@ -121,9 +121,13 @@ namespace GxPress.Api.AppControllers
         public async Task<IEnumerable<ChatSearchResult>> GetChatSearchAsync(string keyWord)
         {
             var result = new List<ChatSearchResult>();
+            //搜索文件夹
             result.AddRange(await chatSearchService.GetChatFolderNameSearchAsync(keyWord, _loginContext.AccountId));
+            //群聊
             result.AddRange(await chatSearchService.GetGroupChatNameSearchAsync(keyWord, _loginContext.AccountId));
+            //单聊
             result.AddRange(await chatSearchService.GetChatSearchAsync(keyWord, _loginContext.AccountId));
+            //好友
             result.AddRange(await chatSearchService.GetFriendUserInfoResult(keyWord, _loginContext.AccountId));
             return result;
         }

+ 6 - 0
gx_api/GxPress/Model/GxPress.Result/App/Topic/TopicListPageResult.cs

@@ -107,6 +107,12 @@ namespace GxPress.Result.App.Topic
         /// <summary>
         /// 
         /// </summary>
+        /// <value></value>
+        public int ParentId { get; set; }
+
+        /// <summary>
+        /// 
+        /// </summary>
         public TopicListPageResult()
         {
             FolderResult = new TopicListPageFolderResult();

+ 12 - 0
gx_api/GxPress/Model/GxPress.Result/Chat/ChatResult.cs

@@ -22,6 +22,12 @@ namespace GxPress.Result.Chat
         /// <value></value>
         public string Name { get; set; }
         /// <summary>
+        /// 用户ID
+        /// </summary>
+        /// <value></value>
+        public int ToUserId { get; set; }
+
+        /// <summary>
         /// 环信ID
         /// </summary>
         /// <value></value>
@@ -47,5 +53,11 @@ namespace GxPress.Result.Chat
         /// <value></value>
         public int TypeValue { get; set; }
 
+        /// <summary>
+        /// 是否置顶
+        /// </summary>
+        /// <value></value>
+        public bool IsTop { get; set; }
+
     }
 }

+ 7 - 14
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -429,22 +429,15 @@ namespace GxPress.Repository.Implement
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
-            // var userIds = new List<int>();
-            // if (request.TopicGroupIds != null && request.TopicGroupIds.Contains(-1))
-            // {
-            //     //获取部门下面的员工
-            //     var users = await _userRepository.GetUserByDepartmentIdAsync(department.Id);
-            // }
-            result.Items = await connection.QueryAsync<TopicListPageResult, User, TopicListPageResult>(sql, (topicListPageResult, user) =>
-              {
-                  topicListPageResult.UserName = user != null ? user.Name : "";
-                  topicListPageResult.AvatarUrl = user != null ? StringUtils.AddDomainMin(user.AvatarUrl) : "";
-                  topicListPageResult.FolderResult.Id = topicListPageResult.FolderId;
-                  topicListPageResult.FolderResult.FolderName = topicListPageResult.FolderName;
-                  return topicListPageResult;
-              }, splitOn: "Id,Name");
+            result.Items = await connection.QueryAsync<TopicListPageResult>(sql);
             result.Total = await connection.ExecuteScalarAsync<int>(countSql);
             connection.Dispose();
+            foreach (var item in result.Items)
+            {
+                item.FolderResult.FolderName = item.FolderName;
+                item.FolderResult.Id = item.ParentId;
+                item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
+            }
             return result;
         }
 

+ 4 - 3
gx_api/GxPress/Service/GxPress.Service.Implement/Chat/ChatSearchService.cs

@@ -32,7 +32,7 @@ namespace GxPress.Service.Implement.Chat
             if (!string.IsNullOrEmpty(keyWord))
                 sqlStr += $" and c.Name like '%{keyWord}%'";
             var sql = $@"SELECT 
-                            c.Id, c.Name,c.Phone as ImId,c.AvatarUrl,b.LastModifiedDate
+                           a.Id, c.Name,c.Phone as ImId,c.AvatarUrl,b.ContactUserId as ToUserId,b.LastModifiedDate,a.IsTop
                         FROM
                             tede_middle a
                                 INNER JOIN
@@ -101,11 +101,12 @@ namespace GxPress.Service.Implement.Chat
             if (!string.IsNullOrEmpty(keyWord))
                 sqlStr += $" AND d.Name LIKE '%{keyWord}%'";
             var sql = $@"SELECT 
-                                d.Id,
+                                a.Id,
                                 d.Name,
                                 d.AvatarUrl,
                                 d.GroupChatImId AS ImId,
-                                d.CreatedDate AS LastModifiedDate
+                                d.CreatedDate AS LastModifiedDate,
+                                a.IsTop
                             FROM
                                 tede_middle a
                                     INNER JOIN

+ 11 - 11
gx_api/GxPress/Service/GxPress.Service.Implement/Topic/TopicService.cs

@@ -230,7 +230,7 @@ namespace GxPress.Service.Implement.Topic
         {
             var topicTypeValue = GxPress.EnumConst.AllTypeConst.Note.GetHashCode();
             var sql = $@"SELECT 
-                                a.*,
+                                a.Id,a.Title,a.UserId,a.Content,a.CreatedDate,a.IsTopic,c.ParentId,
                                 (SELECT 
                                         FolderName
                                     FROM
@@ -287,7 +287,7 @@ namespace GxPress.Service.Implement.Topic
                                             AND SourceId = a.Id
                                             AND AnalyzeType = 3
                                     LIMIT 0 , 1) AS IsCollect,
-                                b.Name, b.AvatarUrl
+                                b.Name as UserName, b.AvatarUrl
                                                     FROM
                                                         tede_note a
                                                             INNER JOIN
@@ -299,22 +299,22 @@ namespace GxPress.Service.Implement.Topic
                                                          ";
             if (request.UserId <= 0)
             {
-                sql += @" AND c.ParentId IN (SELECT 
+                sql += $@" AND c.ParentId IN (SELECT 
                                                     id
                                                 FROM
                                                     tede_middle
                                                 WHERE
-                                                    FolderType = 4 AND AttributeValue = 2
+                                                    FolderType = {topicTypeValue} AND AttributeValue = 2
                                                         AND RoleId = 1)";
             }
             else
             {
-                sql += $@" AND (a.userId={request.UserId} or a.FolderId IN (SELECT 
+                sql += $@" AND (a.userId={request.UserId} or c.ParentId IN (SELECT 
                                                                 MiddleId
                                                             FROM
                                                                 tede_folder_user
                                                             WHERE
-                                                                MiddleId = a.FolderId AND UserId = {request.UserId})
+                                                                MiddleId = c.ParentId AND UserId = {request.UserId})
                                                             OR a.UserId IN (SELECT 
                                                                 Id
                                                             FROM
@@ -325,7 +325,7 @@ namespace GxPress.Service.Implement.Topic
                                                                     FROM
                                                                         tede_middle
                                                                     WHERE
-                                                                        id = a.FolderId) and Id=a.UserId
+                                                                        id = c.ParentId) and Id=a.UserId
                                                                     ))";
             }
 
@@ -404,7 +404,7 @@ namespace GxPress.Service.Implement.Topic
                                                         c.FolderType = 4 AND a.IsTopic = 1 and c.IsDelete=0";
             if (request.UserId <= 0)
             {
-                sql += @" AND c.ParentId IN (SELECT 
+                sql += $@" AND c.ParentId IN (SELECT 
                                                     id
                                                 FROM
                                                     tede_middle
@@ -414,12 +414,12 @@ namespace GxPress.Service.Implement.Topic
             }
             else
             {
-                sql += $@" AND (a.userId={request.UserId} or a.FolderId IN (SELECT 
+                sql += $@" AND (a.userId={request.UserId} or c.ParentId IN (SELECT 
                                                                 MiddleId
                                                             FROM
                                                                 tede_folder_user
                                                             WHERE
-                                                                MiddleId = a.FolderId AND UserId = {request.UserId})
+                                                                MiddleId = c.ParentId AND UserId = {request.UserId})
                                                             OR a.UserId IN (SELECT 
                                                                 Id
                                                             FROM
@@ -430,7 +430,7 @@ namespace GxPress.Service.Implement.Topic
                                                                     FROM
                                                                         tede_middle
                                                                     WHERE
-                                                                        id = a.FolderId) and Id=a.UserId
+                                                                        id = c.ParentId) and Id=a.UserId
                                                                     ))";
             }