lihao 4 years ago
parent
commit
d1325fd157

+ 14 - 23
gx_api/GxPress/Repository/GxPress.Repository.Implement/MiddleRepository.cs

@@ -146,29 +146,20 @@ namespace GxPress.Repository.Implement
             var databaseType = _databaseTypeStr.ToEnum<DatabaseType>(DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
-            var lastModifiedDate = Convert.ToDateTime(middleSecond.LastModifiedDate).AddTicks(10000000);
-            // 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}";
+            var lastModifiedDate = Convert.ToDateTime(middleSecond.LastModifiedDate);
+            var sql = string.Empty;
+            if (middleFirst.LastModifiedDate < middleSecond.LastModifiedDate)
+            {
+                lastModifiedDate = lastModifiedDate.AddTicks(10000000);
+                sql =
+                $"update tede_middle set LastModifiedDate='{lastModifiedDate.ToString()}' where Id={middleFirst.Id}";
+            }
+            else
+            {
+                lastModifiedDate = lastModifiedDate.AddTicks(-10000000);
+                sql =
+                 $"update tede_middle set LastModifiedDate='{lastModifiedDate.ToString()}' where Id={middleFirst.Id}";
+            }
             return await connection.ExecuteAsync(sql) > 0;
         }
 

+ 3 - 3
gx_api/GxPress/Repository/GxPress.Repository.Implement/Note/NoteRepository.cs

@@ -177,7 +177,7 @@ namespace GxPress.Repository.Implement.Note
                     sqlStr = "a.ParentId";
                 sql =
                    $@"SELECT  a.Id,a.MiddleId,a.RoleId,a.ParentId,a.AttributeValue,a.UserId,
-                      a.CreatedDate,a.IsTop,a.FolderName,a.FolderType,
+                    a.CreatedDate,a.IsTop,a.FolderName,a.FolderType,
                     (SELECT GROUP_CONCAT(SourceName Separator'、') from tede_user_middle where MiddleType={noteTypeId} 
                     and DataSourceId=a.MiddleSonId) as EnjoyUser,
                     (SELECT 
@@ -307,7 +307,7 @@ namespace GxPress.Repository.Implement.Note
                 else
                     sql += $" and a.ParentId={request.FolderId}";
                 sql +=
-                    $@" ORDER BY a.IsSystemDefault desc,a.AttributeValue desc,a.IsTop DESC,a.Sort DESC , a.LastModifiedDate DESC";
+                    $@" ORDER BY a.IsSystemDefault desc,a.AttributeValue desc,a.IsTop DESC, a.LastModifiedDate DESC";
                 if (request.Page > 0)
                     sql += $@" limit {(request.Page - 1) * request.PerPage},{request.PerPage}";
             }
@@ -425,7 +425,7 @@ namespace GxPress.Repository.Implement.Note
                 else
                     sql += $" and a.ParentId={request.FolderId}";
                 sql +=
-                    $@" ORDER BY a.AttributeValue desc,a.IsTop DESC,a.Sort DESC , a.LastModifiedDate DESC";
+                    $@" ORDER BY a.AttributeValue desc,a.IsTop DESC, a.LastModifiedDate DESC";
                 if (request.Page > 0)
                     sql += $@" limit {(request.Page - 1) * request.PerPage},{request.PerPage}";
             }