for(int i=0;i<list.size();i++){
if(list.get(i).getId().equals(goodsId)){
if(type==0 && i>0){
nextSort = list.get(i-1).getSort();
nextGoodsId = list.get(i-1).getId();
}
else{
nextSort = list.get(i+1).getSort();
nextGoodsId = list.get(i+1).getId();
}
hostSort = list.get(i).getSort();
}
}
互换排序
@Update({"<script>"+"update goods set sort = sort " +
"<if test='type == 0'> - </if> " +
"<if test='type == 1'> + </if> " +
"1 where " +
"<if test='type == 0'> sort <= #{newSort} and sort > #{oldSort} </if>" +
"<if test='type == 1'> sort >= #{newSort} and sort < #{oldSort} </if>"
+"</script>"})
public boolean insertSort(@Param("newSort") Integer newSort,@Param("oldSort") Integer oldSort,@Param("type") Integer type,@Param("condition")String condition);
插入排序