李昊 4 years ago
parent
commit
b5bbd57d4c

+ 65 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebGroupController.cs

@@ -0,0 +1,65 @@
+using System.Threading.Tasks;
+using GxPress.Auth;
+using GxPress.Repository.Interface;
+using GxPress.Request.App.Group;
+using GxPress.Request.App.GroupUser;
+using GxPress.Result.App.Group;
+using GxPress.Service.Interface.Group;
+using GxPress.Service.Interface.Topic;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace GxPress.Api.WebControllers
+{
+    /// <summary>
+    /// 导航数据
+    /// </summary>
+    [Route("api/web/group")]
+    [ApiController]
+    [Authorize]
+    public class WebGroupController : Controller
+    {
+
+        private readonly IGroupRepository _groupRepository;
+        private readonly IGroupUserRepository _groupUserRepository;
+        private readonly IGroupFolderRepository _groupFolderRepository;
+        private readonly IGroupService _groupService;
+        private readonly ILoginContext _loginContext;
+        private readonly ITopicRepository _topicRepository;
+        private readonly ITopicService _topicService;
+        public WebGroupController(IGroupRepository groupRepository,
+            IGroupFolderRepository groupFolderRepository, IGroupUserRepository groupUserRepository,
+            ILoginContext loginContext, IGroupService groupService, ITopicRepository topicRepository, ITopicService topicService)
+        {
+            _groupFolderRepository = groupFolderRepository;
+            _groupRepository = groupRepository;
+            _groupUserRepository = groupUserRepository;
+            _loginContext = loginContext;
+            _groupService = groupService;
+            _topicRepository = topicRepository;
+            _topicService = topicService;
+        }
+        /// <summary>
+        /// 新建小组
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPut("insert")]
+        public async Task<GroupDetailResult> Insert(GroupInRequest request)
+        {
+            request.UserId = _loginContext.AccountId;
+            var result = await _groupService.InsertGroup(request);
+            //插入小组用户
+            if (result.Id > 0 && request.UserIds.Count > 0)
+            {
+                var groupUserInRequest = new GroupUserInRequest();
+                groupUserInRequest.UserId = request.UserId;
+                groupUserInRequest.UserIds = request.UserIds;
+                groupUserInRequest.SourceType = 2;
+                groupUserInRequest.GroupId = result.Id;
+                await _groupService.InsertsAsync(groupUserInRequest);
+            }
+            return result;
+        }
+    }
+}

+ 23 - 5
gx_api/GxPress/Model/GxPress.Entity/Group.cs

@@ -14,13 +14,16 @@ namespace GxPress.Entity
         /// </summary>
         [DataColumn]
         public string Name { get; set; }
-
         /// <summary>
-        /// 小组创始人
+        /// 小组创始人Id
         /// </summary>
         [DataColumn]
         public int UserId { get; set; }
-
+        /// <summary>
+        /// 小组创始人
+        /// </summary>
+        [DataColumn]
+        public int UserName { get; set; }
         /// <summary>
         /// 二维码
         /// </summary>
@@ -56,7 +59,22 @@ namespace GxPress.Entity
         /// </summary>
         [DataColumn]
         public bool IsUDisturb { get; set; }
-
-      
+        /// <summary>
+        /// 广场ID
+        /// </summary>
+        [DataColumn]
+        public int GroupCategroyId { get; set; }
+        /// <summary>
+        /// 用户数量
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int UserCount { get; set; }
+        /// <summary>
+        /// 小组文章数量
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int GroupArticleCount { get; set; }
     }
 }

+ 4 - 0
gx_api/GxPress/Model/GxPress.Request/App/Group/GroupInRequest.cs

@@ -63,5 +63,9 @@ namespace GxPress.Request.App.Group
         /// 用户ID
         /// </summary>
         public List<int> UserIds { get; set; }
+         /// <summary>
+        /// 广场ID
+        /// </summary>
+        public int GroupCategroyId { get; set; }
     }
 }

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

@@ -64,7 +64,8 @@ namespace GxPress.Repository.Implement
                 IsUDisturb = false,
                 QRCoder = request.QRCoder,
                 IsWords = false,
-                UserId = request.UserId
+                UserId = request.UserId,
+                GroupCategroyId = request.GroupCategroyId
             };
             if (!string.IsNullOrEmpty(group.AvatarUrl))
                 group.AvatarUrl = StringUtils.RemoveDomain(group.AvatarUrl);