Commit 2ba4f510 by naan1993

删除菜单可以删除子菜单

parent 8a4d1579
......@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50621
File Encoding : 65001
Date: 2017-06-13 21:58:58
Date: 2017-06-13 22:26:27
*/
SET FOREIGN_KEY_CHECKS=0;
......@@ -164,7 +164,7 @@ INSERT INTO `menu` VALUES ('161', 'login_log_list', 'loginLog', '[0],[system],[l
INSERT INTO `menu` VALUES ('162', 'to_role_edit', 'role', '[0],[system],[role],', '修改角色跳转', '', '/role/role_edit', '5', '3', '0', null, '1', null);
INSERT INTO `menu` VALUES ('163', 'to_role_assign', 'role', '[0],[system],[role],', '角色分配跳转', '', '/role/role_assign', '6', '3', '0', null, '1', null);
INSERT INTO `menu` VALUES ('164', 'role_list', 'role', '[0],[system],[role],', '角色列表', '', '/role/list', '7', '3', '0', null, '1', null);
INSERT INTO `menu` VALUES ('165', 'to_role_assign', 'mgr', '[0],[system],[role],', '分配角色跳转', '', '/mgr/role_assign', '8', '3', '0', null, '1', null);
INSERT INTO `menu` VALUES ('165', 'to_assign_role', 'mgr', '[0],[system],[mgr],', '分配角色跳转', '', '/mgr/role_assign', '8', '3', '0', null, '1', null);
INSERT INTO `menu` VALUES ('166', 'to_user_edit', 'mgr', '[0],[system],[mgr],', '编辑用户跳转', '', '/mgr/user_edit', '9', '3', '0', null, '1', null);
INSERT INTO `menu` VALUES ('167', 'mgr_list', 'mgr', '[0],[system],[mgr],', '用户列表', '', '/mgr/list', '10', '3', '0', null, '1', null);
......
......@@ -163,7 +163,7 @@ public class MenuController extends BaseController {
//缓存菜单的名称
LogObjectHolder.me().set(ConstantFactory.me().getMenuName(menuId));
this.menuService.delMenu(menuId);
this.menuService.delMenuContainSubMenus(menuId);
return SUCCESS_TIP;
}
......
......@@ -4,7 +4,7 @@
<sql id="Base_Column_List">
id, code, pcode, name, icon, url, num, levels,
id, code, pcode, name, icon, url, num, levels,pcodes,
tips, status,isopen,ismenu
</sql>
......
......@@ -15,4 +15,12 @@ public interface IMenuService {
* @Date 2017/5/5 22:20
*/
void delMenu(Integer menuId);
/**
* 删除菜单包含所有子菜单
*
* @author stylefeng
* @Date 2017/6/13 22:02
*/
void delMenuContainSubMenus(Integer menuId);
}
package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.common.persistence.model.Menu;
import com.stylefeng.guns.modular.system.dao.MenuDao;
import com.stylefeng.guns.modular.system.service.IMenuService;
import com.stylefeng.guns.common.persistence.dao.MenuMapper;
import com.sun.xml.internal.bind.v2.ContextFactory;
import net.sf.ehcache.util.MergedEnumeration;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 菜单服务
......@@ -31,4 +38,21 @@ public class MenuServiceImpl implements IMenuService {
//删除关联的relation
this.menuDao.deleteRelationByMenu(menuId);
}
@Override
public void delMenuContainSubMenus(Integer menuId) {
Menu menu = menuMapper.selectById(menuId);
//删除当前菜单
delMenu(menuId);
//删除所有子菜单
Wrapper<Menu> wrapper = new EntityWrapper<>();
wrapper = wrapper.like("pcodes", "%[" + menu.getCode() + "]%");
List<Menu> menus = menuMapper.selectList(wrapper);
for (Menu temp : menus) {
delMenu(temp.getId());
}
}
}
......@@ -9,7 +9,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;
......@@ -22,7 +21,7 @@ import org.springframework.web.context.WebApplicationContext;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = GunsApplication.class)
@WebAppConfiguration
@Transactional //测试之后数据可回滚
//@Transactional //打开的话测试之后数据可自动回滚
public class BaseJunit {
@Autowired
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment