10.权限关联与控制
11.AOP日志
10.权限关联与控制
1.用户关联角色操作-流程分析
项目运行的网络环境发生变化后,实际上就是我笔记本电脑 所连接到的路由器发生变更。需要用cmd下的ipconfig命令查看当前主机IP地址,然后去web子模块项目的resources目录下把jdbc.properties配置文件的
jdbc.url=jdbc:oracle:thin:@192.168.0.108:1521:orcl 做修改后重新install一下WEB项目再测试就跑通了。
2.用户关联角色操作-代码实现
视图层的UsersControler
//查询用户以及可以添加的角色 @RequestMapping("/findUserByIdAndAllRole.do") public ModelAndView findUserByIdAndAllRole(@RequestParam(name = "id") String userId)throws Exception{ ModelAndView mv = new ModelAndView(); //1.根据一个用户ID查询结果 UserInfo userInfo = userService.findById(userId); //2.根据用户ID查询可以添加的角色 List<Role> othersRoles = userService.findOthersRoles(userId); mv.addObject("user",userInfo); mv.addObject("rolesList",othersRoles); mv.setViewName("user-role-add2"); return mv; }
DAO层的 IUserDao
// where not in () @Select("select * from role where id not in (select roleId from users_role where userId = #{userId}) ") List<Role> findOthersRoles(String userId);
====================
end