lihao 4 年 前
コミット
cc15f965e3

+ 24 - 21
gx_api/GxPress/Repository/GxPress.Repository.Implement/MiddleRepository.cs

@@ -146,27 +146,30 @@ namespace GxPress.Repository.Implement
             var databaseType = _databaseTypeStr.ToEnum<DatabaseType>(DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
-            var lastModifiedDate = DateTime.Now.ToString();
-            if (middleFirst.Sort < middleSecond.Sort)
-            {
-                //修改第一个排序
-                await _repository.UpdateAsync(Q.Set(nameof(Middle.Sort), middleSecond.Sort)
-                    .Where(nameof(Middle.Id), request.MiddleIdFirst));
-                int sort = middleSecond.Sort;
-                var sql =
-                    $"update tede_middle set Sort=Sort-1,LastModifiedDate='{lastModifiedDate}' where UserId={middleFirst.UserId} and FolderType={middleFirst.FolderType} and Sort<={sort} and Id not in({middleFirst.Id}) and id>0";
-                return await connection.ExecuteAsync(sql) > 0;
-            }
-            else
-            {
-                //修改第一个排序
-                await _repository.UpdateAsync(Q.Set(nameof(Middle.Sort), middleSecond.Sort)
-                    .Where(nameof(Middle.Id), request.MiddleIdFirst));
-                int sort = middleSecond.Sort;
-                var sql =
-                    $"update tede_middle set Sort=Sort+1,LastModifiedDate='{lastModifiedDate}' where UserId={middleFirst.UserId} and FolderType={middleFirst.FolderType} and Sort>={sort} and Id not in({middleFirst.Id}) and id>0";
-                return await connection.ExecuteAsync(sql) > 0;
-            }
+            var lastModifiedDate = Convert.ToDateTime(middleSecond.LastModifiedDate).AddTicks(1);
+            // if (middleFirst.Sort < middleSecond.Sort)
+            // {
+            //     //修改第一个排序
+            //     await _repository.UpdateAsync(Q.Set(nameof(Middle.Sort), middleSecond.Sort)
+            //         .Where(nameof(Middle.Id), request.MiddleIdFirst));
+            //     int sort = middleSecond.Sort;
+            //     var sql =
+            //         $"update tede_middle set Sort=Sort-1,LastModifiedDate='{lastModifiedDate}' where UserId={middleFirst.UserId} and FolderType={middleFirst.FolderType} and Sort<={sort} and Id not in({middleFirst.Id}) and id>0";
+            //     return await connection.ExecuteAsync(sql) > 0;
+            // }
+            // else
+            // {
+            //     //修改第一个排序
+            //     await _repository.UpdateAsync(Q.Set(nameof(Middle.Sort), middleSecond.Sort)
+            //         .Where(nameof(Middle.Id), request.MiddleIdFirst));
+            //     int sort = middleSecond.Sort;
+            //     var sql =
+            //         $"update tede_middle set Sort=Sort+1,LastModifiedDate='{lastModifiedDate}' where UserId={middleFirst.UserId} and FolderType={middleFirst.FolderType} and Sort>={sort} and Id not in({middleFirst.Id}) and id>0";
+            //     return await connection.ExecuteAsync(sql) > 0;
+            // }
+            var sql =
+                   $"update tede_middle set LastModifiedDate='{lastModifiedDate.ToString()}' where Id={middleFirst.Id}";
+            return await connection.ExecuteAsync(sql) > 0;
         }
 
         /// <summary>

+ 2 - 2
gx_api/GxPress/Service/GxPress.Service.Implement/Notice/NoticeService.cs

@@ -408,11 +408,11 @@ namespace GxPress.Service.Implement.Notice
             query = commonSqlKataService.NoticeQueryAsync(query, request.UserId);
             //通用
             query = commonSqlKataService.GetCommonQueryAsync(noticeTypeValue, request.UserId, query);
-
+            
             query.OrderByDesc("tede_middle.AttributeValue");
             query.OrderByDesc("tede_middle.IsTop");
             query.OrderByDesc("tede_middle.LastModifiedDate");
-            query.OrderByDesc("tede_middle.Sort");
+            //query.OrderByDesc("tede_middle.Sort");
             query.ForPage(request.Page, request.PerPage);
             query.Select(
                   "tede_middle.Id", "tede_middle.MiddleId", "tede_middle.IsTop", "tede_middle.AttributeValue", "tede_middle.FolderName", "tede_middle.CreatedDate"