源码分析:若依用户 user_id查询返回除了用户表,为何还带有部门dept和角色role表呢
通过认真分析SysUser.java
部份源码如下,
private SysDept dept;
以下是toString(){
.append("dept", getDept())
.append("roles", getRoles())
}
package com.ruoyi.common.core.domain.entity; import java.util.Date; import java.util.List; import javax.validation.constraints.*; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.fasterxml.jackson.annotation.JsonIgnore; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.annotation.Excel.Type; import com.ruoyi.common.annotation.Excels; import com.ruoyi.common.core.domain.BaseEntity; /** * 用户对象 sys_user * * @author ruoyi */ public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; private SysDept dept; private List<SysRole> roles; /** 角色组 */ private Long[] roleIds; /** 岗位组 */ private Long[] postIds; public SysDept getDept() { if (dept == null) { dept = new SysDept(); } return dept; } public void setDept(SysDept dept) { this.dept = dept; } public List<SysRole> getRoles() { return roles; } public void setRoles(List<SysRole> roles) { this.roles = roles; } public Long[] getRoleIds() { return roleIds; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("userId", getUserId()) .append("deptId", getDeptId()) .append("loginName", getLoginName()) .append("userName", getUserName()) .append("userType", getUserType()) .append("email", getEmail()) .append("phonenumber", getPhonenumber()) .append("sex", getSex()) .append("avatar", getAvatar()) .append("password", getPassword()) .append("salt", getSalt()) .append("status", getStatus()) .append("delFlag", getDelFlag()) .append("loginIp", getLoginIp()) .append("loginDate", getLoginDate()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("dept", getDept()) .append("roles", getRoles()) .toString(); } }
做产品的程序,才是好的程序员!