Sfoglia il codice sorgente

Merge branch 'fu-dev' of uskycloud/usky-cloud into master

gez 1 settimana fa
parent
commit
86256b2ae0

+ 22 - 15
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/domain/SysUserRole.java

@@ -5,42 +5,49 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 用户和角色关联 sys_user_role
- * 
+ *
  * @author yq
  */
-public class SysUserRole
-{
+public class SysUserRole {
     /** 用户ID */
     private Long userId;
-    
+
     /** 角色ID */
     private Long roleId;
 
-    public Long getUserId()
-    {
+    /** 租户ID */
+    private Integer tenantId;
+
+    public Long getUserId() {
         return userId;
     }
 
-    public void setUserId(Long userId)
-    {
+    public void setUserId(Long userId) {
         this.userId = userId;
     }
 
-    public Long getRoleId()
-    {
+    public Long getRoleId() {
         return roleId;
     }
 
-    public void setRoleId(Long roleId)
-    {
+    public void setRoleId(Long roleId) {
         this.roleId = roleId;
     }
 
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-            .append("userId", getUserId())
-            .append("roleId", getRoleId())
-            .toString();
+                .append("userId", getUserId())
+                .append("roleId", getRoleId())
+                .append("tenantId", getTenantId())
+                .toString();
     }
 }

+ 137 - 230
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysMenuServiceImpl.java

@@ -28,8 +28,7 @@ import java.util.stream.Collectors;
  * @author yq
  */
 @Service
-public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMenu> implements ISysMenuService
-{
+public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMenu> implements ISysMenuService {
     public static final String PREMISSION_STRING = "perms[\"{0}\"]";
 
     @Autowired
@@ -69,8 +68,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 菜单列表
      */
     @Override
-    public List<SysMenu> selectMenuList(Long userId)
-    {
+    public List<SysMenu> selectMenuList(Long userId) {
         return selectMenuList(new SysMenu(), userId);
     }
 
@@ -81,16 +79,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 菜单列表
      */
     @Override
-    public List<SysMenu> selectMenuList(SysMenu menu, Long userId)
-    {
+    public List<SysMenu> selectMenuList(SysMenu menu, Long userId) {
         List<SysMenu> menuList = null;
         // 管理员显示所有菜单信息
-        if (SysUserVO.isAdmin(userId))
-        {
+        if (SysUserVO.isAdmin(userId)) {
             menuList = menuMapper.selectMenuList(menu);
-        }
-        else
-        {
+        } else {
             menu.getParams().put("userId", userId);
             menuList = menuMapper.selectMenuListByUserId(menu);
         }
@@ -98,24 +92,21 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
     }
 
     @Override
-    public List<SysMenu> selectMenuListTwo(SysMenu menu)
-    {
-        List<SysMenu> menuList = menuMapper.selectMenuListOne(SecurityUtils.getTenantId(),menu.getMenuName());
+    public List<SysMenu> selectMenuListTwo(SysMenu menu) {
+        List<SysMenu> menuList = menuMapper.selectMenuListOne(SecurityUtils.getTenantId(), menu.getMenuName());
         return menuList;
     }
 
 
     @Override
-    public List<SysMenu> selectMenuListOne(Long userId)
-    {
+    public List<SysMenu> selectMenuListOne(Long userId) {
         List<SysMenu> menuList = menuMapper.selectMenuListByUserIdOne(userId);
         return menuList;
     }
 
 
     @Override
-    public List<SysMobileMenu> selectMobileMenuListOne(Long userId)
-    {
+    public List<SysMobileMenu> selectMobileMenuListOne(Long userId) {
         List<SysMobileMenu> menuList = menuMapper.selectMobileMenuListByUserIdOne(userId);
         return menuList;
     }
@@ -127,14 +118,11 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 权限列表
      */
     @Override
-    public Set<String> selectMenuPermsByUserId(Long userId)
-    {
+    public Set<String> selectMenuPermsByUserId(Long userId) {
         List<String> perms = menuMapper.selectMenuPermsByUserId(userId);
         Set<String> permsSet = new HashSet<>();
-        for (String perm : perms)
-        {
-            if (StringUtils.isNotEmpty(perm))
-            {
+        for (String perm : perms) {
+            if (StringUtils.isNotEmpty(perm)) {
                 permsSet.addAll(Arrays.asList(perm.trim().split(",")));
             }
         }
@@ -148,14 +136,11 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 权限列表
      */
     @Override
-    public Set<String> selectMenuPermsByUserIdOne(Integer tenantId)
-    {
+    public Set<String> selectMenuPermsByUserIdOne(Integer tenantId) {
         List<String> perms = menuMapper.selectMenuPermsByUserIdOne(tenantId);
         Set<String> permsSet = new HashSet<>();
-        for (String perm : perms)
-        {
-            if (StringUtils.isNotEmpty(perm))
-            {
+        for (String perm : perms) {
+            if (StringUtils.isNotEmpty(perm)) {
                 permsSet.addAll(Arrays.asList(perm.trim().split(",")));
             }
         }
@@ -170,15 +155,11 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 菜单列表
      */
     @Override
-    public List<SysMenu> selectMenuTreeByUserId(Long userId)
-    {
+    public List<SysMenu> selectMenuTreeByUserId(Long userId) {
         List<SysMenu> menus = null;
-        if (1L == userId)
-        {
+        if (1L == userId) {
             menus = menuMapper.selectMenuTreeAll();
-        }
-        else
-        {
+        } else {
             menus = menuMapper.selectMenuTreeByUserId(userId);
         }
         return getChildPerms(menus, 0);
@@ -191,33 +172,29 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 菜单列表
      */
     @Override
-    public List<SysMenu> selectMenuTreeByUserId1(Long userId,Long platformId)
-    {
+    public List<SysMenu> selectMenuTreeByUserId1(Long userId, Long platformId) {
         List<SysMenu> menus = null;
-        if (1L == userId)
-        {
+        if (1L == userId) {
             menus = menuMapper.selectMenuTreeAll();
-        }
-        else
-        {
-            menus = menuMapper.selectMenuTreeByUserId1(userId,platformId);
+        } else {
+            menus = menuMapper.selectMenuTreeByUserId1(userId, platformId);
         }
         return getChildPerms(menus, 0);
     }
 
 
-    public List<SysMenu> selectMenuTreeByUserIdOne(Integer tenantId){
+    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);
+    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){
+    public List<SysTenantMenu> selectTenantMenuList(Integer tenantId) {
         List<SysTenantMenu> menus = tenantMenuMapper.selectTenantMenuList(tenantId);
         return menus;
     }
@@ -229,8 +206,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 选中菜单列表
      */
     @Override
-    public List<Integer> selectMenuListByRoleId(Long roleId)
-    {
+    public List<Integer> selectMenuListByRoleId(Long roleId) {
         SysRole role = roleMapper.selectRoleById(roleId);
         return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
     }
@@ -242,11 +218,9 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 路由列表
      */
     @Override
-    public List<RouterVo> buildMenus(List<SysMenu> menus)
-    {
+    public List<RouterVo> buildMenus(List<SysMenu> menus) {
         List<RouterVo> routers = new LinkedList<RouterVo>();
-        for (SysMenu menu : menus)
-        {
+        for (SysMenu menu : menus) {
             RouterVo router = new RouterVo();
             router.setHidden("1".equals(menu.getVisible()));
             router.setName(getRouteName(menu));
@@ -254,14 +228,11 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
             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()))
-            {
+            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))
-            {
+            } else if (isMenuFrame(menu)) {
                 router.setMeta(null);
                 List<RouterVo> childrenList = new ArrayList<RouterVo>();
                 RouterVo children = new RouterVo();
@@ -271,14 +242,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
                 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))
-            {
+            } 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[] { "", "" });
+                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));
@@ -296,23 +265,23 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 路由列表
      */
     @Override
-    public List<PlatformRouterVo> buildPlatformMenus()
-    {
+    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)
-                {
+        Long userId = SecurityUtils.getUserId();
+        Integer tenantId = SecurityUtils.getTenantId();
+        String userType = SecurityUtils.getLoginUser().getSysUser().getUserType();
+        if ("01".equals(userType)) {
+            List<SysPlatformVo> sysPlatformVos = sysPlatformMapper.getTenantPlatformList(tenantId);
+            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(),
+                    List<SysMenu> menus1 = this.selectMenuTreeByUserIdOne1(tenantId,
                             platformVo.getId());
                     List<RouterVo> routers = new LinkedList<RouterVo>();
-                    for (SysMenu menu : menus1)
-                    {
+                    for (SysMenu menu : menus1) {
                         RouterVo router = new RouterVo();
                         router.setHidden("1".equals(menu.getVisible()));
                         router.setName(getRouteName(menu));
@@ -320,14 +289,11 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
                         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()))
-                        {
+                        if (!cMenus.isEmpty() && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
                             router.setAlwaysShow(true);
                             router.setRedirect("noRedirect");
                             router.setChildren(buildMenus(cMenus));
-                        }
-                        else if (isMenuFrame(menu))
-                        {
+                        } else if (isMenuFrame(menu)) {
                             router.setMeta(null);
                             List<RouterVo> childrenList = new ArrayList<RouterVo>();
                             RouterVo children = new RouterVo();
@@ -337,14 +303,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
                             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))
-                        {
+                        } 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[] { "", "" });
+                            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));
@@ -358,25 +322,27 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
                     platformRouterVos.add(platformRouterVo);
                 }
             }
-        }else {
+        } else {
             LambdaQueryWrapper<SysUserRole> queryWrapper = Wrappers.lambdaQuery();
-            queryWrapper.in(SysUserRole::getUserId,SecurityUtils.getUserId());
+            queryWrapper.eq(SysUserRole::getUserId, userId)
+                    .eq(SysUserRole::getTenantId, tenantId);
             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)
-                    {
+            if (CollectionUtils.isNotEmpty(userRoleList)) {
+                List<SysPlatformVo> sysPlatformVos = userRoleList.stream()
+                        .map(userRole -> sysPlatformMapper.getRolePlatformList(tenantId, Math.toIntExact(userRole.getRoleId())))
+                        .flatMap(Collection::stream)
+                        .distinct()
+                        .collect(Collectors.toList());
+                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(),
+                        List<SysMenu> menus1 = this.selectMenuTreeByUserId1(userId,
                                 platformVo.getId().longValue());
                         List<RouterVo> routers = new LinkedList<RouterVo>();
-                        for (SysMenu menu : menus1)
-                        {
+                        for (SysMenu menu : menus1) {
                             RouterVo router = new RouterVo();
                             router.setHidden("1".equals(menu.getVisible()));
                             router.setName(getRouteName(menu));
@@ -384,14 +350,11 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
                             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()))
-                            {
+                            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))
-                            {
+                            } else if (isMenuFrame(menu)) {
                                 router.setMeta(null);
                                 List<RouterVo> childrenList = new ArrayList<RouterVo>();
                                 RouterVo children = new RouterVo();
@@ -401,14 +364,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
                                 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))
-                            {
+                            } 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[] { "", "" });
+                                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));
@@ -434,26 +395,21 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 树结构列表
      */
     @Override
-    public List<SysMenu> buildMenuTree(List<SysMenu> menus)
-    {
+    public List<SysMenu> buildMenuTree(List<SysMenu> menus) {
         List<SysMenu> returnList = new ArrayList<SysMenu>();
         List<Long> tempList = new ArrayList<Long>();
-        for (SysMenu dept : menus)
-        {
+        for (SysMenu dept : menus) {
             tempList.add(dept.getMenuId());
         }
-        for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext();)
-        {
+        for (Iterator<SysMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
             SysMenu menu = (SysMenu) iterator.next();
             // 如果是顶级节点, 遍历该父节点的所有子节点
-            if (!tempList.contains(menu.getParentId()))
-            {
+            if (!tempList.contains(menu.getParentId())) {
                 recursionFn(menus, menu);
                 returnList.add(menu);
             }
         }
-        if (returnList.isEmpty())
-        {
+        if (returnList.isEmpty()) {
             returnList = menus;
         }
         return returnList;
@@ -466,26 +422,21 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 树结构列表
      */
     @Override
-    public List<SysMobileMenu> buildMobileMenuTree(List<SysMobileMenu> menus)
-    {
+    public List<SysMobileMenu> buildMobileMenuTree(List<SysMobileMenu> menus) {
         List<SysMobileMenu> returnList = new ArrayList<SysMobileMenu>();
         List<Long> tempList = new ArrayList<Long>();
-        for (SysMobileMenu dept : menus)
-        {
+        for (SysMobileMenu dept : menus) {
             tempList.add(dept.getMenuId());
         }
-        for (Iterator<SysMobileMenu> iterator = menus.iterator(); iterator.hasNext();)
-        {
+        for (Iterator<SysMobileMenu> iterator = menus.iterator(); iterator.hasNext(); ) {
             SysMobileMenu menu = (SysMobileMenu) iterator.next();
             // 如果是顶级节点, 遍历该父节点的所有子节点
-            if (!tempList.contains(menu.getParentId()))
-            {
+            if (!tempList.contains(menu.getParentId())) {
                 recursionMobileFn(menus, menu);
                 returnList.add(menu);
             }
         }
-        if (returnList.isEmpty())
-        {
+        if (returnList.isEmpty()) {
             returnList = menus;
         }
         return returnList;
@@ -498,8 +449,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 下拉树结构列表
      */
     @Override
-    public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus)
-    {
+    public List<TreeSelect> buildMenuTreeSelect(List<SysMenu> menus) {
         List<SysMenu> menuTrees = buildMenuTree(menus);
         return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
     }
@@ -511,8 +461,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 下拉树结构列表
      */
     @Override
-    public List<TreeMobileSelect> buildMobileMenuTreeSelect(List<SysMobileMenu> menus)
-    {
+    public List<TreeMobileSelect> buildMobileMenuTreeSelect(List<SysMobileMenu> menus) {
         List<SysMobileMenu> menuTrees = buildMobileMenuTree(menus);
         return menuTrees.stream().map(TreeMobileSelect::new).collect(Collectors.toList());
     }
@@ -524,8 +473,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 菜单信息
      */
     @Override
-    public SysMenu selectMenuById(Long menuId)
-    {
+    public SysMenu selectMenuById(Long menuId) {
         return menuMapper.selectMenuById(menuId);
     }
 
@@ -536,8 +484,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 结果
      */
     @Override
-    public boolean hasChildByMenuId(Long menuId)
-    {
+    public boolean hasChildByMenuId(Long menuId) {
         int result = menuMapper.hasChildByMenuId(menuId);
         return result > 0 ? true : false;
     }
@@ -549,8 +496,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 结果
      */
     @Override
-    public boolean checkMenuExistRole(Long menuId)
-    {
+    public boolean checkMenuExistRole(Long menuId) {
         int result = roleMenuMapper.checkMenuExistRole(menuId);
         return result > 0 ? true : false;
     }
@@ -562,8 +508,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 结果
      */
     @Override
-    public int insertMenu(SysMenu menu)
-    {
+    public int insertMenu(SysMenu menu) {
         return menuMapper.insertMenu(menu);
     }
 
@@ -574,55 +519,53 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 结果
      */
     @Override
-    public int updateMenu(SysMenu menu)
-    {
+    public int updateMenu(SysMenu menu) {
         return menuMapper.updateMenu(menu);
     }
 
     @Override
-    public void updateTenantMenu(SysTenantMenu tenantMenu){
+    public void updateTenantMenu(SysTenantMenu tenantMenu) {
         UpdateWrapper<SysTenantMenu> updateWrapper = Wrappers.update();
-        updateWrapper.set("menu_alias_name",tenantMenu.getMenuAliasName())
-                .eq("tenant_id",tenantMenu.getTenantId())
-                .eq("menu_id",tenantMenu.getMenuId());
+        updateWrapper.set("menu_alias_name", tenantMenu.getMenuAliasName())
+                .eq("tenant_id", tenantMenu.getTenantId())
+                .eq("menu_id", tenantMenu.getMenuId());
         tenantMenuService.update(updateWrapper);
 
 
-
         LambdaQueryWrapper<SysUser> queryWrapper1 = Wrappers.lambdaQuery();
         queryWrapper1.select(SysUser::getUserId)
-                .eq(SysUser::getStatus,0)
-                .eq(SysUser::getDelFlag,0)
-                .eq(SysUser::getTenantId,SecurityUtils.getTenantId());
+                .eq(SysUser::getStatus, 0)
+                .eq(SysUser::getDelFlag, 0)
+                .eq(SysUser::getTenantId, SecurityUtils.getTenantId());
         List<SysUser> list = sysUserMapper.selectList(queryWrapper1);
         List<Long> userIdList = new ArrayList<>();
-        if(CollectionUtils.isNotEmpty(list)){
+        if (CollectionUtils.isNotEmpty(list)) {
             for (int i = 0; i < list.size(); i++) {
                 userIdList.add(list.get(i).getUserId());
             }
         }
 
-        if(userIdList.size() > 0){
+        if (userIdList.size() > 0) {
             LambdaQueryWrapper<SysUserRole> queryWrapper = Wrappers.lambdaQuery();
-            queryWrapper.in(SysUserRole::getUserId,userIdList);
+            queryWrapper.in(SysUserRole::getUserId, userIdList);
             List<SysUserRole> userRoleList = sysUserRoleMapper.selectList(queryWrapper);
             List<Long> roleIdList = new ArrayList<>();
-            if(userRoleList.size() > 0){
+            if (userRoleList.size() > 0) {
                 for (int i = 0; i < userRoleList.size(); i++) {
-                    if(roleIdList.contains(userRoleList.get(i).getRoleId())){
+                    if (roleIdList.contains(userRoleList.get(i).getRoleId())) {
 
-                    }else{
+                    } else {
                         roleIdList.add(userRoleList.get(i).getRoleId());
                     }
                 }
             }
 
-            if(roleIdList.size() > 0){
+            if (roleIdList.size() > 0) {
                 UpdateWrapper<SysRoleMenu> updateWrapper1 = Wrappers.update();
-                updateWrapper1.set("menu_alias_name",tenantMenu.getMenuAliasName())
-                        .in("role_id",roleIdList)
-                        .eq("menu_id",tenantMenu.getMenuId());
-                sysRoleMenuMapper.update(null,updateWrapper1);
+                updateWrapper1.set("menu_alias_name", tenantMenu.getMenuAliasName())
+                        .in("role_id", roleIdList)
+                        .eq("menu_id", tenantMenu.getMenuId());
+                sysRoleMenuMapper.update(null, updateWrapper1);
             }
 
         }
@@ -636,8 +579,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 结果
      */
     @Override
-    public int deleteMenuById(Long menuId)
-    {
+    public int deleteMenuById(Long menuId) {
         return menuMapper.deleteMenuById(menuId);
     }
 
@@ -648,12 +590,10 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @return 结果
      */
     @Override
-    public String checkMenuNameUnique(SysMenu menu)
-    {
+    public String checkMenuNameUnique(SysMenu menu) {
         Long menuId = Objects.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
         SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
-        if (Objects.nonNull(info) && info.getMenuId().longValue() != menuId.longValue())
-        {
+        if (Objects.nonNull(info) && info.getMenuId().longValue() != menuId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -665,12 +605,10 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param menu 菜单信息
      * @return 路由名称
      */
-    public String getRouteName(SysMenu menu)
-    {
+    public String getRouteName(SysMenu menu) {
         String routerName = StringUtils.capitalize(menu.getPath());
         // 非外链并且是一级目录(类型为目录)
-        if (isMenuFrame(menu))
-        {
+        if (isMenuFrame(menu)) {
             routerName = StringUtils.EMPTY;
         }
         return routerName;
@@ -682,23 +620,19 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param menu 菜单信息
      * @return 路由地址
      */
-    public String getRouterPath(SysMenu menu)
-    {
+    public String getRouterPath(SysMenu menu) {
         String routerPath = menu.getPath();
         // 内链打开外网方式
-        if (menu.getParentId().intValue() != 0 && isInnerLink(menu))
-        {
-            routerPath = StringUtils.replaceEach(routerPath, new String[] { Constants.HTTP, Constants.HTTPS }, new String[] { "", "" });
+        if (menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
+            routerPath = StringUtils.replaceEach(routerPath, new String[]{Constants.HTTP, Constants.HTTPS}, new String[]{"", ""});
         }
         // 非外链并且是一级目录(类型为目录)
         if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType())
-                && UserConstants.NO_FRAME.equals(menu.getIsFrame()))
-        {
+                && UserConstants.NO_FRAME.equals(menu.getIsFrame())) {
             routerPath = "/" + menu.getPath();
         }
         // 非外链并且是一级目录(类型为菜单)
-        else if (isMenuFrame(menu))
-        {
+        else if (isMenuFrame(menu)) {
             routerPath = "/";
         }
         return routerPath;
@@ -710,19 +644,13 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param menu 菜单信息
      * @return 组件信息
      */
-    public String getComponent(SysMenu menu)
-    {
+    public String getComponent(SysMenu menu) {
         String component = UserConstants.LAYOUT;
-        if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu))
-        {
+        if (StringUtils.isNotEmpty(menu.getComponent()) && !isMenuFrame(menu)) {
             component = menu.getComponent();
-        }
-        else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu))
-        {
+        } else if (StringUtils.isEmpty(menu.getComponent()) && menu.getParentId().intValue() != 0 && isInnerLink(menu)) {
             component = UserConstants.INNER_LINK;
-        }
-        else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
-        {
+        } else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu)) {
             component = UserConstants.PARENT_VIEW;
         }
         return component;
@@ -734,8 +662,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param menu 菜单信息
      * @return 结果
      */
-    public boolean isMenuFrame(SysMenu menu)
-    {
+    public boolean isMenuFrame(SysMenu menu) {
         return menu.getParentId().intValue() == 0 && UserConstants.TYPE_MENU.equals(menu.getMenuType())
                 && menu.getIsFrame().equals(UserConstants.NO_FRAME);
     }
@@ -746,8 +673,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param menu 菜单信息
      * @return 结果
      */
-    public boolean isInnerLink(SysMenu menu)
-    {
+    public boolean isInnerLink(SysMenu menu) {
         return menu.getIsFrame().equals(UserConstants.NO_FRAME) && StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS);
     }
 
@@ -757,8 +683,7 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param menu 菜单信息
      * @return 结果
      */
-    public boolean isParentView(SysMenu menu)
-    {
+    public boolean isParentView(SysMenu menu) {
         return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
     }
 
@@ -769,15 +694,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param parentId 传入的父节点ID
      * @return String
      */
-    public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId)
-    {
+    public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
         List<SysMenu> returnList = new ArrayList<SysMenu>();
-        for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();)
-        {
+        for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) {
             SysMenu t = (SysMenu) iterator.next();
             // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
-            if (t.getParentId() == parentId)
-            {
+            if (t.getParentId() == parentId) {
                 recursionFn(list, t);
                 returnList.add(t);
             }
@@ -791,15 +713,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param list
      * @param t
      */
-    private void recursionFn(List<SysMenu> list, SysMenu t)
-    {
+    private void recursionFn(List<SysMenu> list, SysMenu t) {
         // 得到子节点列表
         List<SysMenu> childList = getChildList(list, t);
         t.setChildren(childList);
-        for (SysMenu tChild : childList)
-        {
-            if (hasChild(list, tChild))
-            {
+        for (SysMenu tChild : childList) {
+            if (hasChild(list, tChild)) {
                 recursionFn(list, tChild);
             }
         }
@@ -811,15 +730,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
      * @param list
      * @param t
      */
-    private void recursionMobileFn(List<SysMobileMenu> list, SysMobileMenu t)
-    {
+    private void recursionMobileFn(List<SysMobileMenu> list, SysMobileMenu t) {
         // 得到子节点列表
         List<SysMobileMenu> childList = getChildMobileList(list, t);
         t.setChildren(childList);
-        for (SysMobileMenu tChild : childList)
-        {
-            if (hasMobileChild(list, tChild))
-            {
+        for (SysMobileMenu tChild : childList) {
+            if (hasMobileChild(list, tChild)) {
                 recursionMobileFn(list, tChild);
             }
         }
@@ -828,15 +744,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
     /**
      * 得到子节点列表
      */
-    private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t)
-    {
+    private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) {
         List<SysMenu> tlist = new ArrayList<SysMenu>();
         Iterator<SysMenu> it = list.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             SysMenu n = (SysMenu) it.next();
-            if (n.getParentId().longValue() == t.getMenuId().longValue())
-            {
+            if (n.getParentId().longValue() == t.getMenuId().longValue()) {
                 tlist.add(n);
             }
         }
@@ -846,15 +759,12 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
     /**
      * 得到移动端子节点列表
      */
-    private List<SysMobileMenu> getChildMobileList(List<SysMobileMenu> list, SysMobileMenu t)
-    {
+    private List<SysMobileMenu> getChildMobileList(List<SysMobileMenu> list, SysMobileMenu t) {
         List<SysMobileMenu> tlist = new ArrayList<SysMobileMenu>();
         Iterator<SysMobileMenu> it = list.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             SysMobileMenu n = (SysMobileMenu) it.next();
-            if (n.getParentId().longValue() == t.getMenuId())
-            {
+            if (n.getParentId().longValue() == t.getMenuId()) {
                 tlist.add(n);
             }
         }
@@ -864,30 +774,27 @@ public class SysMenuServiceImpl extends AbstractCrudService<SysMenuMapper, SysMe
     /**
      * 判断是否有子节点
      */
-    private boolean hasChild(List<SysMenu> list, SysMenu t)
-    {
+    private boolean hasChild(List<SysMenu> list, SysMenu t) {
         return getChildList(list, t).size() > 0 ? true : false;
     }
 
     /**
      * 判断移动端是否有子节点
      */
-    private boolean hasMobileChild(List<SysMobileMenu> list, SysMobileMenu t)
-    {
+    private boolean hasMobileChild(List<SysMobileMenu> list, SysMobileMenu t) {
         return getChildMobileList(list, t).size() > 0 ? true : false;
     }
 
     @Override
-    public List<TenantPlatformMenuVo> selectRolePlatformMenu()
-    {
+    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++){
+        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());
+                List<SysMenu> menus = baseMapper.getTenantPlatformMenuList(SecurityUtils.getTenantId(), list.get(i).getId());
                 tenantPlatformMenuVo.setChildren(this.buildMenuTreeSelect(menus));
                 list1.add(tenantPlatformMenuVo);
             }

+ 2 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysNoticeServiceImpl.java

@@ -56,6 +56,8 @@ public class SysNoticeServiceImpl extends AbstractCrudService<SysNoticeMapper, S
     @Override
     public List<SysNotice> selectNoticeList(SysNotice notice) {
         notice.setTenantId(SecurityUtils.getTenantId());
+        String deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId().toString();
+        notice.setDeptId(deptId);
         return noticeMapper.selectNoticeList(notice);
     }
 

+ 2 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysRoleServiceImpl.java

@@ -410,11 +410,13 @@ public class SysRoleServiceImpl extends AbstractCrudService<SysRoleMapper, SysRo
     {
         // 新增用户与角色管理
         List<SysUserRole> list = new ArrayList<SysUserRole>();
+        Integer tenantId = SecurityUtils.getTenantId();
         for (Long userId : userIds)
         {
             SysUserRole ur = new SysUserRole();
             ur.setUserId(userId);
             ur.setRoleId(roleId);
+            ur.setTenantId(tenantId);
             list.add(ur);
         }
         return userRoleMapper.batchUserRole(list);

+ 3 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserServiceImpl.java

@@ -512,6 +512,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
                 SysUserRole ur = new SysUserRole();
                 ur.setUserId(user.getUserId());
                 ur.setRoleId(roleId);
+                ur.setTenantId(user.getTenantId());
                 list.add(ur);
             }
             if (list.size() > 0) {
@@ -552,10 +553,12 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
         if (Objects.nonNull(roleIds)) {
             // 新增用户与角色管理
             List<SysUserRole> list = new ArrayList<SysUserRole>();
+            Integer tenantId = SecurityUtils.getTenantId();
             for (Long roleId : roleIds) {
                 SysUserRole ur = new SysUserRole();
                 ur.setUserId(userId);
                 ur.setRoleId(roleId);
+                ur.setTenantId(tenantId);
                 list.add(ur);
             }
             if (list.size() > 0) {

+ 1 - 0
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysNoticeMapper.xml

@@ -66,6 +66,7 @@
             <if test="tenantId != null and tenantId != ''">
                 AND tenant_id = #{tenantId}
             </if>
+            AND FIND_IN_SET(#{deptId}, dept_id) > 0
         </where>
         order by notice_id desc
     </select>

+ 3 - 2
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysUserRoleMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	<resultMap type="com.usky.system.domain.SysUserRole" id="SysUserRoleResult">
 		<result property="userId"     column="user_id"      />
 		<result property="roleId"     column="role_id"      />
+		<result property="tenantId"   column="tenant_id"    />
 	</resultMap>
 
 	<delete id="deleteUserRoleByUserId" parameterType="Long">
@@ -25,9 +26,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  	</delete>
 	
 	<insert id="batchUserRole">
-		insert into sys_user_role(user_id, role_id) values
+		insert into sys_user_role(user_id, role_id, tenant_id) values
 		<foreach item="item" index="index" collection="list" separator=",">
-			(#{item.userId},#{item.roleId})
+			(#{item.userId},#{item.roleId},#{item.tenantId})
 		</foreach>
 	</insert>