上传代码

This commit is contained in:
xxy
2020-05-02 15:05:21 +08:00
parent c8c80fa719
commit ed34c67d08
733 changed files with 61899 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package com.java2nb.novel.controller;
import com.java2nb.novel.core.bean.UserDetails;
import com.java2nb.novel.core.utils.JwtTokenUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
/**
* @author 11797
*/
public class BaseController {
protected JwtTokenUtil jwtTokenUtil;
protected String getToken(HttpServletRequest request){
Cookie[] cookies = request.getCookies();
if(cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("Authorization")) {
return cookie.getValue();
}
}
}
return request.getHeader("Authorization");
}
protected UserDetails getUserDetails(HttpServletRequest request) {
String token = getToken(request);
if(StringUtils.isBlank(token)){
return null;
}else{
return jwtTokenUtil.getUserDetailsFromToken(token);
}
}
@Autowired
public void setJwtTokenUtil(JwtTokenUtil jwtTokenUtil) {
this.jwtTokenUtil = jwtTokenUtil;
}
}