用户 | 描述 |
---|---|
${user.username} | |
${role.roleName} | ${role.roleDesc} |
${p.permissionName} | ${p.url} |
findById方法
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private IUserService userService;
//查询指定id的用户
@RequestMapping("/findById.do")
public ModelAndView findById(String id) throws Exception{
ModelAndView mv = new ModelAndView();
UserInfo userInfo = userService.findById(id);
mv.addObject("user",userInfo);
mv.setViewName("user-show1");
System.out.println(userInfo.getUsername());
return mv;
}
@RequestMapping("/findAll.do")
public ModelAndView findAll()throws Exception{
ModelAndView mv = new ModelAndView();
List userList=userService.findAll();
mv.addObject("userList",userList);
mv.setViewName("user-list");
return mv;
}
@RequestMapping("/save.do")
@PreAuthorize("authentication.principal.username == 'tom'")
public String save(UserInfo userInfo) throws Exception{
userService.save(userInfo);
return "redirect:findAll.do";
}
}
@Override
public UserInfo findById(String id) throws Exception {
return userDao.findById(id);
}
@Select("select * from users where id=#{id}")
@Results({
@Result(id = true, property = "id", column = "id"),
@Result(property = "username", column = "username"),
@Result(property = "email", column = "email"),
@Result(property = "password", column = "password"),
@Result(property = "phoneNum", column = "phoneNum"),
@Result(property = "status", column = "status"),
@Result(property = "roles",column = "id",javaType = java.util.List.class,many = @Many(select = "com.itheima.ssm.dao.IRoleDao.findRoleByUserId"))
})
UserInfo findById(String id) throws Exception;
//根据用户id查询出所有对应的角色
@Select("select * from role where id in (select roleId from users_role where userId=#{userId})")
@Results({
@Result(id = true, property = "id", column = "id"),
@Result(property = "roleName", column = "roleName"),
@Result(property = "roleDesc", column = "roleDesc"),
@Result(property = "permissions",column = "id",javaType = java.util.List.class,many = @Many(select = "com.itheima.ssm.dao.IPermissionDao.findPermissionByRoleId"))
})
public List findRoleByUserId(String userId) throws Exception;
@Select("select * from permission where id in (select permissionId from role_permission where roleId=#{id} )")
public List findPermissionByRoleId(String id) throws Exception;
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
数据 - AdminLTE2定制版
用户管理
用户详情
用户
描述
${user.username}
${role.roleName}
${role.roleDesc}
${p.permissionName}
${p.url}