lihao 4 years ago
parent
commit
0d5c4ce1d3

+ 2 - 1
gx_api/GxPress/Api/GxPress.Api/AppControllers/GroupController.cs

@@ -7,6 +7,7 @@ using GxPress.Repository.Interface.Group;
 using GxPress.Request.App.Group;
 using GxPress.Request.App.GroupUser;
 using GxPress.Request.App.Topic;
+using GxPress.Result;
 using GxPress.Result.App.Group;
 using GxPress.Result.App.GroupUser;
 using GxPress.Result.App.Topic;
@@ -80,7 +81,7 @@ namespace GxPress.Api.AppControllers
         /// <param name="request"></param>
         /// <returns></returns>
         [HttpPost("insert-user")]
-        public async Task<bool> AddGroupUser(GroupUserInRequest request)
+        public async Task<AppResult> AddGroupUser(GroupUserInRequest request)
         {
             request.UserId = _loginContext.AccountId;
             return await _groupService.InsertsAsync(request);

+ 2 - 1
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebGroupController.cs

@@ -7,6 +7,7 @@ using GxPress.Repository.Interface.Group;
 using GxPress.Request.App.Group;
 using GxPress.Request.App.GroupUser;
 using GxPress.Request.App.Topic;
+using GxPress.Result;
 using GxPress.Result.App.Group;
 using GxPress.Result.App.GroupUser;
 using GxPress.Result.App.Topic;
@@ -113,7 +114,7 @@ namespace GxPress.Api.WebControllers
         /// <param name="request"></param>
         /// <returns></returns>
         [HttpPost("insert-user")]
-        public async Task<bool> AddGroupUser(GroupUserInRequest request)
+        public async Task<AppResult> AddGroupUser(GroupUserInRequest request)
         {
             request.UserId = _loginContext.AccountId;
             return await _groupService.InsertsAsync(request);

+ 5 - 0
gx_api/GxPress/Model/GxPress.Result/AppResult.cs

@@ -17,5 +17,10 @@ namespace GxPress.Result
         /// 消息
         /// </summary>
         public string Msg { get; set; }
+        /// <summary>
+        /// 是否成功
+        /// </summary>
+        /// <value></value>
+        public bool Success { get; set; }
     }
 }

+ 15 - 5
gx_api/GxPress/Service/GxPress.Service.Implement/Group/GroupService.cs

@@ -22,6 +22,8 @@ using GxPress.Service.Interface.AdminVerify;
 using GxPress.Service.Interface.Group;
 using GxPress.Service.Interface.Middle;
 using GxPress.Repository.Interface.Group;
+using GxPress.Result;
+
 namespace GxPress.Service.Implement.Group
 {
     public partial class GroupService : IGroupService
@@ -138,8 +140,14 @@ namespace GxPress.Service.Implement.Group
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-        public async Task<bool> InsertsAsync(GroupUserInRequest request)
+        public async Task<AppResult> InsertsAsync(GroupUserInRequest request)
         {
+            var result = new AppResult()
+            {
+                Code = 200,
+                Success = true,
+                Msg = ""
+            };
             request.UserIds = request.UserIds.Distinct().ToList();
             //获取当前小组
             var group = await _groupRepository.GetAsync(request.GroupId);
@@ -157,19 +165,21 @@ namespace GxPress.Service.Implement.Group
                 };
                 await _adminVerifyService.InsertAsync(adminVerifyInsertRequest);
                 if (request.SourceType == 2)
-                    throw new BusinessException("等待用户同意同意");
+                    result.Msg = "等待用户同意同意";
                 if (request.SourceType == 1)
-                    throw new BusinessException("等待管理员同意");
+                    result.Msg = "等待管理员同意";
+                result.Code = 201;
+                result.Success = true;
             }
 
             if (!group.IsAdmin && request.SourceType == 1)
             {
                 //管理员插入
                 await AddUsersAsync(request);
-                return true;
+                return result;
             }
 
-            return true;
+            return result;
         }
 
         /// <summary>

+ 2 - 1
gx_api/GxPress/Service/GxPress.Service.Interface/Group/IGroupService.cs

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
 using GxPress.Common.Page;
 using GxPress.Request.App.Group;
 using GxPress.Request.App.GroupUser;
+using GxPress.Result;
 using GxPress.Result.App.Group;
 using GxPress.Result.App.GroupUser;
 
@@ -15,7 +16,7 @@ namespace GxPress.Service.Interface.Group
         Task<GroupDetailResult> InsertGroup(GroupInRequest request);
         Task<PagedList<GroupUserFindResult>> FindGroupByGroupFolderIdAsync(GroupSearchRequest request);
 
-        Task<bool> InsertsAsync(GroupUserInRequest request);
+        Task<AppResult> InsertsAsync(GroupUserInRequest request);
 
         /// <summary>
         /// 小组添加用户