自动注入HttpServletRequest

This commit is contained in:
小海
2019-12-04 14:43:10 +08:00
parent 86bb5e1b13
commit 450f308f1e
6 changed files with 17 additions and 15 deletions

View File

@@ -20,16 +20,18 @@ public class RedisUserUtil {
RedisUtil redisUtil;
@Autowired
JwtUtil jwtUtil;
@Autowired
HttpServletRequest request;
public User get(HttpServletRequest request) {
User user = getWithOutExc(request);
public User get() {
User user = getWithOutExc();
if (user == null) {
throw new MyException(ResponseEnum.HAVE_NOT_LOG_IN);
}
return user;
}
public User getWithOutExc(HttpServletRequest request) {
public User getWithOutExc() {
String token = request.getHeader("Authorization");
if (token == null || token.isEmpty()) {
return null;