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

28 lines
859 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}