递归删除菜单

This commit is contained in:
zegezy 2024-04-11 20:57:44 +08:00
parent 663ae670cb
commit db267e857c

View File

@ -5,10 +5,10 @@
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "删除",
"createTime" : null,
"updateTime" : 1665500654624,
"updateTime" : 1712806455648,
"lock" : "0",
"createBy" : null,
"updateBy" : "guyi",
"updateBy" : null,
"path" : "/delete",
"method" : "DELETE",
"parameters" : [ {
@ -141,7 +141,17 @@ for(item in userIds){
}
SqlCache.delete('permissions:1')
db.table('sys_role_menu').where().eq("menu_id",id).delete();
var result = db.table("sys_menu").logic().where().eq("id",id).delete();
let recursionDelete = (list) => {
list.forEach(it => {
db.table('sys_role_menu').where().eq("menu_id",it.id).delete();
db.table("sys_menu").logic().where().eq("id",it.id).delete()
let children = db.select("select id from sys_menu where is_del = 0 and pid = #{it.id}")
if(children && children.size() > 0){
recursionDelete(children)
}
})
}
recursionDelete(db.select("select id from sys_menu where is_del = 0 and pid = #{id}"))
return result
db.table('sys_role_menu').where().eq("menu_id",id).delete();
return db.table("sys_menu").logic().where().eq("id",id).delete();