car-park/cf-file/cf-file-api/src/main/java/com/cf/file/api/controller/BaseController.java

28 lines
859 B
Java
Raw Normal View History

2020-06-18 14:39:34 +08:00
package com.cf.file.api.controller;
import com.alibaba.fastjson.JSON;
import com.cf.framework.domain.ucenter.ext.UserBasicInfo;
import com.cf.framework.utils.HttpHearderUtils;
import com.cf.ucenter.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
public class BaseController {
@Autowired
protected HttpServletRequest request;
protected UserBasicInfo userBasicInfo;
/**
* 解析jwt令牌获取基础的用户信息
* @param authService
*/
protected void getUserBasicInfoByJwt(AuthService authService)
{
//取到jwt令牌
String jwt = HttpHearderUtils.getAuthorization(request);
String jwtToken = authService.checkJwtToken(jwt);
userBasicInfo = JSON.parseObject(jwtToken, UserBasicInfo.class);
}
}