lihao 4 years ago
parent
commit
d3fe068f41

+ 11 - 7
gx_api/GxPress/Model/GxPress.Result/App/Topic/TopicDetailResult.cs

@@ -11,7 +11,7 @@ namespace GxPress.Result.App.Topic
     public class TopicDetailResult
     {
         /// <summary>
-        /// 通知ID
+        /// 话题ID
         /// </summary>
         public int Id { get; set; }
 
@@ -30,23 +30,17 @@ namespace GxPress.Result.App.Topic
         /// <summary>
         /// 内容
         /// </summary>
-
         public string Content { get; set; }
         /// <summary>
         /// 内容
         /// </summary>
-
         public string HtmlContent { get; set; }
 
         /// <summary>
         /// 用户名
         /// </summary>
-
         public string UserName { get; set; }
 
-
-
-
         /// <summary>
         /// 阅读量
         /// </summary>
@@ -105,5 +99,15 @@ namespace GxPress.Result.App.Topic
         /// </summary>
         /// <value></value>
         public string AvatarUrl { get; set; }
+        /// <summary>
+        /// 小组ID
+        /// </summary>
+        /// <value></value>
+        public int GroupId { get; set; }
+        /// <summary>
+        /// 小组名称
+        /// </summary>
+        /// <value></value>
+        public string GroupName { get; set; }
     }
 }

+ 10 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Topic/TopicService.Detail.cs

@@ -24,7 +24,16 @@ namespace GxPress.Service.Implement.Topic
             if (topic == null)
                 throw new BusinessException("话题不存在");
             var result = _mapper.Map<TopicDetailResult>(topic);
-
+            //获取小组信息
+            if (topic.GroupId > 0)
+            {
+                var group = await groupRepository.GetAsync(topic.GroupId);
+                if (group != null)
+                {
+                    result.GroupName = group.Name;
+                    result.GroupId = group.Id;
+                }
+            }
             if (string.IsNullOrWhiteSpace(result.Content))
                 result.Content = "[]";
             var contentJsonData = JsonConvert.DeserializeObject<List<ContentJsonData>>(result.Content);

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

@@ -46,13 +46,18 @@ namespace GxPress.Service.Implement.Topic
         private readonly IVisitRepository _visitRepository;
         private readonly IVisitService _visitService;
         private readonly INoteRepository noteRepository;
+        private readonly IGroupRepository groupRepository;
         public TopicService(ITopicRepository topicRepository, IUserRepository userRepository,
             ITopicAddresseeRepository topicAddresseeRepository,
             ITopicGroupRepository topicGroupRepository,
             ITopicGroupUserRepository topicGroupUserRepository, IAnalyzeService analyzeService,
             ICommentRepository commentRepository, IMapper mapper, IDepartmentRepository departmentRepository,
             IGroupUserRepository groupUserRepository, IFolderUserRepository folderUserRepository,
-            INoteService noteService, IMiddleRepository middleRepository, IVisitRepository visitRepository, IVisitService visitService, IDepartmentUserRepository departmentUserRepository, INoteRepository noteRepository)
+            INoteService noteService, IMiddleRepository middleRepository, 
+            IVisitRepository visitRepository, IVisitService visitService, 
+            IDepartmentUserRepository departmentUserRepository, 
+            INoteRepository noteRepository,
+            IGroupRepository groupRepository)
         {
             _topicRepository = topicRepository;
             _userRepository = userRepository;
@@ -71,6 +76,7 @@ namespace GxPress.Service.Implement.Topic
             _visitService = visitService;
             this.departmentUserRepository = departmentUserRepository;
             this.noteRepository = noteRepository;
+            this.groupRepository=groupRepository;
         }