Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
xiaolang
/
expert
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
44e3a8d0
authored
Apr 22, 2020
by
xiaolang850403
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加token校验
parent
78086f7c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
24 additions
and
16 deletions
+24
-16
src/main/java/com/asset/controller/UserController.java
+2
-2
src/main/java/com/asset/controller/admin/AdminController.java
+2
-2
src/main/java/com/asset/controller/admin/FailLogController.java
+1
-1
src/main/java/com/asset/controller/system/AreaController.java
+2
-2
src/main/java/com/asset/core/filter/CorsFilter.java
+1
-1
src/main/java/com/asset/core/filter/TokenInterceptor.java
+3
-0
src/main/java/com/asset/core/jwt/JWTConfiguration.java
+5
-0
src/main/java/com/asset/core/jwt/TokenUtil.java
+2
-2
src/main/java/com/asset/domain/User.java
+6
-6
No files found.
src/main/java/com/asset/controller/UserController.java
View file @
44e3a8d0
...
@@ -204,8 +204,8 @@ public class UserController {
...
@@ -204,8 +204,8 @@ public class UserController {
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
return
ResultUtil
.
Validated
(
result
);
return
ResultUtil
.
Validated
(
result
);
}
}
String
pass
=
MD5Util
.
getEncryption
(
user
.
getPassword
());
//
String pass = MD5Util.getEncryption(user.getPassword());
user
.
setPassword
(
pass
);
//
user.setPassword(pass);
userService
.
updateById
(
user
);
userService
.
updateById
(
user
);
if
(
user
.
getId
()
!=
null
){
if
(
user
.
getId
()
!=
null
){
//删除凭证的旧数据
//删除凭证的旧数据
...
...
src/main/java/com/asset/controller/admin/AdminController.java
View file @
44e3a8d0
...
@@ -57,13 +57,13 @@ public class AdminController {
...
@@ -57,13 +57,13 @@ public class AdminController {
public
final
String
refuse
=
"审核不通过,原因:"
;
public
final
String
refuse
=
"审核不通过,原因:"
;
@RequestMapping
(
value
=
"/getUserList"
)
@RequestMapping
(
value
=
"/getUserList"
)
public
Result
getUserList
(
@RequestParam
(
defaultValue
=
"1"
)
int
currentP
age
,
@RequestParam
(
defaultValue
=
"10"
)
int
per
,
User
user
)
{
public
Result
getUserList
(
@RequestParam
(
defaultValue
=
"1"
)
int
p
age
,
@RequestParam
(
defaultValue
=
"10"
)
int
per
,
User
user
)
{
QueryWrapper
<
User
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
User
>
queryWrapper
=
new
QueryWrapper
<>();
if
(
user
.
getState
()
!=
null
){
if
(
user
.
getState
()
!=
null
){
queryWrapper
.
eq
(
"state"
,
user
.
getState
()).
or
().
eq
(
"name"
,
user
.
getName
()).
or
().
eq
(
"mobile"
,
user
.
getMobile
()).
or
().
eq
(
"email"
,
user
.
getEmail
()).
or
().
eq
(
"employer"
,
user
.
getEmployer
());
queryWrapper
.
eq
(
"state"
,
user
.
getState
()).
or
().
eq
(
"name"
,
user
.
getName
()).
or
().
eq
(
"mobile"
,
user
.
getMobile
()).
or
().
eq
(
"email"
,
user
.
getEmail
()).
or
().
eq
(
"employer"
,
user
.
getEmployer
());
}
}
//List list = userService.list(queryWrapper);
//List list = userService.list(queryWrapper);
PageHelper
.
startPage
(
currentP
age
,
per
);
PageHelper
.
startPage
(
p
age
,
per
);
Map
map
=
Pagination
.
Pagination
(
userService
.
list
(
queryWrapper
));
Map
map
=
Pagination
.
Pagination
(
userService
.
list
(
queryWrapper
));
return
ResultUtil
.
success
(
CodeEnum
.
SUCCESS
,
map
);
return
ResultUtil
.
success
(
CodeEnum
.
SUCCESS
,
map
);
}
}
...
...
src/main/java/com/asset/controller/admin/FailLogController.java
View file @
44e3a8d0
...
@@ -27,7 +27,7 @@ public class FailLogController {
...
@@ -27,7 +27,7 @@ public class FailLogController {
@GetMapping
(
"/getFailLogByUid"
)
@GetMapping
(
"/getFailLogByUid"
)
public
Result
getFailLogByUid
(
int
user_id
)
{
public
Result
getFailLogByUid
(
int
user_id
)
{
QueryWrapper
<
FailLog
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
FailLog
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"userid"
,
user_id
);
queryWrapper
.
eq
(
"user
_
id"
,
user_id
);
List
<
FailLog
>
list
=
failLogService
.
list
(
queryWrapper
);
List
<
FailLog
>
list
=
failLogService
.
list
(
queryWrapper
);
return
ResultUtil
.
success
(
CodeEnum
.
SUCCESS
,
list
);
return
ResultUtil
.
success
(
CodeEnum
.
SUCCESS
,
list
);
}
}
...
...
src/main/java/com/asset/controller/system/AreaController.java
View file @
44e3a8d0
...
@@ -24,9 +24,9 @@ public class AreaController {
...
@@ -24,9 +24,9 @@ public class AreaController {
AreaService
areaService
;
AreaService
areaService
;
@GetMapping
(
"/getAreaList"
)
@GetMapping
(
"/getAreaList"
)
public
Result
getAreaList
(
int
p
id
)
{
public
Result
getAreaList
(
int
id
)
{
QueryWrapper
<
Area
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
Area
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"pid"
,
p
id
);
queryWrapper
.
eq
(
"pid"
,
id
);
List
<
Area
>
list
=
areaService
.
list
(
queryWrapper
);
List
<
Area
>
list
=
areaService
.
list
(
queryWrapper
);
return
ResultUtil
.
success
(
CodeEnum
.
SUCCESS
,
list
);
return
ResultUtil
.
success
(
CodeEnum
.
SUCCESS
,
list
);
}
}
...
...
src/main/java/com/asset/core/filter/CorsFilter.java
View file @
44e3a8d0
package
com
.
asset
.
core
.
enums
.
filter
;
package
com
.
asset
.
core
.
filter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
...
src/main/java/com/asset/core/filter/TokenInterceptor.java
View file @
44e3a8d0
...
@@ -53,6 +53,7 @@ public class TokenInterceptor implements HandlerInterceptor {
...
@@ -53,6 +53,7 @@ public class TokenInterceptor implements HandlerInterceptor {
queryWrapper
.
eq
(
"mobile"
,
mobile
);
queryWrapper
.
eq
(
"mobile"
,
mobile
);
User
user
=
userService
.
getOne
(
queryWrapper
);
User
user
=
userService
.
getOne
(
queryWrapper
);
//比较数据库里token的refexpire的最长期限
//比较数据库里token的refexpire的最长期限
if
(
user
!=
null
){
if
(
Common
.
getStringToDate
(
user
.
getLoginTime
())+
Long
.
valueOf
(
user
.
getRefexpire
())
>
System
.
currentTimeMillis
()){
if
(
Common
.
getStringToDate
(
user
.
getLoginTime
())+
Long
.
valueOf
(
user
.
getRefexpire
())
>
System
.
currentTimeMillis
()){
System
.
out
.
println
(
"刷新token,生成新的token"
);
System
.
out
.
println
(
"刷新token,生成新的token"
);
token
=
TokenUtil
.
sign
(
mobile
.
toString
());
token
=
TokenUtil
.
sign
(
mobile
.
toString
());
...
@@ -72,6 +73,8 @@ public class TokenInterceptor implements HandlerInterceptor {
...
@@ -72,6 +73,8 @@ public class TokenInterceptor implements HandlerInterceptor {
response
.
getWriter
().
append
(
json
.
toJSONString
());
response
.
getWriter
().
append
(
json
.
toJSONString
());
return
false
;
return
false
;
}
}
}
return
false
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
response
.
sendError
(
500
);
response
.
sendError
(
500
);
...
...
src/main/java/com/asset/core/jwt/JWTConfiguration.java
View file @
44e3a8d0
...
@@ -23,6 +23,11 @@ public class JWTConfiguration implements WebMvcConfigurer {
...
@@ -23,6 +23,11 @@ public class JWTConfiguration implements WebMvcConfigurer {
System
.
out
.
println
(
"*****"
);
System
.
out
.
println
(
"*****"
);
List
<
String
>
excludePath
=
new
ArrayList
<>();
List
<
String
>
excludePath
=
new
ArrayList
<>();
//对以下资源请求不进行拦截和验证
//对以下资源请求不进行拦截和验证
excludePath
.
add
(
"/user/register"
);
excludePath
.
add
(
"/upload/oss"
);
excludePath
.
add
(
"/area/getAreaList"
);
excludePath
.
add
(
"/job/getJobList"
);
excludePath
.
add
(
"/user/checkMobile"
);
excludePath
.
add
(
"/login"
);
//登录
excludePath
.
add
(
"/login"
);
//登录
registry
.
addInterceptor
(
tokenInterceptor
)
registry
.
addInterceptor
(
tokenInterceptor
)
...
...
src/main/java/com/asset/core/jwt/TokenUtil.java
View file @
44e3a8d0
...
@@ -8,8 +8,8 @@ import com.auth0.jwt.algorithms.Algorithm;
...
@@ -8,8 +8,8 @@ import com.auth0.jwt.algorithms.Algorithm;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
public
class
TokenUtil
{
public
class
TokenUtil
{
//过期时间
//过期时间
(10小时)
private
static
final
long
EXPIRE_TIME
=
1
*
60
*
1000
;
private
static
final
long
EXPIRE_TIME
=
1
*
60
*
60
*
1000
;
//使用静态的字符密文或者key来获取算法器,token秘钥,请勿泄露,请勿随便修改
//使用静态的字符密文或者key来获取算法器,token秘钥,请勿泄露,请勿随便修改
private
static
final
String
TOKEN_SECRET
=
"expert"
;
//密钥盐
private
static
final
String
TOKEN_SECRET
=
"expert"
;
//密钥盐
...
...
src/main/java/com/asset/domain/User.java
View file @
44e3a8d0
...
@@ -97,22 +97,22 @@ public class User implements Serializable {
...
@@ -97,22 +97,22 @@ public class User implements Serializable {
private
String
expertTypeValue
;
private
String
expertTypeValue
;
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
String
expert
;
//专家凭证
private
String
expert
;
//专家凭证
(入库用)
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
String
recom
;
//推荐凭证
private
String
recom
;
//推荐凭证
(入库用)
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
String
other
;
//其他凭证
private
String
other
;
//其他凭证
(入库用)
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
List
reexpert
;
//专家凭证
private
List
reexpert
;
//专家凭证
(展示)
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
List
rerecom
;
//推荐凭证
private
List
rerecom
;
//推荐凭证
(展示)
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
List
reother
;
//其他凭证
private
List
reother
;
//其他凭证
(展示)
private
String
expertRange
;
private
String
expertRange
;
...
...
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