@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); return result; } }
@Override public Set<Role> findRoles(String account) { UserExample example = new UserExample(); example.createCriteria().andAccountEqualTo(account); List<User> users = userMapper.selectByExample(example); Set<Role> roles = new HashSet<>(); if (CollectionUtils.hasUniqueObject(users)) { User user = users.get(0); UserRoleExample secUserRoleExample = new UserRoleExample(); secUserRoleExample.createCriteria().andUserIdEqualTo(user.getId()); List<UserRole> userRoles = userRoleMapper.selectByExample(secUserRoleExample); for (UserRole userRole : userRoles) { roles.add(roleMapper.selectByPrimaryKey(userRole.getRoleId())); } } return roles; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", userId=").append(userId); sb.append(", roleId=").append(roleId); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); sb.append("]"); return sb.toString(); }
@Override public boolean equals(Object that) { if (this == that) { return true; } if (that == null) { return false; } if (getClass() != that.getClass()) { return false; } UserRole other = (UserRole) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())); }