java 上下移動資料排序

2021-08-21 18:28:34 字數 1076 閱讀 5194

//向上移動就把上一條資料和本條資料的排序字段交換下

update sys_custom_group as a,

sys_custom_group as b

set a.seq = b.seq,

b.seq = a.seq

where

a.id = '051d11d139794532963beb75f40c0afc' and

exists(select * from (select id from sys_custom_group where seq < 9 and parent_id = '1a83c7ac73c54be8843ffa0b3b5ee550' order by seq desc limit 0,1) r

where r.id = b.id

)

後台只要獲取,要移動的該條資料的id,和其順序seq,我這裡因為是tree形資料結構,所以還有個parentid;

下面看在mybatis裡怎麼寫;

區分flag  isup;  如果是向上移動為true 向下移動為true

update sys_custom_group as a,

sys_custom_group as b

set a.seq = b.seq,

b.seq = a.seq

where

a.id = # and

exists(select * from (select id from sys_custom_group where seq < # and parent_id = # order by seq desc limit 0,1) r

where r.id = b.id

) where

a.id = # and

exists(select * from (select id from sys_custom_group where seq > # and parent_id = # order by seq asc limit 0,1) r

where r.id = b.id

)

datagridview上下移動整行

原位址 方法 上移 下移 刪除 d showprocess是乙個datagridview private void upordownordelete string type if this.d showprocess.currentrow null messagebox.show 請選擇要需要操作的...

js 實現單行資料上下移動

部分 是react.js的寫法,但是js部分大部分都是通用的 html部分 上移下移 js 部分 單行資料上移下移功能,多行的話這個方法也許不管用了。movedata status this.state walistdata是陣列,detailsid是單行資料id 唯一的 for let i 0 a...

C dataGridView上下移動選中行

datagridview 實現行 row 的上下移動,我這裡用到了selectedrows 0 而沒用currentrow是有原因的 主要是這兩段 datagridview1.rows rowindex 1 selected true datagridview1.rows rowindex sele...