自定义内容<shiro:principal>
自定义字段内容
字段名最好与 User 实体一致
@Data
public class UserPrincipal implements Serializable {
private static final long serialVersionUID = 2784409120011781423L;
private Integer id;
private String username;
private String nickname;
private String dingtalkUserId;
private String dingtalkUnionId;
private Integer roleId;
private String roleIds;
private Integer deptId;
private Integer schoolId;
private Integer status;
private Integer deleteFlag;
private Integer type;
private String mobile;
private String email;
private Integer gender;
private String position;
private String avatar;
private Date lastTime;
private String lastIp;
}
设置自定义的Realm
user = loginService.checkLogin(username, password)
默认会获取全部
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(uesr, password, getName());
return info;
按自定格式显示
UserPrincipal principal = new UserPrincipal();
BeanUtils.copyProperties(user, principal);
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(principal, password, getName());
return info;
自定义字段输出
<shiro:principal></shiro:principal>
[UserPrincipal(id=1, dingtalkUserId=u11, dingtalkUnionId=un11, username=admin, nickname=admin, passwordReset=1, roleId=1, roleIds=1, deptId=0, schoolId=2, status=1, deleteFlag=0, type=0, mobile=, email=1@qq.com, gender=2, position=, avatar=, lastTime=null, lastIp=)]