这里的currentTypePriority 表示当前移动的排序值
nextTypePriority表示要移动的后一个排序值
比如 1、2、3、4、5
2要移动到5前面 =》1、3、4、2、5
那么这里的
currentTypePriority:2
nextTypePriority:5
if (currentTypePriority > nextTypePriority) { //上移 update( Wrappers.lambdaUpdate(Menu.class) .setSql(" priority=priority+1") .ge(Menu::getPriority, nextTypePriority) .lt(Menu::getPriority, currentTypePriority) ); } else { //下移 update( Wrappers.lambdaUpdate(Menu.class) .setSql(" priority=priority-1") .ge(Menu::getPriority, currentTypePriority) .lt(Menu::getPriority, nextTypePriority) ); nextTypePriority=nextTypePriority-1; } //修改自己 currentType.setPriority(nextTypePriority); updateById(currentType);
标签:JAVA,getPriority,Menu,nextTypePriority,priority,currentTypePriority,下移,列表 From: https://www.cnblogs.com/pxblog/p/17117314.html