Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Fedex
/
iClear-Connect-Pre-Clearance
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
zelong.shao
2024-11-19 18:00:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fce16a907e7e159f2d467ea5ad795f14703b1a35
fce16a90
1 parent
67955c9f
manager|登出
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
1 deletions
server/manager-server/src/main/java/com/fedex/connect/manager/controller/base/BaseController.java
server/manager-server/src/main/java/com/fedex/connect/manager/controller/sys/impl/SysAuthController.java
server/manager-server/src/main/java/com/fedex/connect/manager/enums/ResponseCode.java
server/manager-server/src/main/java/com/fedex/connect/manager/repository/repo/sys/IUserRepository.java
server/manager-server/src/main/java/com/fedex/connect/manager/repository/repo/sys/impl/UserExtRepositoryImpl.java
server/manager-server/src/main/java/com/fedex/connect/manager/service/sys/ISysUserService.java
server/manager-server/src/main/java/com/fedex/connect/manager/service/sys/impl/SysUserServiceImpl.java
server/manager-server/src/main/resources/application-test.yml
server/manager-server/src/main/resources/message_en_US.properties
server/manager-server/src/main/resources/message_zh_CN.properties
server/manager-server/src/main/java/com/fedex/connect/manager/controller/base/BaseController.java
View file @
fce16a9
...
...
@@ -9,6 +9,7 @@ import com.fedex.connect.manager.config.PropertiesConfig;
import
com.fedex.connect.manager.service.bi.IDicEntriesService
;
import
com.fedex.connect.manager.service.log.ILogLoginService
;
import
com.fedex.connect.manager.service.sys.IPrivilegeService
;
import
com.fedex.connect.manager.service.sys.IRedisUtilService
;
import
com.fedex.connect.manager.service.sys.ISysAuthService
;
import
com.fedex.connect.manager.service.sys.ISysUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -35,6 +36,8 @@ public class BaseController extends BasicController {
protected
IDicEntriesService
dicEntriesService
;
@Autowired
protected
IPrivilegeService
privilegeService
;
@Autowired
protected
IRedisUtilService
redisUtilService
;
public
User
getCurrentUserInfo
(){
User
user
=
this
.
getUserInfo
(
localeMessageUtil
);
...
...
server/manager-server/src/main/java/com/fedex/connect/manager/controller/sys/impl/SysAuthController.java
View file @
fce16a9
package
com
.
fedex
.
connect
.
manager
.
controller
.
sys
.
impl
;
import
com.fedex.connect.common.dependencies.authentication.SecurityConstants
;
import
com.fedex.connect.common.dependencies.cache.CacheSystem
;
import
com.fedex.connect.common.dependencies.contants.RedisConstants
;
import
com.fedex.connect.common.dependencies.date.vo.ResponseVo
;
import
com.fedex.connect.common.dependencies.enums.sys.ParamConfigEnum
;
import
com.fedex.connect.common.dependencies.enums.sys.UserLoginTypeEnum
;
import
com.fedex.connect.common.dependencies.util.GsonUtils
;
import
com.fedex.connect.common.dependencies.util.JwtTokenUtils
;
import
com.fedex.connect.common.dependencies.util.StringExtUtil
;
import
com.fedex.connect.common.model.bi.DictionaryEntries
;
import
com.fedex.connect.common.model.sys.User
;
...
...
@@ -17,12 +20,18 @@ import com.fedex.connect.manager.data.dto.LoginRequest;
import
com.fedex.connect.manager.data.dto.SysUserDto
;
import
com.fedex.connect.manager.util.ParamConfigUtil
;
import
com.google.gson.JsonObject
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.ExpiredJwtException
;
import
io.jsonwebtoken.JwtException
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -220,4 +229,54 @@ public class SysAuthController extends BaseController implements ISysAuthControl
log
.
info
(
s
+
":"
+
parameter
);
}
}
@PostMapping
(
value
=
"/logout"
)
@ApiOperation
(
value
=
"登出"
)
public
ResponseVo
logOut
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
log
.
info
(
"user logout"
);
ResponseVo
resultRS
=
new
ResponseVo
();
String
id
=
""
;
try
{
Authentication
auth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
if
(
auth
!=
null
)
{
new
SecurityContextLogoutHandler
().
logout
(
request
,
response
,
auth
);
}
resultRS
.
setCode
(
HttpServletResponse
.
SC_OK
);
resultRS
.
setMsg
(
localeMessageUtil
.
getMessage
(
"system_exception_40007"
));
//清理redis中token
String
token
=
request
.
getHeader
(
SecurityConstants
.
TOKEN_HEADER
);
if
(!
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
token
)){
id
=
JwtTokenUtils
.
getId
(
token
.
replace
(
SecurityConstants
.
TOKEN_PREFIX
,
""
));
redisUtilService
.
del
(
RedisConstants
.
REDIS_KEY_TOKEN
+
id
);
}
}
catch
(
ExpiredJwtException
ee
)
{
log
.
error
(
"登出1失败!"
,
ee
);
Claims
claims
=
ee
.
getClaims
();
id
=
claims
.
getId
();
redisUtilService
.
del
(
RedisConstants
.
REDIS_KEY_TOKEN
+
id
);
return
resultRS
;
}
catch
(
JwtException
je
){
log
.
error
(
"登出2失败!"
,
je
);
return
resultRS
;
}
catch
(
Exception
e
)
{
log
.
error
(
"登出3失败"
,
e
);
resultRS
.
setMsg
(
localeMessageUtil
.
getMessage
(
"system_exception_40008"
));
resultRS
.
setCode
(
HttpServletResponse
.
SC_BAD_REQUEST
);
}
finally
{
if
(!
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
id
)){
log
.
info
(
"redis token get userid:"
+
id
);
//插入日志
User
sysUser
=
sysUserService
.
findById
(
Long
.
parseLong
(
id
));
DictionaryEntries
dicUserLoginType
=
cacheSystem
.
getDicUserLoginType
(
UserLoginTypeEnum
.
EXIT
.
getCode
());
LogLoginDto
dto
=
new
LogLoginDto
(
sysUser
.
getId
(),
dicUserLoginType
.
getId
(),
UserLoginTypeEnum
.
EXIT
.
getMsg
());
logLoginService
.
saveLoginLog
(
dto
);
}
}
return
resultRS
;
}
}
...
...
server/manager-server/src/main/java/com/fedex/connect/manager/enums/ResponseCode.java
View file @
fce16a9
...
...
@@ -13,6 +13,7 @@ public enum ResponseCode {
MESSAGE_CODE_40004
(
40004
,
"system_exception_40004"
),
MESSAGE_CODE_40005
(
40005
,
"system_exception_40005"
),
MESSAGE_CODE_40006
(
40006
,
"system_exception_40006"
),
MESSAGE_CODE_40007
(
40007
,
"system_exception_40007"
),
;
private
Integer
code
;
private
String
msg
;
...
...
server/manager-server/src/main/java/com/fedex/connect/manager/repository/repo/sys/IUserRepository.java
View file @
fce16a9
...
...
@@ -11,4 +11,6 @@ public interface IUserRepository {
int
insert
(
User
record
);
int
updateByPrimaryKeySelective
(
User
record
);
User
findById
(
Long
id
);
}
...
...
server/manager-server/src/main/java/com/fedex/connect/manager/repository/repo/sys/impl/UserExtRepositoryImpl.java
View file @
fce16a9
...
...
@@ -25,4 +25,9 @@ public class UserExtRepositoryImpl extends BaseDao implements IUserRepository {
public
int
updateByPrimaryKeySelective
(
User
record
)
{
return
userMapper
.
updateByPrimaryKeySelective
(
record
);
}
@Override
public
User
findById
(
Long
id
)
{
return
userMapper
.
selectByPrimaryKey
(
id
);
}
}
...
...
server/manager-server/src/main/java/com/fedex/connect/manager/service/sys/ISysUserService.java
View file @
fce16a9
...
...
@@ -14,4 +14,6 @@ public interface ISysUserService {
int
update
(
User
dao
);
void
getFclData
(
HttpServletRequest
request
,
List
<
String
>
cookiesList
,
List
<
String
>
saveKeyList
);
User
findById
(
Long
id
);
}
...
...
server/manager-server/src/main/java/com/fedex/connect/manager/service/sys/impl/SysUserServiceImpl.java
View file @
fce16a9
...
...
@@ -190,5 +190,10 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
}
}
@Override
public
User
findById
(
Long
id
)
{
return
userRepository
.
findById
(
id
);
}
}
...
...
server/manager-server/src/main/resources/application-test.yml
View file @
fce16a9
...
...
@@ -50,7 +50,7 @@ url:
fcl
:
login
:
url
:
http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnLogin
redjrectLogin
:
http
s://exportdeclarationuat-tw.dmz.apac.fedex.com/IcTw
/#/redjrectLogin
redjrectLogin
:
http
://localhost:8080/ImpPer
/#/redjrectLogin
twidx
:
url
:
http://exportdeclarationuat-tw.apac.fedex.com
interface
:
...
...
server/manager-server/src/main/resources/message_en_US.properties
View file @
fce16a9
...
...
@@ -15,3 +15,5 @@ system_exception_40003=系统异常,请联系清关部门
system_exception_40004
=
登录已过期,请重新登录
system_exception_40005
=
用戶不存在
system_exception_40006
=
登录已过期
system_exception_40007
=
退出成功
system_exception_40008
=
退出失败
\ No newline at end of file
...
...
server/manager-server/src/main/resources/message_zh_CN.properties
View file @
fce16a9
...
...
@@ -15,3 +15,5 @@ system_exception_40003=系统异常,请联系清关部门
system_exception_40004
=
登录已过期,请重新登录
system_exception_40005
=
用戶不存在
system_exception_40006
=
登录已过期
system_exception_40007
=
退出成功
system_exception_40008
=
退出失败
\ No newline at end of file
...
...
Please
register
or
login
to post a comment