|
@@ -9,8 +9,6 @@ import cn.hnthyy.thmz.service.his.mz.EmployeeService;
|
|
|
import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
|
|
|
import cn.hnthyy.thmz.service.thmz.*;
|
|
|
import cn.hnthyy.thmz.vo.MenuVo;
|
|
|
-import cn.hnthyy.thmz.vo.RoleMenuRelationVo;
|
|
|
-import cn.hnthyy.thmz.vo.RoleMenuVo;
|
|
|
import cn.hnthyy.thmz.vo.UserMenuRelationVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -38,6 +36,8 @@ public class MenuController {
|
|
|
private EmployeeService employeeService;
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
+ @Autowired
|
|
|
+ private RoleService roleService;
|
|
|
|
|
|
/**
|
|
|
* 获取所有的父菜单
|
|
@@ -514,5 +514,48 @@ public class MenuController {
|
|
|
nodesMap.put(zd.getCode().trim(), tempParent);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除菜单
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @UserLoginToken
|
|
|
+ @RequestMapping(value = "/deleteMenu", method = {RequestMethod.GET})
|
|
|
+ public Map<String, Object> deleteMenu(@RequestParam Long id) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ try {
|
|
|
+ //判断是否含有子菜单、角色关联菜单数据
|
|
|
+ List<Menu> menus = menuService.queryByParentId(id);
|
|
|
+ if (menus.size() > 0) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "该菜单含有子菜单,禁止删除");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ List<RoleMenuRelation> roleMenuRelations = roleMenuRelationService.queryByMenuId(id);
|
|
|
+ for (int i = 0; i < roleMenuRelations.size(); i++) {
|
|
|
+ Role role = roleService.queryById(roleMenuRelations.get(i).getRoleId());
|
|
|
+ if(role.getDelFlag() == 1){//判断菜单关联的角色是否有效
|
|
|
+ roleMenuRelations.remove(i);
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (roleMenuRelations.size() > 0) {
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "该菜单已与角色权限关联,禁止删除");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ menuService.removeById(id);
|
|
|
+ resultMap.put("code", 0);
|
|
|
+ resultMap.put("message", "删除菜单成功");
|
|
|
|
|
|
+ return resultMap;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("查询角色失败,错误信息{}", e.getMessage());
|
|
|
+ resultMap.put("code", -1);
|
|
|
+ resultMap.put("message", "删除角色失败");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|