Ver Fonte

Merge branch 'master' of http://192.168.101.10:13000/boman/boman-framwork

sr há 4 anos atrás
pai
commit
7ff1666aef

+ 15 - 3
boman-api/boman-api-system/src/main/java/com/boman/system/api/domain/SysMenu.java

@@ -9,6 +9,7 @@ import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.Size;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 菜单权限表 sys_menu
@@ -70,6 +71,9 @@ public class SysMenu extends BaseEntity
 
     /** 子菜单 */
     private List<SysMenu> children = new ArrayList<SysMenu>();
+
+    /** 父级菜单 */
+    private SysMenu parent;
     /**
      * 对应的表名称
      */
@@ -80,16 +84,24 @@ public class SysMenu extends BaseEntity
      * false 此表中有此菜单,但是未选择
      * 0 此表中无此菜单
      */
-    private List<JSONObject> containsHead;
+    private List<Map<String, Object>> containsHead;
 
-    public List<JSONObject> getContainsHead() {
+    public List<Map<String, Object>> getContainsHead() {
         return containsHead;
     }
 
-    public void setContainsHead(List<JSONObject> containsHead) {
+    public void setContainsHead(List<Map<String, Object>> containsHead) {
         this.containsHead = containsHead;
     }
 
+    public SysMenu getParent() {
+        return parent;
+    }
+
+    public void setParent(SysMenu parent) {
+        this.parent = parent;
+    }
+
     public String getSysTableName() {
         return sysTableName;
     }

+ 8 - 10
boman-api/boman-domain/src/main/java/com.boman.domain/RoleEnum.java

@@ -1,7 +1,5 @@
 package com.boman.domain;
 
-import com.alibaba.fastjson.JSONObject;
-
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -99,16 +97,16 @@ public enum RoleEnum {
         return result;
     }
 
-    /**
-     * 功能描述: 拿到所有的roles eg: A、M.....
-     *
-     * @return java.util.List<java.lang.String>
-     */
-    public static List<JSONObject> initData() {
+   /**
+    * 功能描述: 拿到所有的roles eg: A、M.....
+    *
+    * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+    */
+    public static List<Map<String, Object>> initData() {
         List<String> roles = roles();
-        List<JSONObject> result = new ArrayList<>(roles.size());
+        List<Map<String, Object>> result = new ArrayList<>(roles.size());
         for (String role : roles) {
-            JSONObject jsonObject = new JSONObject(2);
+            Map<String, Object> jsonObject = new HashMap<>(2);
             jsonObject.put("name", role);
             jsonObject.put("type", "0");
             result.add(jsonObject);

+ 25 - 11
boman-api/boman-domain/src/main/java/com.boman.domain/dto/RoleMenuDto.java

@@ -1,19 +1,12 @@
 package com.boman.domain.dto;
 
 
-
-import lombok.Data;
-
 import java.util.List;
 
-import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
-import static com.boman.domain.constant.FormDataConstant.COLON;
-
 /**
  * @author shiqian
  * @date 2021年05月06日 17:25
  **/
-@Data
 public class RoleMenuDto {
 
     private Long menuId;
@@ -29,8 +22,7 @@ public class RoleMenuDto {
      */
     public static String getBtnFromPerms(String perms) {
         // sys_user:A
-        requireNonNull(perms, "权限标识为空");
-        String[] split = perms.split(COLON);
+        String[] split = perms.split(":");
         assert split.length == 2;
         // A
         return split[1];
@@ -44,11 +36,33 @@ public class RoleMenuDto {
      */
     public static String getTableNameFromPerms(String perms) {
         // sys_user:A
-        requireNonNull(perms, "权限标识为空");
-        String[] split = perms.split(COLON);
+        String[] split = perms.split(":");
         assert split.length == 2;
         // sys_user
         return split[0];
     }
 
+    public Long getMenuId() {
+        return menuId;
+    }
+
+    public void setMenuId(Long menuId) {
+        this.menuId = menuId;
+    }
+
+    public Long getRoleId() {
+        return roleId;
+    }
+
+    public void setRoleId(Long roleId) {
+        this.roleId = roleId;
+    }
+
+    public List<String> getHead() {
+        return head;
+    }
+
+    public void setHead(List<String> head) {
+        this.head = head;
+    }
 }

+ 16 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/array/ArrayUtils.java

@@ -1,6 +1,10 @@
 package com.boman.common.core.utils.array;
 
+import org.apache.commons.compress.utils.Lists;
+
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * @author shiqian
@@ -28,4 +32,16 @@ public class ArrayUtils extends org.apache.commons.lang3.ArrayUtils {
     public static boolean equalsEmptyArray(String value) {
         return "[]".equals(value);
     }
+
+    /**
+     * 功能描述: 切割转list
+     *
+     * @param input  input
+     * @param symbol 分隔符
+     * @return java.util.List<java.lang.String>
+     */
+    public static List<String> split(String input, String symbol) {
+        String[] split = input.split(symbol);
+        return new ArrayList<>(Arrays.asList(split));
+    }
 }

+ 18 - 4
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysMenuController.java

@@ -100,6 +100,18 @@ public class SysMenuController extends BaseController
         return ajax;
     }
 
+   /**
+    * 功能描述: 根据roleId查找的叶子结点去匹配所对应的菜单树
+    *
+    * @param roleId roleId
+    * @return com.boman.common.core.web.domain.AjaxResult
+    */
+    @GetMapping(value = "/listTreeByRoleId/{roleId}")
+    public AjaxResult listTreeByRoleId(@PathVariable("roleId") Long roleId) {
+        return AjaxResult.success(menuService.listTreeByRoleId(roleId));
+    }
+
+
     /**
      * 功能描述: 根据菜单id,找到此菜单以及子菜单下所有的叶子节点
      *
@@ -110,15 +122,17 @@ public class SysMenuController extends BaseController
     public AjaxResult allLeafNodeById(@PathVariable("menuId") Long menuId) {
         return AjaxResult.success(menuService.allLeafNodeById(menuId));
     }
+
     /**
-     * 功能描述: 根据菜单id,找到此菜单以及子菜单下所有的叶子节点, 同时匹配叶子结点对应的头部的规则
+     * 功能描述: 根据menuId和roleId,找到此菜单以及子菜单下所有的叶子节点, 同时匹配叶子结点对应的头部的规则
      *
      * @param menuId menuId
+     * @param roleId roleId
      * @return com.boman.common.core.web.domain.AjaxResult
      */
-    @GetMapping(value = "/listMenus/{menuId}")
-    public AjaxResult listMenus(@PathVariable("menuId") Long menuId) {
-        return AjaxResult.success(menuService.listMenus(menuId));
+    @GetMapping(value = "/listMenus/roleId/{roleId}/menuId/{menuId}")
+    public AjaxResult listMenus(@PathVariable("roleId") Long roleId, @PathVariable("menuId") Long menuId) {
+        return AjaxResult.success(menuService.listMenus(roleId, menuId));
     }
 
     /**

+ 8 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysMenuMapper.java

@@ -122,4 +122,12 @@ public interface SysMenuMapper
      * @return 结果
      */
     public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId);
+
+    /**
+     * 功能描述: 根据roleId查找的叶子结点去匹配所对应的菜单树
+     *
+     * @param roleId roleId
+     * @return java.util.List<com.boman.system.api.domain.SysMenu>
+     */
+    List<SysMenu> listTreeByRoleId(@Param("roleId") Long roleId);
 }

+ 26 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysRoleMenuMapper.java

@@ -51,4 +51,30 @@ public interface SysRoleMenuMapper
      * @return 结果
      */
     int batchRoleMenu(@Param("roleMenuList") List<SysRoleMenu> roleMenuList);
+
+    /**
+     * 功能描述: 根据roleId和menuId查找
+     *
+     * @param roleId roleId
+     * @param menuId menuId
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    SysRoleMenu listByRoleIdMenuId(@Param("roleId") Long roleId, @Param("menuId") Long menuId);
+
+    /**
+     * 功能描述: 根据roleId和menuId查找
+     *
+     * @param roleId roleId
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    List<SysRoleMenu> listByRoleId(Long roleId);
+
+    /**
+     * 功能描述: 根据roleId和menuIdList查找
+     *
+     * @param roleId     roleId
+     * @param menuIdList menuIdList
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    List<SysRoleMenu> listByRoleIdMenuIdList(@Param("roleId") Long roleId, @Param("menuIdList") List<Long> menuIdList);
 }

+ 9 - 1
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysMenuService.java

@@ -174,5 +174,13 @@ public interface ISysMenuService
      */
     public String checkMenuNameUnique(SysMenu menu);
 
-    Map<String, Object> listMenus(Long menuId);
+    Map<String, Object> listMenus(Long roleId, Long menuId);
+
+    /**
+     * 功能描述: 根据roleId查找的叶子结点去匹配所对应的菜单树
+     *
+     * @param roleId roleId
+     * @return java.lang.String
+     */
+    List<SysMenu>  listTreeByRoleId(Long roleId);
 }

+ 34 - 8
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/ISysRoleMenuService.java

@@ -12,18 +12,18 @@ import java.util.List;
  */
 public interface ISysRoleMenuService {
 
-   /**
-    * 功能描述: 批量保存roleMenu
-    *
-    * @param dtos dtos
-    * @return int
-    */
+    /**
+     * 功能描述: 批量保存roleMenu
+     *
+     * @param dtos dtos
+     * @return int
+     */
     int saveList(List<RoleMenuDto> dtos);
 
     /**
      * 功能描述: 根据roleIdList删除
      *
-     * @param roleIdList  roleIdList
+     * @param roleIdList roleIdList
      * @return int
      */
     int deleteByRoleIdList(List<Long> roleIdList);
@@ -31,10 +31,36 @@ public interface ISysRoleMenuService {
     /**
      * 功能描述: 批量保存roleMenuList
      *
-     * @param roleMenuList  roleMenuList
+     * @param roleMenuList roleMenuList
      * @return int
      */
     int batchRoleMenu(List<SysRoleMenu> roleMenuList);
 
+    /**
+     * 功能描述: 根据roleId和menuId查找
+     *
+     * @param roleId roleId
+     * @param menuId menuId
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    SysRoleMenu listByRoleIdMenuId(Long roleId, Long menuId);
+
+    /**
+     * 功能描述: 根据roleId和menuIdList查找
+     *
+     * @param roleId     roleId
+     * @param menuIdList menuIdList
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    List<SysRoleMenu>  listByRoleIdMenuIdList(Long roleId, List<Long> menuIdList);
+
+    /**
+     * 功能描述: 根据roleId和menuId查找
+     *
+     * @param roleId roleId
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    List<SysRoleMenu> listByRoleId(Long roleId);
+
 
 }

+ 176 - 33
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysMenuServiceImpl.java

@@ -1,9 +1,10 @@
 package com.boman.system.service.impl;
 
-import java.util.*;
-import java.util.stream.Collectors;
-
-import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.constant.UserConstants;
+import com.boman.common.core.utils.SecurityUtils;
+import com.boman.common.core.utils.StringUtils;
+import com.boman.common.core.utils.array.ArrayUtils;
+import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.web.domain.AjaxResult;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
@@ -12,15 +13,9 @@ import com.boman.domain.RoleEnum;
 import com.boman.domain.constant.GlobalBtn;
 import com.boman.domain.dto.RoleMenuDto;
 import com.boman.system.api.domain.SysMenu;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.boman.common.core.constant.UserConstants;
-import com.boman.common.core.utils.SecurityUtils;
-import com.boman.common.core.utils.StringUtils;
 import com.boman.system.api.domain.SysRole;
 import com.boman.system.api.domain.SysUser;
+import com.boman.system.domain.SysRoleMenu;
 import com.boman.system.domain.vo.MetaVo;
 import com.boman.system.domain.vo.RouterVo;
 import com.boman.system.domain.vo.TreeSelect;
@@ -28,11 +23,17 @@ import com.boman.system.mapper.SysMenuMapper;
 import com.boman.system.mapper.SysRoleMapper;
 import com.boman.system.mapper.SysRoleMenuMapper;
 import com.boman.system.service.ISysMenuService;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.lang3.BooleanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
-import static com.boman.domain.constant.FormDataConstant.COLON;
 
 /**
  * 菜单 业务层处理
@@ -53,6 +54,8 @@ public class SysMenuServiceImpl implements ISysMenuService {
     private SysRoleMenuMapper roleMenuMapper;
     @Resource
     private RedisService redisService;
+    @Resource
+    private ISysRoleMenuService roleMenuService;
 
     /**
      * 根据用户查询系统菜单列表
@@ -132,13 +135,27 @@ public class SysMenuServiceImpl implements ISysMenuService {
      */
     @Override
     public List<SysMenu> allLeafNodeById(Long menuId) {
+        List<SysMenu> tempList = Lists.newArrayListWithCapacity(16);
         SysMenu menu = selectMenuById(menuId);
         List<SysMenu> menus = menuMapper.selectMenuList(new SysMenu());
-        List<SysMenu> tempList = Lists.newArrayListWithCapacity(16);
-        recursionList(menus, menu, tempList);
-        // 把父亲去掉
-        if (tempList.size() > 1) {
-            tempList.remove(0);
+        List<SysMenu> sysMenus = recChildList(menus, menu, tempList);
+        return ObjectUtils.filter(sysMenus, menu1 -> SysMenu.BUTTON.equals(menu1.getMenuType()));
+    }
+
+    private List<SysMenu> recChildList(List<SysMenu> menus, SysMenu menu, List<SysMenu> tempList) {
+        int child = 0;
+        // 得到子节点列表
+        List<SysMenu> childList = getChildList(menus, menu);
+        for (SysMenu tChild : childList) {
+            if (hasChild(menus, tChild)) {
+                recChildList(menus, tChild, tempList);
+            } else {
+                child++;
+            }
+        }
+
+        if (child == childList.size() && childList.size() != 0) {
+            tempList.addAll(childList);
         }
 
         return tempList;
@@ -539,11 +556,11 @@ public class SysMenuServiceImpl implements ISysMenuService {
     }
 
     @Override
-    public Map<String, Object> listMenus(Long menuId) {
+    public Map<String, Object> listMenus(Long roleId, Long menuId) {
         SysMenu menu = selectMenuById(menuId);
-        List<SysMenu> menus = menuMapper.selectMenuList(new SysMenu());
+        List<SysMenu> allMenu = menuMapper.selectMenuList(new SysMenu());
         List<SysMenu> tempList = Lists.newArrayListWithCapacity(16);
-        recursionList(menus, menu, tempList);
+        recursionList(allMenu, menu, tempList);
         // 把父亲去掉
         if (tempList.size() > 1) {
             tempList.remove(0);
@@ -557,29 +574,155 @@ public class SysMenuServiceImpl implements ISysMenuService {
             return result;
         }
 
+        // 找到当前menuId对应的所有的叶子结点
+        List<SysMenu> leafNodes = allLeafNodeById(menuId);
+        List<Long> menuIdList = map(leafNodes, SysMenu::getId);
+        List<SysRoleMenu> roleMenuList = roleMenuService.listByRoleIdMenuIdList(roleId, menuIdList);
+        if (isEmpty(roleMenuList)) {
+            result.put("sysMenus", tempList);
+            return result;
+        }
+
+        List<Long> roleMenuIdList = map(roleMenuList, SysRoleMenu::getMenuId);
+        List<String> allBtnList = RoleEnum.roles();
+
         for (SysMenu sysMenu : tempList) {
-            List<JSONObject> containsHead = RoleEnum.initData();
-            List<SysMenu> childList = getChildList(menus, sysMenu);
-            for (SysMenu childMenu : childList) {
-                String btn = RoleMenuDto.getBtnFromPerms(childMenu.getPerms());
-                String tableName = RoleMenuDto.getTableNameFromPerms(childMenu.getPerms());
-                GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
-                String menuRole = genTable.getMenuRole();
-                if (menuRole.contains(btn)) {
-                    switchBtn(containsHead, btn, true);
-                } else {
-                    switchBtn(containsHead, btn, false);
+            List<Map<String, Object>> containsHead = RoleEnum.initData();
+            List<SysMenu> childList = getChildList(allMenu, sysMenu);
+            if (isEmpty(childList)) {
+                continue;
+            }
+
+            List<String> btnList = getBtnFromMenu(roleMenuIdList, childList);
+
+            String tableName = RoleMenuDto.getTableNameFromPerms(childList.get(0).getPerms());
+            GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
+            if (isEmpty(genTable)) {
+                continue;
+            }
+
+            List<String> menuRoleList = ArrayUtils.split(genTable.getMenuRole(), "");
+
+            for (String allBtn : allBtnList) {
+                boolean one = btnList.contains(allBtn);
+                boolean another = menuRoleList.contains(allBtn);
+                if (BooleanUtils.isTrue(one) && BooleanUtils.isTrue(another)) {
+                    switchBtn(containsHead, allBtn, true);
+                }
+
+                if (BooleanUtils.isFalse(one) && BooleanUtils.isTrue(another)) {
+                    switchBtn(containsHead, allBtn, false);
+                }
+
+                if (BooleanUtils.isFalse(one) && BooleanUtils.isFalse(another)) {
+                    switchBtn(containsHead, allBtn, "0");
                 }
             }
 
             sysMenu.setContainsHead(containsHead);
         }
+
         result.put("sysMenus", tempList);
         return result;
     }
 
-    private void switchBtn(List<JSONObject> containsHead, String btn, Object value) {
-        JSONObject jsonObject = new JSONObject(2);
+    /**
+     * 功能描述: roleMenuIdList包含childList中的id的全部取出来
+     *
+     * @param roleMenuIdList roleMenuIdList
+     * @param childList      childList
+     * @return java.util.List<java.lang.String>
+     */
+    private List<String> getBtnFromMenu(List<Long> roleMenuIdList, List<SysMenu> childList) {
+        List<String> btnList = Lists.newArrayList();
+        for (SysMenu childMenu : childList) {
+            if (roleMenuIdList.contains(childMenu.getId())) {
+                String btn = RoleMenuDto.getBtnFromPerms(childMenu.getPerms());
+                btnList.add(btn);
+            }
+        }
+        return btnList;
+    }
+
+    /**
+     * 功能描述: 根据roleId查找的叶子结点去匹配所对应的菜单树
+     *
+     * @param roleId roleId
+     * @return java.lang.String
+     */
+    @Override
+    public List<SysMenu> listTreeByRoleId(Long roleId) {
+        List<SysMenu> roleMenus = menuMapper.listTreeByRoleId(roleId);
+        List<SysMenu> allMenus = selectMenuListAll(new SysMenu());
+
+        List<Long> roleMenuIdList = map(roleMenus, SysMenu::getId);
+        List<SysMenu> parentMenus = Lists.newArrayListWithCapacity(16);
+
+        // 把roleMenus对应的所有的爹parentMenus找到
+        recGetParent(allMenus, roleMenus, parentMenus);
+
+        // 递归,把孩子放进父亲的怀抱
+        for (SysMenu parentMenu : parentMenus) {
+            recursionFn(parentMenus, parentMenu);
+        }
+
+        // 把不在roleMenus中的去除掉
+        return filter(parentMenus, menu -> isNotEmpty(menu.getChildren()));
+    }
+
+    /**
+     * 功能描述: 找到sonMenus对应的所有的父类,结果存放于result中
+     *
+     * @param allMenus allMenus
+     * @param sonMenus sonMenus
+     * @param result   没有按照规则排序只是把父类全部存放于result中
+     */
+    private void recGetParent(List<SysMenu> allMenus, List<SysMenu> roleMenus, List<SysMenu> result) {
+        for (SysMenu sonMenu : roleMenus) {
+            for (SysMenu parentMenu : allMenus) {
+                if (sonMenu.getParentId().equals(parentMenu.getId())) {
+                    if (isNotEmpty(result)) {
+                        List<Long> idList = map(result, SysMenu::getId);
+                        if (!idList.contains(parentMenu.getId())) {
+                            result.add(parentMenu);
+                        }
+                    } else {
+                        result.add(parentMenu);
+                    }
+
+                    // 顶级目录
+                    if (parentMenu.getId() != 1) {
+                        List<SysMenu> list = Collections.singletonList(parentMenu);
+                        recGetParent(allMenus, list, result);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    private void recBuildTree(List<SysMenu> roleMenus, SysMenu parent) {
+        List<SysMenu> childList = getChildList(roleMenus, parent);
+
+        parent.setChildren(childList);
+        for (SysMenu tChild : childList) {
+            if (hasChild(roleMenus, tChild)) {
+                recursionFn(roleMenus, tChild);
+            }
+        }
+    }
+
+    // 得到子节点列表
+//    List<SysMenu> childList = getChildList(list, t);
+//        t.setChildren(childList);
+//        for (SysMenu tChild : childList) {
+//        if (hasChild(list, tChild)) {
+//            recursionFn(list, tChild);
+//        }
+//    }
+
+    private void switchBtn(List<Map<String, Object>> containsHead, String btn, Object value) {
+        Map<String, Object> jsonObject = new HashMap<>(2);
         jsonObject.put("name", btn);
         jsonObject.put("type", value);
         switch (btn) {

+ 36 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysRoleMenuServiceImpl.java

@@ -122,4 +122,40 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
 
         return result;
     }
+
+    /**
+     * 功能描述: 根据roleId和menuId查找
+     *
+     * @param roleId roleId
+     * @param menuId menuId
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    @Override
+    public SysRoleMenu listByRoleIdMenuId(Long roleId, Long menuId) {
+
+        return mapper.listByRoleIdMenuId(roleId, menuId);
+    }
+
+    /**
+     * 功能描述: 根据roleId和menuIdList查找
+     *
+     * @param roleId     roleId
+     * @param menuIdList menuIdList
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    @Override
+    public List<SysRoleMenu> listByRoleIdMenuIdList(Long roleId, List<Long> menuIdList) {
+        return mapper.listByRoleIdMenuIdList(roleId, menuIdList);
+    }
+
+    /**
+     * 功能描述: 根据roleId和menuId查找
+     *
+     * @param roleId roleId
+     * @return java.util.List<com.boman.system.domain.SysRoleMenu>
+     */
+    @Override
+    public List<SysRoleMenu> listByRoleId(Long roleId) {
+        return mapper.listByRoleId(roleId);
+    }
 }

+ 11 - 1
boman-modules/boman-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -130,7 +130,17 @@
 		<include refid="selectMenuVo"/>
 		where menu_name=#{menuName} and parent_id = #{parentId} limit 1
 	</select>
-	
+
+	<select id="listTreeByRoleId"  resultMap="SysMenuResult">
+		SELECT
+			m.*
+		FROM
+			sys_menu m
+				LEFT JOIN sys_role_menu rm ON m.id = rm.menu_id
+		WHERE
+			rm.role_id = #{roleId}
+	</select>
+
 	<update id="updateMenu" parameterType="SysMenu">
 		update sys_menu
 		<set>

+ 15 - 0
boman-modules/boman-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml

@@ -14,6 +14,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	    select count(1) from sys_role_menu where menu_id = #{menuId}
 	</select>
 
+	<select id="listByRoleIdMenuId" resultMap="SysRoleMenuResult">
+		select * from sys_role_menu where menu_id = #{menuId} and role_id = #{roleId}
+	</select>
+
+	<select id="listByRoleId" resultMap="SysRoleMenuResult">
+		select * from sys_role_menu where role_id = #{roleId}
+	</select>
+
+	<select id="listByRoleIdMenuIdList" resultMap="SysRoleMenuResult">
+		select * from sys_role_menu where role_id = #{roleId} and menu_id in
+		<foreach collection="menuIdList" item="menuId" open="(" separator="," close=")">
+			#{menuId}
+		</foreach>
+	</select>
+
 	<delete id="deleteRoleMenuByRoleId" parameterType="Long">
 		delete from sys_role_menu where role_id=#{roleId}
 	</delete>

+ 3 - 9
boman-web-core/src/main/java/com/boman/web/core/utils/HandlerFormDataUtils.java

@@ -18,10 +18,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.nio.charset.StandardCharsets;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.domain.constant.FormDataConstant.*;
@@ -49,11 +46,8 @@ public class HandlerFormDataUtils {
         for (JSONObject jsonObject : result) {
             //获取到所有rows查询字段的值
             Set<String> strings = jsonObject.keySet();
-
-            if ( strings.size() == 0){
-                break;
-            }
-            for (String string : strings) {
+            List<String> arrays = new ArrayList<>(strings);
+            for (String string : arrays) {
                 for (GenTableColumn column : allColumns) {
                     String dictType = column.getDictType();
                     String columnName = column.getColumnName();