热门

最新

红包

立Flag

投票

同城

我的

发布
jailman
大囚长
4 年前
truejailman

“生命游戏”一定可以有更复杂的形式,通过不断的进化也许能在计算机中形成初步的文明。AI可以像人一样通过电力和数据的浇灌来成长。

CSDN App 扫码分享
分享
评论
2
打赏
  • 复制链接
  • 举报
下一条:
//获取登录用户信息 public CsmallAuthenticationInfo getUserInfo(){ // 获得SpringSecurity上下文(容器)对象 UsernamePasswordAuthenticationToken authenticationToken= (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext() .getAuthentication(); if(authenticationToken==null){ throw new CoolSharkServiceException(ResponseCode.UNAUTHORIZED,"没有登录信息"); } // 如果authenticationToken不为空,获得其中的用户信息 CsmallAuthenticationInfo csmallAuthenticationInfo= (CsmallAuthenticationInfo) authenticationToken.getCredentials(); // 返回登录用户信息 return csmallAuthenticationInfo; } // 业务逻辑层大多数方法都是需要获得用户Id,所以我们编写一个方法,专门返回当前登录用户的id public Long getUserId(){ return getUserInfo().getId(); }
立即登录