lihao 4 年之前
父節點
當前提交
3108d5c8cf

+ 10 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/GroupController.cs

@@ -274,5 +274,15 @@ namespace GxPress.Api.AppControllers
         {
             return await _groupRepository.GetUserGroupListAsync(_loginContext.AccountId);
         }
+        /// <summary>
+        /// 小组广场搜索
+        /// </summary>
+        /// <param name="keyWord"></param>
+        /// <returns></returns>
+        [HttpGet("search")]
+        public async Task<IEnumerable<SearchGroupDetailResult>> GetSearchGroupAsync([FromQuery] string keyWord)
+        {
+            return await _groupRepository.GetSearchGroupAsync(keyWord, _loginContext.AccountId);
+        }
     }
 }

+ 5 - 0
gx_api/GxPress/Model/GxPress.Entity/Topic/Topic.cs

@@ -49,5 +49,10 @@ namespace GxPress.Entity.Topic
         /// <value></value>
         [DataColumn]
         public int FolderId { get; set; }
+        /// <summary>
+        /// 是否草稿
+        /// </summary>
+        /// <value></value>
+        public bool IsDraft { get; set; }
     }
 }

+ 5 - 0
gx_api/GxPress/Model/GxPress.Request/App/Topic/TopicDetailListRequest.cs

@@ -31,5 +31,10 @@ namespace GxPress.Request.App.Topic
         {
             GroupIds = new List<int>();
         }
+        /// <summary>
+        /// 是否草稿
+        /// </summary>
+        /// <value></value>
+        public bool IsDraft { get; set; }
     }
 }

+ 5 - 0
gx_api/GxPress/Model/GxPress.Request/App/Topic/TopicInRequest.cs

@@ -57,5 +57,10 @@ namespace GxPress.Request.App.Topic
         {
             TopicAddresseeUserIds = new List<int>();
         }
+        /// <summary>
+        /// 是否草稿
+        /// </summary>
+        /// <value></value>
+        public bool IsDraft { get; set; }
     }
 }

+ 5 - 0
gx_api/GxPress/Model/GxPress.Request/App/Topic/TopicUpdateRequest.cs

@@ -44,5 +44,10 @@ namespace GxPress.Request.App.Topic
         {
             TopicAddresseeUserIds = new List<int>();
         }
+        /// <summary>
+        /// 是否草稿
+        /// </summary>
+        /// <value></value>
+        public bool IsDraft { get; set; }
     }
 }

+ 40 - 2
gx_api/GxPress/Model/GxPress.Result/App/Group/GroupDetailResult.cs

@@ -166,7 +166,7 @@ namespace GxPress.Result.App.Group
         /// <value></value>
         public int Sort { get; set; }
 
-         /// <summary>
+        /// <summary>
         /// 广场ID
         /// </summary>
         public int GroupCategroyId { get; set; }
@@ -196,6 +196,7 @@ namespace GxPress.Result.App.Group
         /// </summary>
         /// <value></value>
         public int UserCount { get; set; }
+
     }
     /// <summary>
     /// 
@@ -212,5 +213,42 @@ namespace GxPress.Result.App.Group
         public string Name { get; set; }
 
     }
-
+    /// <summary>
+    /// 小组搜索
+    /// </summary>
+    public class SearchGroupDetailResult
+    {
+        /// <summary>
+        /// 小组ID
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 简介
+        /// </summary>
+        /// <value></value>
+        public string Introduce { get; set; }
+        /// <summary>
+        /// 小组名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 头像
+        /// </summary>
+        public string AvatarUrl { get; set; }
+        /// <summary>
+        /// 用户数量
+        /// </summary>
+        /// <value></value>
+        public int UserCount { get; set; }
+        /// <summary>
+        /// 是否申请
+        /// </summary>
+        /// <value></value>
+        public bool IsApply { get; set; }
+        /// <summary>
+        /// 是否是成员
+        /// </summary>
+        /// <value></value>
+        public bool IsUser { get; set; }
+    }
 }

+ 61 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/GroupRepository.cs

@@ -637,6 +637,66 @@ namespace GxPress.Repository.Implement
             }
             return result;
         }
-
+        /// <summary>
+        /// 小组广场搜索
+        /// </summary>
+        /// <param name="keyWord"></param>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<SearchGroupDetailResult>> GetSearchGroupAsync(string keyWord, int userId)
+        {
+            string sqlStr = string.Empty;
+            if (!string.IsNullOrWhiteSpace(keyWord))
+                sqlStr += $" and a.Name like '%{keyWord}%'";
+            string sql = $@"SELECT 
+                            a.Id,
+                            a.Name,
+                            a.AvatarUrl,
+                            a.Introduce,
+                            (SELECT 
+                                    COUNT(1)
+                                FROM
+                                    tede_group_user
+                                WHERE
+                                    GroupId = a.Id) AS UserCount,
+                            (SELECT 
+                                    COUNT(1)
+                                FROM
+                                    tede_topic
+                                WHERE
+                                    GroupId = a.Id) as TopicCount,
+                                    (SELECT 
+                                        COUNT(1)
+                                    FROM
+                                        tede_group_user
+                                    WHERE
+                                        GroupId = a.Id AND UserId = {userId}
+                                    LIMIT 1) AS IsUser,
+                                (SELECT 
+                                        count(1)
+                                    FROM
+                                        tede_admin_verify
+                                    WHERE
+                                        SourceType = 1 AND VerifyType = 3
+                                            AND UserId = {userId}
+                                            AND DisposeType = 0
+                                            AND SourceId = a.Id limit 1) as IsApply
+                        FROM
+                            tede_group a
+                        WHERE
+                            a.IsShow = 1 {sqlStr}
+                        ORDER BY a.Sort DESC";
+            var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
+            var database = new Database(databaseType, _connectionString);
+            var connection = database.GetConnection();
+            var result = await connection
+                .QueryAsync<SearchGroupDetailResult>(sql);
+            foreach (var item in result)
+            {
+                item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
+                item.Introduce = string.IsNullOrWhiteSpace(item.Introduce) ? string.Empty : item.Introduce;
+            }
+            return result;
+        }
     }
 }

+ 9 - 3
gx_api/GxPress/Repository/GxPress.Repository.Implement/TopicRepository.cs

@@ -222,7 +222,7 @@ namespace GxPress.Repository.Implement
                                                 tede_group
                                             WHERE
                                                 IsShow = 1) ";
-
+            sqlStr += $" and a.IsDraft={(request.IsDraft == true ? 1 : 0)}";
 
             if (!string.IsNullOrEmpty(request.Key))
             {
@@ -347,7 +347,7 @@ namespace GxPress.Repository.Implement
         {
             var topicConst = AllTypeConst.Topic.GetHashCode();
             var result = new PagedList<TopicListPageResult>();
-            var sqlStr = "";
+            var sqlStr = $" and a.IsDraft={(request.IsDraft == true ? 1 : 0)}";
             if (request.GroupIds.Count() == 0)
             {
                 sqlStr += $@" AND a.GroupId IN (SELECT 
@@ -576,7 +576,12 @@ namespace GxPress.Repository.Implement
         /// <returns></returns>
         public async Task<List<JobTopicResult>> ExecuteTopic()
         {
-            string sql = "select a.*,b.UserId,b.Id,c.Name,d.AvatarUrl from tede_topic a inner join  tede_topic_addressee b on a.Id=b.TopicId inner join tede_user c on c.Id=b.UserId inner join tede_user d on d.Id=a.UserId where b.IsUpload=0 order by a.CreatedDate desc limit 0,100";
+            string sql = @"select a.*,b.UserId,b.Id,c.Name,d.AvatarUrl from tede_topic a 
+                        inner join  tede_topic_addressee b on a.Id=b.TopicId 
+                        inner join tede_user c on c.Id=b.UserId 
+                        inner join tede_user d on d.Id=a.UserId 
+                        where b.IsUpload=0 
+                        order by a.CreatedDate desc limit 0,100";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
@@ -771,5 +776,6 @@ namespace GxPress.Repository.Implement
             result.Total = await connection.ExecuteScalarAsync<int>(sql);
             return result;
         }
+
     }
 }

+ 7 - 0
gx_api/GxPress/Repository/GxPress.Repository.Interface/IGroupRepository.cs

@@ -114,5 +114,12 @@ namespace GxPress.Repository.Interface
         /// </summary>
         /// <returns></returns>
         Task<IEnumerable<GroupDetailResult>> GetGroupDetailResults(string keyWor);
+        /// <summary>
+        /// 小组广场搜索
+        /// </summary>
+        /// <param name="keyWord"></param>
+        /// <param name="userId"></param>
+        /// <returns></returns>
+        Task<IEnumerable<SearchGroupDetailResult>> GetSearchGroupAsync(string keyWord, int userId);
     }
 }

+ 2 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Topic/TopicService.Add.cs

@@ -34,7 +34,8 @@ namespace GxPress.Service.Implement.Topic
                         HtmlContent = request.HtmlContent,
                         Title = request.Title,
                         GroupId = request.GroupId,
-                        FolderId = request.FolderId
+                        FolderId = request.FolderId,
+                        IsDraft = request.IsDraft
                     };
 
                     if (!string.IsNullOrEmpty(request.Content))

+ 2 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Topic/TopicService.Update.cs

@@ -52,6 +52,8 @@ namespace GxPress.Service.Implement.Topic
             }
             //添加话题阅读成员
             await _topicAddresseeRepository.InsertAsync(topicAddressees);
+            //是否草稿
+            topic.IsDraft = request.IsDraft;
             return await _topicRepository.UpdateAsync(topic);
         }
     }