lizijie
2021-04-23 4318ffbc62cf082dbea4e045b7ed84da7e0a66ab
修改配置菜单传空数组时不置空问题
4 files modified
82 ■■■■ changed files
screen-common/src/main/java/com/moral/constant/ResponseCodeEnum.java 4 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/ManageMenuServiceImpl.java 4 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/ManageRoleMenuServiceImpl.java 70 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/ManageRoleServiceImpl.java 4 ●●●● patch | view | raw | blame | history
screen-common/src/main/java/com/moral/constant/ResponseCodeEnum.java
@@ -32,9 +32,9 @@
    TIME_FORMAT_INVALID(-18,"时间格式无效"),
    TIME_INVALID(-19,"时间无效"),
    GROUP_EXIST(-20, "组已存在"),
    ROLE_IS_EXPIRE(-21, "该角色名不存在"),
    ROLE_IS_EXIST(-21, "角色已存在"),
    ROLE_IS_NULL(-22, "角色不存在"),
    MENU_IS_EXPIRE(-23, "该菜单名不存在"),
    MENU_IS_EXIST(-23, "菜单已存在"),
    MENU_IS_NULL(-24, "菜单不存在"),
    PARAMETERS_NOT_REQUIREMENT(-25, "参数不符合要求"),
    DICTTYPE_NOT_EXIST(-26,"字典类型不存在"),
screen-manage/src/main/java/com/moral/api/service/impl/ManageMenuServiceImpl.java
@@ -58,8 +58,8 @@
            return resultMap;
        }
        if (manageMenuMapper.getManageMenuByName(manageMenu.getName()) != null) {
            resultMap.put("code", ResponseCodeEnum.MENU_IS_EXPIRE.getCode());
            resultMap.put("msg", ResponseCodeEnum.MENU_IS_EXPIRE.getMsg());
            resultMap.put("code", ResponseCodeEnum.MENU_IS_EXIST.getCode());
            resultMap.put("msg", ResponseCodeEnum.MENU_IS_EXIST.getMsg());
        } else {
            manageMenuMapper.insertOne(manageMenu);
            //操作插入日志
screen-manage/src/main/java/com/moral/api/service/impl/ManageRoleMenuServiceImpl.java
@@ -63,7 +63,7 @@
            result = manageRoleMenuMapper.getDataByMenuIds(list,id);
        }
        List<Map> result1 = manageRoleMenuMapper.getDataByRoleId(id);
        if (manageRoleMenuMapper.selectCount(wrapper)==0 || result.size()==0){
        if ((manageRoleMenuMapper.selectCount(wrapper)==0 || result.size()==0)&&list.size()!=0){
            List<Map> insertList = new ArrayList<>();
            for (Object temp:list) {
                Map<String,Object> map = new HashMap<>();
@@ -74,47 +74,49 @@
            if (insertList.size()!=0){
                manageRoleMenuMapper.insertBatch(insertList);
            }
        }
        List updateList = new ArrayList();
        for (Map manageRoleMenu:result1) {
            int have = 1;
            for (Object temp:list){
                if (manageRoleMenu.get("menu_id").equals(Integer.parseInt(temp.toString()))){
                    have = 2;
        }else {
            List updateList = new ArrayList();
            for (Map manageRoleMenu:result1) {
                int have = 1;
                for (Object temp:list){
                    if (manageRoleMenu.get("menu_id").equals(Integer.parseInt(temp.toString()))){
                        have = 2;
                        continue;
                    }
                }
                if (have == 2){
                    continue;
                }
                updateList.add(manageRoleMenu.get("menu_id"));
                System.out.println("++++++++++++++"+updateList);
            }
            if (have == 2){
                continue;
            }
            updateList.add(manageRoleMenu.get("menu_id"));
        }
        List insertList = new ArrayList();
        for (Object temp:list) {
            int have = 1;
            for (Map manageRoleMenu:result1){
                if (manageRoleMenu.get("menu_id").equals(Integer.parseInt(temp.toString()))){
                    have = 2;
            List insertList = new ArrayList();
            for (Object temp:list) {
                int have = 1;
                for (Map manageRoleMenu:result1){
                    if (manageRoleMenu.get("menu_id").equals(Integer.parseInt(temp.toString()))){
                        have = 2;
                        continue;
                    }
                }
                if (have == 2){
                    continue;
                }
                insertList.add(temp);
            }
            if (have == 2){
                continue;
            if (updateList.size()>0){
                manageRoleMenuMapper.updateDeleteStateByRoleIdMenuIds(updateList,id);
            }
            insertList.add(temp);
        }
        if (updateList.size()>0){
            manageRoleMenuMapper.updateDeleteStateByRoleIdMenuIds(updateList,id);
        }
        if (insertList.size()>0){
            List mapList = new ArrayList();
            for (Object temp:insertList) {
                Map<String,Integer> insertMap = new HashMap<>();
                insertMap.put("role_id",id);
                insertMap.put("menu_id",Integer.parseInt(temp.toString()));
                mapList.add(insertMap);
            if (insertList.size()>0){
                List mapList = new ArrayList();
                for (Object temp:insertList) {
                    Map<String,Integer> insertMap = new HashMap<>();
                    insertMap.put("role_id",id);
                    insertMap.put("menu_id",Integer.parseInt(temp.toString()));
                    mapList.add(insertMap);
                }
                manageRoleMenuMapper.insertBatch(mapList);
            }
            manageRoleMenuMapper.insertBatch(mapList);
        }
        List<ManageMenu> manageMenusNew = manageMenuMapper.getManageMenuByRoleId(id);
        List manageMenuOldList = new ArrayList();
screen-manage/src/main/java/com/moral/api/service/impl/ManageRoleServiceImpl.java
@@ -105,8 +105,8 @@
            return resultMap;
        }
        if (manageRoleMapper.getManageRoleByName(manageRole.getName()) != null){
            resultMap.put("code",ResponseCodeEnum.ROLE_IS_EXPIRE.getCode());
            resultMap.put("msg",ResponseCodeEnum.ROLE_IS_EXPIRE.getMsg());
            resultMap.put("code",ResponseCodeEnum.ROLE_IS_EXIST.getCode());
            resultMap.put("msg",ResponseCodeEnum.ROLE_IS_EXIST.getMsg());
            return resultMap;
        }
        manageRoleMapper.insertOne(manageRole);