lihao 4 роки тому
батько
коміт
513a2a6700

+ 10 - 1
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebTopicController.cs

@@ -268,6 +268,15 @@ namespace GxPress.Api.WebControllers
             request.UserId = _loginContext.AccountId;
             return await _topicService.UpdateAsync(request);
         }
-
+        /// <summary>
+        /// 删除草稿箱
+        /// </summary>
+        /// <param name="groupId"></param>
+        /// <returns></returns>
+        [HttpDelete("clear-draft/{groupId}")]
+        public async Task<bool> ClearDraftAsync(int groupId)
+        {
+            return await _topicRepository.ClearDraftAsync(_loginContext.AccountId, groupId);
+        }
     }
 }

+ 5 - 0
gx_api/GxPress/Infrastructure/GxPress.Common/Page/PagedList.cs

@@ -56,5 +56,10 @@ namespace GxPress.Common.Page
         /// </summary>
         /// <value></value>
         public int ParentId { get; set; }
+        /// <summary>
+        /// 是否成员
+        /// </summary>
+        /// <value></value>
+        public bool IsUser { get; set; }
     }
 }

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

@@ -112,6 +112,9 @@ namespace GxPress.Service.Implement.Topic
         public async Task<PagedList<TopicListPageResult>> GetGroupTopicPageAsync(TopicDetailListRequest request)
         {
             var result = new PagedList<TopicListPageResult>();
+            //判断是否小组成员
+            if (request.GroupIds.Count == 1)
+                result.IsUser = await _groupUserRepository.ExistsAsync(request.UserId, request.GroupIds[0]);
             if (request.UserId <= 0)
                 result = await _topicRepository.GetAnonymousGroupTopicPageAsync(request);
             else
@@ -837,10 +840,16 @@ namespace GxPress.Service.Implement.Topic
         /// <returns></returns>
         public async Task<PagedList<TopicListPageResult>> FindTopicByGroupIdAsync(TopicDetailListRequest request)
         {
+            var query = Q.NewQuery();
+            query.Where(nameof(Entity.Topic.Topic.GroupId), request.GroupId);
+            query.Where(nameof(Entity.Topic.Topic.IsDraft), false);
             //根据groupID查询话题
-            var topics = await _topicRepository.GetAllAsync(Q.Where(nameof(Entity.Topic.Topic.GroupId), request.GroupId));
+            var topics = await _topicRepository.GetAllAsync(query);
+            query = Q.NewQuery();
+            query.WhereIn(nameof(Entity.Topic.TopicAddressee.TopicId), topics.Select(n => n.Id).ToList());
+            query.Where(nameof(Entity.Topic.TopicAddressee.UserId), request.UserId).Set(nameof(Entity.Topic.TopicAddressee.IsRead), true);
             //根据话题ID修改用户的阅读
-            await _topicAddresseeRepository.UpdateAsync(Q.WhereIn(nameof(Entity.Topic.TopicAddressee.TopicId), topics.Select(n => n.Id).ToList()).Where(nameof(Entity.Topic.TopicAddressee.UserId), request.UserId).Set(nameof(Entity.Topic.TopicAddressee.IsRead), true));
+            await _topicAddresseeRepository.UpdateAsync(query);
             var topicListPageResults = await _topicRepository.FindTopicByGroupIdAsync(request);
             foreach (var item in topicListPageResults.Items)
             {