|
@@ -14,10 +14,7 @@ import com.usky.system.mapper.*;
|
|
|
import com.usky.system.service.ISysMenuService;
|
|
|
import com.usky.system.service.SysRoleMenuService;
|
|
|
import com.usky.system.service.SysTenantMenuService;
|
|
|
-import com.usky.system.service.vo.MetaVo;
|
|
|
-import com.usky.system.service.vo.RouterVo;
|
|
|
-import com.usky.system.service.vo.TreeSelect;
|
|
|
-import com.usky.system.service.vo.TreeMobileSelect;
|
|
|
+import com.usky.system.service.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -62,6 +59,9 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
|
|
|
@Autowired
|
|
|
private SysUserMapper sysUserMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysPlatformMapper sysPlatformMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 根据用户查询系统菜单列表
|
|
|
*
|
|
@@ -184,12 +184,38 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
|
|
|
return getChildPerms(menus, 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户ID查询菜单
|
|
|
+ *
|
|
|
+ * @param userId 用户名称
|
|
|
+ * @return 菜单列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SysMenu> selectMenuTreeByUserId1(Long userId,Long platformId)
|
|
|
+ {
|
|
|
+ List<SysMenu> menus = null;
|
|
|
+ if (1L == userId)
|
|
|
+ {
|
|
|
+ menus = menuMapper.selectMenuTreeAll();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menus = menuMapper.selectMenuTreeByUserId1(userId,platformId);
|
|
|
+ }
|
|
|
+ return getChildPerms(menus, 0);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public List<SysMenu> selectMenuTreeByUserIdOne(Integer tenantId){
|
|
|
List<SysMenu> menus = menuMapper.selectMenuTreeByUserIdOne(tenantId);
|
|
|
return getChildPerms(menus, 0);
|
|
|
}
|
|
|
|
|
|
+ public List<SysMenu> selectMenuTreeByUserIdOne1(Integer tenantId,Integer platformId){
|
|
|
+ List<SysMenu> menus = menuMapper.selectMenuTreeByUserIdOne1(tenantId,platformId);
|
|
|
+ return getChildPerms(menus, 0);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<SysTenantMenu> selectTenantMenuList(Integer tenantId){
|
|
|
List<SysTenantMenu> menus = tenantMenuMapper.selectTenantMenuList(tenantId);
|
|
@@ -265,6 +291,142 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
|
|
|
return routers;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构建前端路由所需要的菜单
|
|
|
+ * @return 路由列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PlatformRouterVo> buildPlatformMenus()
|
|
|
+ {
|
|
|
+ List<PlatformRouterVo> platformRouterVos = new LinkedList<PlatformRouterVo>();
|
|
|
+ if (SecurityUtils.getLoginUser().getSysUser().getUserType().equals("01")){
|
|
|
+ List<SysPlatformVo> sysPlatformVos = sysPlatformMapper.getTenantPlatformList(SecurityUtils.getTenantId());
|
|
|
+ if (CollectionUtils.isNotEmpty(sysPlatformVos)){
|
|
|
+ for (SysPlatformVo platformVo : sysPlatformVos)
|
|
|
+ {
|
|
|
+ PlatformRouterVo platformRouterVo = new PlatformRouterVo();
|
|
|
+ platformRouterVo.setPlatformId(platformVo.getId());
|
|
|
+ platformRouterVo.setPlatformName(platformVo.getPlatformName());
|
|
|
+ platformRouterVo.setIcon(platformVo.getIcon());
|
|
|
+ List<SysMenu> menus1 = this.selectMenuTreeByUserIdOne1(SecurityUtils.getTenantId(),
|
|
|
+ platformVo.getId());
|
|
|
+ List<RouterVo> routers = new LinkedList<RouterVo>();
|
|
|
+ for (SysMenu menu : menus1)
|
|
|
+ {
|
|
|
+ RouterVo router = new RouterVo();
|
|
|
+ router.setHidden("1".equals(menu.getVisible()));
|
|
|
+ router.setName(getRouteName(menu));
|
|
|
+ router.setPath(getRouterPath(menu));
|
|
|
+ router.setComponent(getComponent(menu));
|
|
|
+ router.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ List<SysMenu> cMenus = menu.getChildren();
|
|
|
+ if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
|
|
+ {
|
|
|
+ router.setAlwaysShow(true);
|
|
|
+ router.setRedirect("noRedirect");
|
|
|
+ router.setChildren(buildMenus(cMenus));
|
|
|
+ }
|
|
|
+ else if (isMenuFrame(menu))
|
|
|
+ {
|
|
|
+ router.setMeta(null);
|
|
|
+ List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
|
|
+ RouterVo children = new RouterVo();
|
|
|
+ children.setPath(menu.getPath());
|
|
|
+ children.setComponent(menu.getComponent());
|
|
|
+ children.setName(StringUtils.capitalize(menu.getPath()));
|
|
|
+ children.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ childrenList.add(children);
|
|
|
+ router.setChildren(childrenList);
|
|
|
+ }
|
|
|
+ else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
|
|
+ {
|
|
|
+ router.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ router.setPath("/inner");
|
|
|
+ List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
|
|
+ RouterVo children = new RouterVo();
|
|
|
+ String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" });
|
|
|
+ children.setPath(routerPath);
|
|
|
+ children.setComponent(UserConstants.INNER_LINK);
|
|
|
+ children.setName(StringUtils.capitalize(routerPath));
|
|
|
+ children.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), menu.getPath(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ childrenList.add(children);
|
|
|
+ router.setChildren(childrenList);
|
|
|
+ }
|
|
|
+ routers.add(router);
|
|
|
+ }
|
|
|
+ platformRouterVo.setRouterVos(routers);
|
|
|
+ platformRouterVos.add(platformRouterVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ LambdaQueryWrapper<SysUserRole> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.in(SysUserRole::getUserId,SecurityUtils.getUserId());
|
|
|
+ List<SysUserRole> userRoleList = sysUserRoleMapper.selectList(queryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(userRoleList)){
|
|
|
+ List<SysPlatformVo> sysPlatformVos = sysPlatformMapper.getRolePlatformList(SecurityUtils.getTenantId(),
|
|
|
+ userRoleList.get(0).getRoleId().intValue());
|
|
|
+ if (CollectionUtils.isNotEmpty(sysPlatformVos)){
|
|
|
+ for (SysPlatformVo platformVo : sysPlatformVos)
|
|
|
+ {
|
|
|
+ PlatformRouterVo platformRouterVo = new PlatformRouterVo();
|
|
|
+ platformRouterVo.setPlatformId(platformVo.getId());
|
|
|
+ platformRouterVo.setPlatformName(platformVo.getPlatformName());
|
|
|
+ platformRouterVo.setIcon(platformVo.getIcon());
|
|
|
+ List<SysMenu> menus1 = this.selectMenuTreeByUserId1(SecurityUtils.getUserId(),
|
|
|
+ platformVo.getId().longValue());
|
|
|
+ List<RouterVo> routers = new LinkedList<RouterVo>();
|
|
|
+ for (SysMenu menu : menus1)
|
|
|
+ {
|
|
|
+ RouterVo router = new RouterVo();
|
|
|
+ router.setHidden("1".equals(menu.getVisible()));
|
|
|
+ router.setName(getRouteName(menu));
|
|
|
+ router.setPath(getRouterPath(menu));
|
|
|
+ router.setComponent(getComponent(menu));
|
|
|
+ router.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ List<SysMenu> cMenus = menu.getChildren();
|
|
|
+ if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
|
|
+ {
|
|
|
+ router.setAlwaysShow(true);
|
|
|
+ router.setRedirect("noRedirect");
|
|
|
+ router.setChildren(buildMenus(cMenus));
|
|
|
+ }
|
|
|
+ else if (isMenuFrame(menu))
|
|
|
+ {
|
|
|
+ router.setMeta(null);
|
|
|
+ List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
|
|
+ RouterVo children = new RouterVo();
|
|
|
+ children.setPath(menu.getPath());
|
|
|
+ children.setComponent(menu.getComponent());
|
|
|
+ children.setName(StringUtils.capitalize(menu.getPath()));
|
|
|
+ children.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ childrenList.add(children);
|
|
|
+ router.setChildren(childrenList);
|
|
|
+ }
|
|
|
+ else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
|
|
+ {
|
|
|
+ router.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ router.setPath("/inner");
|
|
|
+ List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
|
|
+ RouterVo children = new RouterVo();
|
|
|
+ String routerPath = StringUtils.replaceEach(menu.getPath(), new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" });
|
|
|
+ children.setPath(routerPath);
|
|
|
+ children.setComponent(UserConstants.INNER_LINK);
|
|
|
+ children.setName(StringUtils.capitalize(routerPath));
|
|
|
+ children.setMeta(new MetaVo(menu.getMenuName(), menu.getMenuAliasName(), menu.getIcon(), menu.getPath(), menu.getIsFrame(), menu.getIsNew(), menu.getRemark()));
|
|
|
+ childrenList.add(children);
|
|
|
+ router.setChildren(childrenList);
|
|
|
+ }
|
|
|
+ routers.add(router);
|
|
|
+ }
|
|
|
+ platformRouterVo.setRouterVos(routers);
|
|
|
+ platformRouterVos.add(platformRouterVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return platformRouterVos;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构建前端所需要树结构
|
|
|
*
|
|
@@ -714,4 +876,22 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
|
|
|
{
|
|
|
return getChildMobileList(list, t).size() > 0 ? true : false;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TenantPlatformMenuVo> selectRolePlatformMenu()
|
|
|
+ {
|
|
|
+ List<TenantPlatformMenuVo> list1 = new ArrayList<>();
|
|
|
+ List<SysPlatformVo> list = sysPlatformMapper.getTenantPlatformList(SecurityUtils.getTenantId());
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ TenantPlatformMenuVo tenantPlatformMenuVo = new TenantPlatformMenuVo();
|
|
|
+ tenantPlatformMenuVo.setId(list.get(i).getId());
|
|
|
+ tenantPlatformMenuVo.setLabel(list.get(i).getPlatformName());
|
|
|
+ List<SysMenu> menus = baseMapper.getTenantPlatformMenuList(SecurityUtils.getTenantId(),list.get(i).getId());
|
|
|
+ tenantPlatformMenuVo.setChildren(this.buildMenuTreeSelect(menus));
|
|
|
+ list1.add(tenantPlatformMenuVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list1;
|
|
|
+ }
|
|
|
}
|