我将仇恨写在冰上,然后期待太阳的升起。——加西亚马尔克斯

这里Opt用的是之前博客提到的复制修改过的Optional

https://VampireAchao.gitee.io/2021/07/19/新版Optional/

shaun我之前也稍微写过:https://VampireAchao.gitee.io/2021/09/02/shaun/

代码很简单:

1
2
3
4
5
6
7
8
9
10
11
/**
* 获取用户信息
*
* @return com.baomidou.shaun.core.profile.TokenProfile
* @author <achao1441470436@gmail.com>
* @since 2021/9/9 10:33
*/
public static Opt<TokenProfile> getProfile() {
final JEEContext context = WebUtil.getJEEContext(false);
return Opt.ofNullable(CORE_CONFIG.getProfileTokenManager().getProfile(context));
}

参考的是shaun源码中com.baomidou.shaun.core.filter中的写法