public synchronized void sort(File file, int displayOrder, int parentId){ int max = count(parentId); if(displayOrder > max){ displayOrder = max; } if(file.getDisplayOrder() > displayOrder){ fileDao.batchExecute("update File set displayOrder = displayOrder + 1 where parentId = ? and displayOrder >=? and displayOrder < ?", displayOrder, file.getDisplayOrder()); } else{ fileDao.batchExecute("update File set displayOrder = displayOrder - 1 where parentId = ? and displayOrder >? and displayOrder <= ?", file.getDisplayOrder(), displayOrder); } file.setDisplayOrder(displayOrder); save(file); }
时间: 2024-12-07 06:21:47