Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fzm-joying
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
lei
fzm-joying
Commits
f0082832
Commit
f0082832
authored
Jul 16, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增登出接口
nft详情接口加入是否收藏字段
parent
73a24985
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
8 deletions
+33
-8
InterceptorConfig.java
...rc/main/java/com/fzm/common/config/InterceptorConfig.java
+2
-1
NftVo.java
...-common/src/main/java/com/fzm/common/entity/vo/NftVo.java
+4
-0
UserServiceImpl.java
...ain/java/com/fzm/common/service/impl/UserServiceImpl.java
+1
-1
JwtUtil.java
...ng-common/src/main/java/com/fzm/common/utils/JwtUtil.java
+4
-3
NftController.java
...rc/main/java/com/fzm/portal/controller/NftController.java
+11
-1
UserController.java
...c/main/java/com/fzm/portal/controller/UserController.java
+9
-0
LyPortalApplicationTests.java
...rc/test/java/com/fzm/portal/LyPortalApplicationTests.java
+2
-2
No files found.
joying-common/src/main/java/com/fzm/common/config/InterceptorConfig.java
View file @
f0082832
...
@@ -12,7 +12,8 @@ public class InterceptorConfig implements WebMvcConfigurer {
...
@@ -12,7 +12,8 @@ public class InterceptorConfig implements WebMvcConfigurer {
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
authenticationInterceptor
())
registry
.
addInterceptor
(
authenticationInterceptor
())
.
addPathPatterns
(
"/**"
);
// 拦截所有请求,通过判断是否有 @LoginRequired 注解 决定是否需要登录
.
excludePathPatterns
(
"/user/login"
,
"/admin/login"
,
"/verificationCode/send/sms"
)
.
addPathPatterns
(
"/**"
);
}
}
@Bean
@Bean
public
AuthenticationInterceptor
authenticationInterceptor
()
{
public
AuthenticationInterceptor
authenticationInterceptor
()
{
...
...
joying-common/src/main/java/com/fzm/common/entity/vo/NftVo.java
View file @
f0082832
...
@@ -56,6 +56,9 @@ public class NftVo {
...
@@ -56,6 +56,9 @@ public class NftVo {
@ApiModelProperty
(
"授权阅读 0-不需要授权 1-需要授权"
)
@ApiModelProperty
(
"授权阅读 0-不需要授权 1-需要授权"
)
private
Integer
isGrant
;
private
Integer
isGrant
;
@ApiModelProperty
(
"是否收藏"
)
private
Boolean
collection
;
@ApiModelProperty
(
"关于nft"
)
@ApiModelProperty
(
"关于nft"
)
private
String
aboutNft
;
private
String
aboutNft
;
...
@@ -73,5 +76,6 @@ public class NftVo {
...
@@ -73,5 +76,6 @@ public class NftVo {
this
.
publishTime
=
DateUtil
.
format
(
nft
.
getPublishTime
(),
"yyyy/MM/dd HH:mm:ss"
);
this
.
publishTime
=
DateUtil
.
format
(
nft
.
getPublishTime
(),
"yyyy/MM/dd HH:mm:ss"
);
this
.
isArchives
=
nft
.
getIsArchives
();
this
.
isArchives
=
nft
.
getIsArchives
();
this
.
isGrant
=
nft
.
getIsGrant
();
this
.
isGrant
=
nft
.
getIsGrant
();
this
.
collection
=
false
;
}
}
}
}
joying-common/src/main/java/com/fzm/common/service/impl/UserServiceImpl.java
View file @
f0082832
...
@@ -140,7 +140,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -140,7 +140,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
case
"voice"
:
case
"voice"
:
return
smsProperties
.
getVoiceLoginCodetype
();
return
smsProperties
.
getVoiceLoginCodetype
();
default
:
default
:
throw
GlobalException
.
newException
(
ResultCode
.
CODE_ERROR
);
throw
GlobalException
.
newException
(
ResultCode
.
VALIDATE_FAILED
,
"短信类型【"
+
type
+
"】的传参有误,取值范围是{sms,email,voice}"
);
}
}
}
}
...
...
joying-common/src/main/java/com/fzm/common/utils/JwtUtil.java
View file @
f0082832
...
@@ -55,6 +55,7 @@ public class JwtUtil {
...
@@ -55,6 +55,7 @@ public class JwtUtil {
.
getBody
();
.
getBody
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"JWT格式验证失败:{}"
,
token
);
log
.
info
(
"JWT格式验证失败:{}"
,
token
);
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
e
.
getMessage
());
}
}
return
claims
;
return
claims
;
}
}
...
@@ -80,7 +81,7 @@ public class JwtUtil {
...
@@ -80,7 +81,7 @@ public class JwtUtil {
Claims
claims
=
getClaimsFromToken
(
token
);
Claims
claims
=
getClaimsFromToken
(
token
);
return
claims
.
get
(
CLAIM_KEY_CREATED
,
Date
.
class
);
return
claims
.
get
(
CLAIM_KEY_CREATED
,
Date
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
GlobalException
.
newException
(
ResultCode
.
TOKEN_VALID_ERROR
,
e
.
getMessage
());
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
e
.
getMessage
());
}
}
}
}
...
@@ -92,7 +93,7 @@ public class JwtUtil {
...
@@ -92,7 +93,7 @@ public class JwtUtil {
Claims
claims
=
getClaimsFromToken
(
token
);
Claims
claims
=
getClaimsFromToken
(
token
);
return
claims
.
get
(
CLAIM_KEY_USERID
,
Integer
.
class
);
return
claims
.
get
(
CLAIM_KEY_USERID
,
Integer
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
GlobalException
.
newException
(
ResultCode
.
TOKEN_VALID_ERROR
,
e
.
getMessage
());
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
e
.
getMessage
());
}
}
}
}
...
@@ -104,7 +105,7 @@ public class JwtUtil {
...
@@ -104,7 +105,7 @@ public class JwtUtil {
Claims
claims
=
getClaimsFromToken
(
token
);
Claims
claims
=
getClaimsFromToken
(
token
);
return
claims
.
get
(
CLAIM_KEY_APP_ID
,
String
.
class
);
return
claims
.
get
(
CLAIM_KEY_APP_ID
,
String
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
GlobalException
.
newException
(
ResultCode
.
TOKEN_VALID_ERROR
,
e
.
getMessage
());
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
e
.
getMessage
());
}
}
}
}
...
...
joying-portal/src/main/java/com/fzm/portal/controller/NftController.java
View file @
f0082832
...
@@ -2,6 +2,7 @@ package com.fzm.portal.controller;
...
@@ -2,6 +2,7 @@ package com.fzm.portal.controller;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.constant.SystemConstant
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.Nft
;
import
com.fzm.common.entity.NftDto
;
import
com.fzm.common.entity.NftDto
;
...
@@ -18,6 +19,7 @@ import com.fzm.common.service.UserService;
...
@@ -18,6 +19,7 @@ import com.fzm.common.service.UserService;
import
com.fzm.common.utils.JwtUtil
;
import
com.fzm.common.utils.JwtUtil
;
import
com.fzm.common.utils.OssUtil
;
import
com.fzm.common.utils.OssUtil
;
import
com.fzm.common.utils.QRCodeUtil
;
import
com.fzm.common.utils.QRCodeUtil
;
import
com.fzm.common.utils.RedisUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
...
@@ -58,6 +60,9 @@ public class NftController {
...
@@ -58,6 +60,9 @@ public class NftController {
private
CategoryService
categoryService
;
private
CategoryService
categoryService
;
@Resource
@Resource
private
RedisUtil
redisUtil
;
@Resource
private
HttpServletRequest
request
;
private
HttpServletRequest
request
;
/**
/**
...
@@ -101,7 +106,7 @@ public class NftController {
...
@@ -101,7 +106,7 @@ public class NftController {
@GetMapping
(
"get/{id}"
)
@GetMapping
(
"get/{id}"
)
@ApiOperation
(
value
=
"获取nft详情"
)
@ApiOperation
(
value
=
"获取nft详情"
)
public
ResponseModel
<
NftVo
>
getById
(
@PathVariable
Integer
id
)
{
public
ResponseModel
<
NftVo
>
getById
(
@PathVariable
Integer
id
,
@RequestHeader
(
required
=
false
)
String
Authorization
)
{
Nft
nft
=
nftService
.
getById
(
id
);
Nft
nft
=
nftService
.
getById
(
id
);
if
(
nft
==
null
)
{
if
(
nft
==
null
)
{
throw
GlobalException
.
newException
(
ResultCode
.
DATA_ERROR
,
"没找到此nft的详情"
);
throw
GlobalException
.
newException
(
ResultCode
.
DATA_ERROR
,
"没找到此nft的详情"
);
...
@@ -112,6 +117,11 @@ public class NftController {
...
@@ -112,6 +117,11 @@ public class NftController {
}
}
NftVo
nftVo
=
new
NftVo
(
nft
,
user
);
NftVo
nftVo
=
new
NftVo
(
nft
,
user
);
nftVo
.
setCategory
(
categoryService
.
getById
(
nft
.
getCategoryId
()).
getCategoryName
());
nftVo
.
setCategory
(
categoryService
.
getById
(
nft
.
getCategoryId
()).
getCategoryName
());
if
(
StringUtils
.
isNotBlank
(
Authorization
))
{
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
Authorization
);
Boolean
collection
=
redisUtil
.
sIsMember
(
RedisConstant
.
COLLECTION_USER_PREFIX
+
userId
,
id
.
toString
());
nftVo
.
setCollection
(
collection
);
}
return
ResponseModel
.
success
(
nftVo
);
return
ResponseModel
.
success
(
nftVo
);
}
}
...
...
joying-portal/src/main/java/com/fzm/portal/controller/UserController.java
View file @
f0082832
...
@@ -81,6 +81,15 @@ public class UserController {
...
@@ -81,6 +81,15 @@ public class UserController {
return
ResponseModel
.
success
(
user
!=
null
&&
StringUtils
.
isNotBlank
(
user
.
getPassword
()));
return
ResponseModel
.
success
(
user
!=
null
&&
StringUtils
.
isNotBlank
(
user
.
getPassword
()));
}
}
@Authentication
@PostMapping
(
value
=
"/logout"
)
@ApiOperation
(
value
=
"判断用户是否已注册过"
)
public
ResponseModel
<
Boolean
>
logout
(
@RequestHeader
String
Authorization
)
{
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
Authorization
);
redisUtil
.
delete
(
RedisConstant
.
PORTAL_USER_TOKEN_PREFIX
+
userId
);
return
ResponseModel
.
success
();
}
//@ApiOperation(value = "设置密码")
//@ApiOperation(value = "设置密码")
public
ResponseModel
<
Boolean
>
setPassword
()
{
public
ResponseModel
<
Boolean
>
setPassword
()
{
return
ResponseModel
.
success
();
return
ResponseModel
.
success
();
...
...
joying-portal/src/test/java/com/fzm/portal/LyPortalApplicationTests.java
View file @
f0082832
package
com
.
fzm
.
portal
;
package
com
.
fzm
.
portal
;
import
cn.fzm.chain.simplesdk.client.ParaChainClient
;
import
cn.fzm.chain.simplesdk.client.ParaChainClient
;
import
com.fzm.common.constant.RedisConstant
;
import
com.fzm.common.utils.JsonUtil
;
import
com.fzm.common.utils.JsonUtil
;
import
com.fzm.common.utils.RedisUtil
;
import
com.fzm.common.utils.RedisUtil
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -29,8 +30,7 @@ class LyPortalApplicationTests {
...
@@ -29,8 +30,7 @@ class LyPortalApplicationTests {
@Test
@Test
void
contextLoads
()
{
void
contextLoads
()
{
System
.
out
.
println
(
redisUtil
.
setMembers
(
"user:collect:2"
));
System
.
out
.
println
(
redisUtil
.
sIsMember
(
RedisConstant
.
COLLECTION_USER_PREFIX
+
9
,
"2"
));
System
.
out
.
println
(
redisUtil
.
sSize
(
"user:collect:2"
));
}
}
}
}
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