|
@@ -9,6 +9,8 @@ import java.util.List;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.ruoyi.system.domain.SysTenantMenu;
|
|
|
+import com.ruoyi.system.mapper.SysTenantMenuMapper;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,6 +28,7 @@ import com.ruoyi.system.mapper.SysMenuMapper;
|
|
|
import com.ruoyi.system.mapper.SysRoleMapper;
|
|
|
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
|
|
import com.ruoyi.system.service.ISysMenuService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
/**
|
|
|
* 菜单 业务层处理
|
|
@@ -49,6 +52,9 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
@Autowired
|
|
|
private SysRoleMenuMapper roleMenuMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysTenantMenuMapper tenantMenuMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 根据用户查询系统菜单列表
|
|
|
*
|
|
@@ -371,6 +377,25 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|
|
return menuMapper.selectMenuByPath(path);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public int insertMenus(SysMenu menu, Long userId) {
|
|
|
+ int i = 0;
|
|
|
+ SysUser user = userService.selectUserById(userId);
|
|
|
+ //管理员添加系统菜单
|
|
|
+ if (SysUser.isAdmin(userId)) {
|
|
|
+ i = menuMapper.insertMenu(menu);
|
|
|
+ } else if (user.isTenantAdmin()) {
|
|
|
+ //租户管理员添加租户菜单
|
|
|
+ menuMapper.insertMenu(menu);
|
|
|
+ SysTenantMenu tenantMenu = new SysTenantMenu();
|
|
|
+ tenantMenu.setTenantId(user.getTenantId());
|
|
|
+ tenantMenu.setMenuId(menu.getMenuId());
|
|
|
+ i = tenantMenuMapper.insertSysTenantMenu(tenantMenu);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取路由名称
|
|
|
*
|