码迷,mamicode.com
首页 > 编程语言 > 详细

排序操作

时间:2015-10-16 23:15:09      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

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);
    }

 

排序操作

标签:

原文地址:http://www.cnblogs.com/rubekid/p/4886592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!