李昊 4 years ago
parent
commit
8cb07fc717

+ 2 - 2
gx_api/GxPress/Api/GxPress.Api/AppControllers/MiddleController.cs

@@ -48,7 +48,7 @@ namespace GxPress.Api.AppControllers
         /// <param name="request"></param>
         /// <param name="request"></param>
         /// <returns></returns>
         /// <returns></returns>
         [HttpPut("add-folder")]
         [HttpPut("add-folder")]
-        public async Task<bool> Insert(NoticeFolderInRequest request)
+        public async Task<MiddleInResult> Insert(NoticeFolderInRequest request)
         {
         {
             request.UserId = _loginContext.AccountId;
             request.UserId = _loginContext.AccountId;
             var middleInsertRequest = new MiddleInsertRequest
             var middleInsertRequest = new MiddleInsertRequest
@@ -61,7 +61,7 @@ namespace GxPress.Api.AppControllers
                 UserIds = request.UserIds,
                 UserIds = request.UserIds,
                 UserMiddles = request.UserMiddles
                 UserMiddles = request.UserMiddles
             };
             };
-            return await _middleService.InsertAsync(middleInsertRequest) > 0;
+            return await _middleService.InsertAsync(middleInsertRequest);
 
 
         }
         }
         /// <summary>
         /// <summary>

+ 2 - 2
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebMiddleController.cs

@@ -48,7 +48,7 @@ namespace GxPress.Api.WebControllers
         /// <param name="request"></param>
         /// <param name="request"></param>
         /// <returns></returns>
         /// <returns></returns>
         [HttpPut("add-folder")]
         [HttpPut("add-folder")]
-        public async Task<bool> Insert(NoticeFolderInRequest request)
+        public async Task<MiddleInResult> Insert(NoticeFolderInRequest request)
         {
         {
             request.UserId = _loginContext.AccountId;
             request.UserId = _loginContext.AccountId;
             var middleInsertRequest = new MiddleInsertRequest
             var middleInsertRequest = new MiddleInsertRequest
@@ -61,7 +61,7 @@ namespace GxPress.Api.WebControllers
                 UserIds = request.UserIds,
                 UserIds = request.UserIds,
                 UserMiddles = request.UserMiddles
                 UserMiddles = request.UserMiddles
             };
             };
-            return await _middleService.InsertAsync(middleInsertRequest) > 0;
+            return await _middleService.InsertAsync(middleInsertRequest);
 
 
         }
         }
         /// <summary>
         /// <summary>

+ 9 - 0
gx_api/GxPress/Model/GxPress.Result/App/Middle/Middle.cs

@@ -87,4 +87,13 @@ namespace GxPress.Result.App.Middle
         /// <value></value>
         /// <value></value>
         public string EnjoyUser { get; set; }
         public string EnjoyUser { get; set; }
     }
     }
+    /// <summary>
+    /// 添加文件夹返回
+    /// </summary>
+    public class MiddleInResult
+    {
+        public int Id { get; set; }
+
+        public string Name { get; set; }
+    }
 }
 }

+ 13 - 5
gx_api/GxPress/Repository/GxPress.Repository.Implement/UserRepository.cs

@@ -986,7 +986,7 @@ namespace GxPress.Repository.Implement
             foreach (var item in userIds)
             foreach (var item in userIds)
                 sqlStr += $"{item},";
                 sqlStr += $"{item},";
             sqlStr = sqlStr.Remove(sqlStr.Length - 1, 1);
             sqlStr = sqlStr.Remove(sqlStr.Length - 1, 1);
-            var sql = $@"select * from tede_user where id  in({sqlStr})";
+            var sql = $@"select * from tede_user where id in({sqlStr})";
             if (!string.IsNullOrEmpty(keyWord))
             if (!string.IsNullOrEmpty(keyWord))
                 sql += $@" and (Name like '%{keyWord}%' or phone like '%{keyWord}%' or Email like '%{keyWord}%')";
                 sql += $@" and (Name like '%{keyWord}%' or phone like '%{keyWord}%' or Email like '%{keyWord}%')";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
@@ -1009,8 +1009,12 @@ namespace GxPress.Repository.Implement
             var sqlStr = "";
             var sqlStr = "";
             foreach (var item in userIds)
             foreach (var item in userIds)
                 sqlStr += $"{item},";
                 sqlStr += $"{item},";
-            sqlStr = sqlStr.Remove(sqlStr.Length - 1, 1);
-            var sql = $@"select * from tede_user where id not in({sqlStr}) and (Name like '%{keyword}%' or phone like '%{keyword}%' or Email like '%{keyword}%')";
+            sqlStr = !string.IsNullOrEmpty(sqlStr) ? sqlStr.Remove(sqlStr.Length - 1, 1) : "";
+            var sql = $@"select * from tede_user where 1=1 ";
+            if (!string.IsNullOrEmpty(sqlStr))
+                sql += " and id not in({sqlStr})";
+            if (!string.IsNullOrEmpty(keyword))
+                sql += $@" and (Name like '%{keyword}%' or phone like '%{keyword}%' or Email like '%{keyword}%')";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
             var connection = database.GetConnection();
@@ -1032,8 +1036,12 @@ namespace GxPress.Repository.Implement
             var sqlStr = "";
             var sqlStr = "";
             foreach (var item in userIds)
             foreach (var item in userIds)
                 sqlStr += $"{item},";
                 sqlStr += $"{item},";
-            sqlStr = sqlStr.Remove(sqlStr.Length - 1, 1);
-            var sql = $@"select * from tede_user where id in({sqlStr}) and (Name like '%{keyword}%' or phone like '%{keyword}%' or Email like '%{keyword}%')";
+            sqlStr = string.IsNullOrEmpty(sqlStr) ? "" : sqlStr.Remove(sqlStr.Length - 1, 1);
+            var sql = $@"select * from tede_user where 1=1 ";
+            if (!string.IsNullOrEmpty(sqlStr))
+                sql += " and id in({sqlStr})";
+            if (!string.IsNullOrEmpty(keyword))
+                sql += " and (Name like '%{keyword}%' or phone like '%{keyword}%' or Email like '%{keyword}%')";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
             var connection = database.GetConnection();

+ 7 - 2
gx_api/GxPress/Service/GxPress.Service.Implement/Middle/MiddleService.cs

@@ -66,7 +66,7 @@ namespace GxPress.Service.Implement.Middle
         /// </summary>
         /// </summary>
         /// <param name="request"></param>
         /// <param name="request"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public async Task<int> InsertAsync(MiddleInsertRequest request)
+        public async Task<MiddleInResult> InsertAsync(MiddleInsertRequest request)
         {
         {
             var folderRoleId = new List<int> { 1, 2, 3 };
             var folderRoleId = new List<int> { 1, 2, 3 };
             if (!folderRoleId.Contains(request.RoleId) && (request.FolderType == 3 || request.FolderType == 4))
             if (!folderRoleId.Contains(request.RoleId) && (request.FolderType == 3 || request.FolderType == 4))
@@ -134,7 +134,12 @@ namespace GxPress.Service.Implement.Middle
             if (request.RoleId == 3 && request.ParentId == 0)
             if (request.RoleId == 3 && request.ParentId == 0)
                 //添加人员
                 //添加人员
                 await InsertFolderUsers(request, middleId);
                 await InsertFolderUsers(request, middleId);
-            return middleId;
+            var result = new MiddleInResult()
+            {
+                Id = middleId,
+                Name = request.FolderName
+            };
+            return result;
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 1 - 1
gx_api/GxPress/Service/GxPress.Service.Interface/Middle/IMiddleService.cs

@@ -16,7 +16,7 @@ namespace GxPress.Service.Interface.Middle
         /// </summary>
         /// </summary>
         /// <param name="request"></param>
         /// <param name="request"></param>
         /// <returns></returns>
         /// <returns></returns>
-        Task<int> InsertAsync(MiddleInsertRequest request);
+        Task<MiddleInResult> InsertAsync(MiddleInsertRequest request);
 
 
         /// <summary>
         /// <summary>
         /// 修改文件夹名称
         /// 修改文件夹名称