Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
22c3864d
Commit
22c3864d
authored
Jun 07, 2022
by
Zheng Jie
Browse files
[新增功能](luoqiz-master): 记录登录日志
parent
5959c3fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
View file @
22c3864d
...
...
@@ -17,6 +17,7 @@ package me.zhengjie.service.impl;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
lombok.RequiredArgsConstructor
;
import
me.zhengjie.domain.Log
;
...
...
@@ -94,6 +95,12 @@ public class LogServiceImpl implements LogService {
log
.
setMethod
(
methodName
);
log
.
setUsername
(
username
);
log
.
setParams
(
getParameter
(
method
,
joinPoint
.
getArgs
()));
// 记录登录用户,隐藏密码信息
if
(
log
.
getDescription
().
equals
(
"用户登录"
)){
JSONObject
obj
=
JSONUtil
.
parseObj
(
log
.
getParams
());
log
.
setUsername
(
obj
.
get
(
"username"
).
toString
());
log
.
setParams
(
JSONUtil
.
toJsonStr
(
Dict
.
create
().
set
(
"username"
,
log
.
getUsername
())));
}
log
.
setBrowser
(
browser
);
logRepository
.
save
(
log
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
View file @
22c3864d
...
...
@@ -21,6 +21,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.annotation.Log
;
import
me.zhengjie.annotation.rest.AnonymousDeleteMapping
;
import
me.zhengjie.annotation.rest.AnonymousGetMapping
;
import
me.zhengjie.annotation.rest.AnonymousPostMapping
;
...
...
@@ -70,6 +71,7 @@ public class AuthorizationController {
@Resource
private
LoginProperties
loginProperties
;
@Log
(
"用户登录"
)
@ApiOperation
(
"登录授权"
)
@AnonymousPostMapping
(
value
=
"/login"
)
public
ResponseEntity
<
Object
>
login
(
@Validated
@RequestBody
AuthUserDto
authUser
,
HttpServletRequest
request
)
throws
Exception
{
...
...
Write
Preview
Supports
Markdown
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