package com.itheima.domain; import java.io.Serializable; import java.util.Date; import java.util.List; /** * @author 黑马程序员 * @Company http://www.ithiema.com */ public class User implements Serializable { private Integer id; private String username; private String address; private String sex; private Date birthday; //多对多的关系映射:一个用户可以具备多个角色 private Listroles; public List getRoles() { return roles; } public void setRoles(List roles) { this.roles = roles; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } @Override public String toString() { return "User{" + "id=" + id + ", username='" + username + '\'' + ", address='" + address + '\'' + ", sex='" + sex + '\'' + ", birthday=" + birthday + '}'; } }
package com.itheima.domain; import java.io.Serializable; import java.util.List; /** * @author 黑马程序员 * @Company http://www.ithiema.com */ public class Role implements Serializable { private Integer roleId; private String roleName; private String roleDesc; //多对多的关系映射:一个角色可以赋予多个用户 private Listusers; public List getUsers() { return users; } public void setUsers(List users) { this.users = users; } public Integer getRoleId() { return roleId; } public void setRoleId(Integer roleId) { this.roleId = roleId; } public String getRoleName() { return roleName; } public void setRoleName(String roleName) { this.roleName = roleName; } public String getRoleDesc() { return roleDesc; } public void setRoleDesc(String roleDesc) { this.roleDesc = roleDesc; } @Override public String toString() { return "Role{" + "roleId=" + roleId + ", roleName='" + roleName + '\'' + ", roleDesc='" + roleDesc + '\'' + '}'; } }
package com.itheima.dao; import com.itheima.domain.Role; import java.util.List; /** * @author 黑马程序员 * @Company http://www.ithiema.com */ public interface IRoleDao { /** * 查询所有角色 * @return */ ListfindAll(); }
package com.itheima.dao; import com.itheima.domain.User; import java.util.List; /** * @author 黑马程序员 * @Company http://www.ithiema.com * * 用户的持久层接口 */ public interface IUserDao { /** * 查询所有用户,同时获取到用户下所有账户的信息 * @return */ ListfindAll(); /** * 根据id查询用户信息 * @param userId * @return */ User findById(Integer userId); }
DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">