您的位置:首页 > 娱乐 > 明星 > 邯郸做网站优化_网站开发近期市场_营销方法有哪几种_宁德seo推广

邯郸做网站优化_网站开发近期市场_营销方法有哪几种_宁德seo推广

2024/12/21 22:28:41 来源:https://blog.csdn.net/xiugtt6141121/article/details/142768935  浏览:    关键词:邯郸做网站优化_网站开发近期市场_营销方法有哪几种_宁德seo推广
邯郸做网站优化_网站开发近期市场_营销方法有哪几种_宁德seo推广

角色处理器

2.1 分页查询当前角色信息

1)原型效果

在这里插入图片描述

2)接口说明
功能描述: 分页查询当前角色信息
服务路径: /api/roles
服务方法:Post

请求参数格式:

{"pageNum":1,"pageSize":10
}

响应数据格式:

{"code": 1,"data": {"totalRows": 10,"totalPages": 1,"pageNum": 1,"pageSize": 10,"size": 10,"rows": [{"id": 1237258113002901512,"name": "超级管理员","description": "我是超级管理员","status": 1,"createTime": "2020-01-06T15:37:45.000+00:00","updateTime": "2021-12-09T23:08:02.000+00:00","deleted": 1},{"id": 1237258113002901513,"name": "标记用户角色测试","description": "标记用户角色测试","status": 1,"createTime": "2020-01-08T02:53:35.000+00:00","updateTime": "2021-12-28T10:16:21.000+00:00","deleted": 1},//.........]}
}

代码实现

1. 表现层
    /*** 分页查询角色信息*/@ApiOperation(value = "分页查询角色信息")@PostMapping("/roles")public R<RoleDataRespVo> getRolesData(@RequestBody HashMap<String,Object> pageMsg){return UserService.getRolesData(pageMsg);
2. 服务层
R<RoleDataRespVo> getRolesData(HashMap<String, Object> pageMsg);
@Overridepublic R<RoleDataRespVo> getRolesData(HashMap<String, Object> pageMsg) {// 设置分页参数Integer pageNum = (Integer) pageMsg.get("pageNum");Integer pageSize = (Integer) pageMsg.get("pageSize");PageHelper.startPage(pageNum, pageSize);// 获取数据ArrayList<SysRole> allRole = sysRoleMapper.getAllRole();PageInfo<SysRole> sysRolePageInfo = new PageInfo<>(allRole);RoleDataRespVo roleDataRespVo = new RoleDataRespVo(sysRolePageInfo);return R.ok(roleDataRespVo);}
3. Dao层
ArrayList<SysRole> getAllRole();
    <select id="getAllRole" resultType="com.jixu.stock.pojo.entity.SysRole">select id,name,description,status,create_time,update_time,deletedfrom sys_role</select>

2.2 添加角色回显权限选项功能-1

1)原型效果

在这里插入图片描述

2)接口说明
功能描述: 树状结构回显权限集合,底层通过递归获取权限数据集合
服务路径: /api/permissions/tree/all
服务方法:GET
请求参数:无

响应格式:

{"code": 1,"data": [{"id": "1236916745927790564","title": "组织管理","icon": "el-icon-menu","path": "/org","name": "org","children": [{"id": "1236916745927790560","title": "菜单权限管理","icon": "el-icon-menu","path": "/menus","name": "menus","children": [{"id": "1236916745927790563","title": "删除菜单权限","icon": "","path": "/api/permission","name": "","children": []},{"id": "1236916745927790565","title": "查询菜单权限列表权限","icon": "","path": "/api/permissions","name": "","children": []},{"id": "1236916745927790577","title": "更新菜单权限","icon": "","path": "/api/permission","name": "","children": []},{"id": "1236916745927790582","title": "新增菜单权限","icon": "","path": "/api/permission","name": "","children": []}]},{"id": "1236916745927790575","title": "用户管理","icon": "el-icon-user-solid","path": "/user","name": "user","children": [{"id": "1236916745927790556","title": "删除用户权限","icon": "","path": "/api/user","name": "","children": []},{"id": "1236916745927790561","title": "新增用户权限","icon": "","path": "/api/user","name": "","children": []},{"id": "1236916745927790568","title": "查询用户信息列表权限","icon": "","path": "/api/users","name": "","children": []},{"id": "1236916745927790579","title": "赋予用户角色权限","icon": "","path": "/api/user/roles","name": "","children": []},{"id": "1236916745927790580","title": "更新用户信息权限","icon": "","path": "/api/user","name": "","children": []}]},{"id": "1236916745927790578","title": "角色管理","icon": "el-icon-user","path": "/roles","name": "roles","children": [{"id": "1236916745927790562","title": "更新角色权限","icon": "","path": "/api/role","name": "","children": []},{"id": "1236916745927790570","title": "删除角色权限","icon": "","path": "/api/role/*","name": "","children": []},{"id": "1236916745927790572","title": "新增角色权限","icon": "","path": "/api/role","name": "","children": []},{"id": "1236916745927790574","title": "角色详情权限","icon": "","path": "/api/role/*","name": "","children": []},{"id": "1236916745927790583","title": "查询角色列表权限","icon": "","path": "/api/roles","name": "","children": []}]}]},{//......}]}       

代码实现

1. 表现层
    @ApiOperation(value = "添加角色回显权限选项")@GetMapping("/permissions/tree/all")public R<ArrayList<PermissionDomain>> getRolesPermission(){return UserService.getRolesPermission();}
2. 服务层
R<ArrayList<PermissionDomain>> getRolesPermission();
    @Overridepublic R<ArrayList<PermissionDomain>> getRolesPermission() {// 获取所有的权限信息List<HashMap<String ,Object>> allPermission =  sysPermissionMapper.getAllPermission();// 制作映射集合HashMap<Long, PermissionDomain> permissionMap = new HashMap<>();// 获取树的父节点ArrayList<PermissionDomain> permissionParentList = new ArrayList<>();for (HashMap<String, Object> map : allPermission) {PermissionDomain permissionDomain = new PermissionDomain();permissionDomain.setId((Long) map.get("id"));permissionDomain.setPid((Long) map.get("pid"));permissionDomain.setIcon((String) map.get("icon"));permissionDomain.setPath((String) map.get("url"));permissionDomain.setName((String) map.get("name"));permissionDomain.setTitle((String) map.get("title"));permissionDomain.setChildren(new ArrayList<>());permissionDomain.setChildren(new ArrayList<>());Long id = (Long) map.get("id");Long pid = (Long) map.get("pid");permissionMap.put(id,permissionDomain);if (pid.equals(Long.valueOf(0))){permissionParentList.add(permissionDomain);}}List<PermissionDomain> treeData = buildTree(permissionMap, Long.valueOf(0));/*** 迭代方式*///        // 用于快速查找子菜单的映射
//        HashMap<Long, ArrayList<PermissionDomain>> mapList = new HashMap<>();
//        /**
//         * 在这里循环所有对象 , 将每个对象的pid( pid 指向于 id )也就是说一个id对应多个pid
//         * 将所有pid 指向的对象 , 封装到一个列表 , 则该列表就是它的父id所对应的列表
//         */
//        for (HashMap<String, Object> map : allPermission) {
//            Long pid = (Long) map.get("pid");
//            Long id = (Long) map.get("id");
//
//            // 获取主键对象
//            PermissionDomain permissionObject = permissionMap.get(id);
//
//            if (permissionObject != null){
//                mapList.computeIfAbsent(pid , k -> new ArrayList<>()).add(permissionObject);
//            }
//        }
//
//        for (PermissionDomain parentPermission : permissionParentList) {
//            Long parentId = Long.valueOf(parentPermission.getId());
//            ArrayList<PermissionDomain> childrenList = new ArrayList<>();
//            // 如果父菜单包含在内
//            if (mapList.containsKey(parentId)){
//                // 获取父菜单所对应的子菜单
//                ArrayList<PermissionDomain> permissinSonList = mapList.get(parentId);
//                // 循环所有子菜单
//                for (PermissionDomain permissionSon : permissinSonList) {
//                    Long id = permissionSon.getId();
//                    // 判断子菜单是否还含有下一级菜单
//                    ArrayList<PermissionDomain> orDefault = mapList.getOrDefault(id, new ArrayList<>());
//                    permissionSon.setChildren(orDefault);
//
//                }
//                childrenList.addAll(permissinSonList);
//            }
//            parentPermission.setChildren(childrenList);
//        }
//return R.ok(new ArrayList<>(treeData));}
3. Dao层
List<HashMap<String, Object>> getAllPermission();
    <select id="getAllPermission" resultType="java.util.HashMap">select id,code,title,icon,url,name,pidfrom sys_permission;</select>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com