Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李丛阳
education
Commits
11ebf448
Commit
11ebf448
authored
Nov 28, 2017
by
李丛阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
education init 1.02
parent
f2a7f11e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
22 deletions
+57
-22
MvcConfig.java
src/main/java/org/rcisoft/config/MvcConfig.java
+13
-13
JwtUtil.java
src/main/java/org/rcisoft/core/util/JwtUtil.java
+11
-1
UserUtil.java
src/main/java/org/rcisoft/core/util/UserUtil.java
+25
-0
application-dev.yml
src/main/resources/application-dev.yml
+4
-4
application-prod.yml
src/main/resources/application-prod.yml
+4
-4
No files found.
src/main/java/org/rcisoft/config/MvcConfig.java
View file @
11ebf448
...
...
@@ -59,19 +59,19 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
super
.
addResourceHandlers
(
registry
);
}
/
/
使用阿里 FastJson 作为JSON MessageConverter
//
@Override
//
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
//
FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4();
//
FastJsonConfig config = new FastJsonConfig();
//
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
//
SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
//
SerializerFeature.WriteNullNumberAsZero);//Number null -> 0
//
converter.setFastJsonConfig(config);
//
converter.setDefaultCharset(Charset.forName("UTF-8"));
//
converters.add(converter);
//
}
/
*
使用阿里 FastJson 作为JSON MessageConverter
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter4 converter = new FastJsonHttpMessageConverter4();
FastJsonConfig config = new FastJsonConfig();
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
SerializerFeature.WriteNullNumberAsZero);//Number null -> 0
converter.setFastJsonConfig(config);
converter.setDefaultCharset(Charset.forName("UTF-8"));
converters.add(converter);
}
*/
//统一异常处理
@Override
...
...
src/main/java/org/rcisoft/core/util/JwtUtil.java
View file @
11ebf448
...
...
@@ -69,5 +69,15 @@ public class JwtUtil {
else
return
false
;
}
/*
获取 user claims
*/
public
static
Claims
getUserClaimsFromToken
(
String
token
){
try
{
Claims
claims
=
jwtBean
.
getClaimsFromToken
(
token
);
return
claims
;
}
catch
(
Exception
e
){
return
null
;
}
}
}
src/main/java/org/rcisoft/core/util/UserUtil.java
0 → 100644
View file @
11ebf448
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
();
}
}
src/main/resources/application-dev.yml
View file @
11ebf448
...
...
@@ -5,10 +5,10 @@ server:
max-threads
:
300
#uri-encoding: UTF-8
logging
:
level
:
root
:
INFO
org.springframework.web
:
DEBUG
#
logging:
#
level:
#
root: INFO
#
org.springframework.web: DEBUG
druid
:
url
:
jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
...
...
src/main/resources/application-prod.yml
View file @
11ebf448
...
...
@@ -4,10 +4,10 @@ server:
tomcat
:
max-threads
:
300
logging
:
level
:
root
:
INFO
org.springframework.web
:
DEBUG
#
logging:
#
level:
#
root: INFO
#
org.springframework.web: DEBUG
druid
:
url
:
jdbc:mysql://127.0.0.1:3306/boot?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment