JAVA----自定义`<shiro:principal>` 内容

自定义内容<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=)]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值