Commit 11ebf448 authored by 李丛阳's avatar 李丛阳

education init 1.02

parent f2a7f11e
...@@ -59,19 +59,19 @@ public class MvcConfig extends WebMvcConfigurerAdapter { ...@@ -59,19 +59,19 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
super.addResourceHandlers(registry); super.addResourceHandlers(registry);
} }
//使用阿里 FastJson 作为JSON MessageConverter /*使用阿里 FastJson 作为JSON MessageConverter
// @Override @Override
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
// FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4(); FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4();
// FastJsonConfig config = new FastJsonConfig(); FastJsonConfig config = new FastJsonConfig();
// config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段 config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
// SerializerFeature.WriteNullStringAsEmpty,//String null -> "" SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
// SerializerFeature.WriteNullNumberAsZero);//Number null -> 0 SerializerFeature.WriteNullNumberAsZero);//Number null -> 0
// converter.setFastJsonConfig(config); converter.setFastJsonConfig(config);
// converter.setDefaultCharset(Charset.forName("UTF-8")); converter.setDefaultCharset(Charset.forName("UTF-8"));
// converters.add(converter); converters.add(converter);
// } }
*/
//统一异常处理 //统一异常处理
@Override @Override
......
...@@ -69,5 +69,15 @@ public class JwtUtil { ...@@ -69,5 +69,15 @@ public class JwtUtil {
else else
return false; return false;
} }
/*
获取 user claims
*/
public static Claims getUserClaimsFromToken(String token){
try {
Claims claims = jwtBean.getClaimsFromToken(token);
return claims;
}catch (Exception e){
return null;
}
}
} }
package org.rcisoft.core.util;
import io.jsonwebtoken.Claims;
/**
* Created by lcy on 17/11/28.
*/
public class UserUtil {
/**
* 用户id
*/
public static final String USER_ID = "businessId";
/**
* 获取用户信息
* @param token
* @param prop
* @return
*/
public static String getUserInfoProp(String token,String prop){
Claims claims = JwtUtil.getUserClaimsFromToken(token);
return claims.get(prop).toString();
}
}
...@@ -5,10 +5,10 @@ server: ...@@ -5,10 +5,10 @@ server:
max-threads: 300 max-threads: 300
#uri-encoding: UTF-8 #uri-encoding: UTF-8
logging: #logging:
level: # level:
root: INFO # root: INFO
org.springframework.web: DEBUG # org.springframework.web: DEBUG
druid: druid:
url: jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true url: jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
......
...@@ -4,10 +4,10 @@ server: ...@@ -4,10 +4,10 @@ server:
tomcat: tomcat:
max-threads: 300 max-threads: 300
logging: #logging:
level: # level:
root: INFO # root: INFO
org.springframework.web: DEBUG # org.springframework.web: DEBUG
druid: druid:
url: jdbc:mysql://127.0.0.1:3306/boot?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true url: jdbc:mysql://127.0.0.1:3306/boot?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment