"vscode:/vscode.git/clone" did not exist on "a1e8005499c7d9009d3fdd5821fd145eb52c8d26"
Commit 22c3864d authored by Zheng Jie's avatar Zheng Jie
Browse files

[新增功能](luoqiz-master): 记录登录日志

parent 5959c3fc
...@@ -17,6 +17,7 @@ package me.zhengjie.service.impl; ...@@ -17,6 +17,7 @@ package me.zhengjie.service.impl;
import cn.hutool.core.lang.Dict; import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.Log; import me.zhengjie.domain.Log;
...@@ -94,6 +95,12 @@ public class LogServiceImpl implements LogService { ...@@ -94,6 +95,12 @@ public class LogServiceImpl implements LogService {
log.setMethod(methodName); log.setMethod(methodName);
log.setUsername(username); log.setUsername(username);
log.setParams(getParameter(method, joinPoint.getArgs())); 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); log.setBrowser(browser);
logRepository.save(log); logRepository.save(log);
} }
......
...@@ -21,6 +21,7 @@ import io.swagger.annotations.Api; ...@@ -21,6 +21,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.annotation.rest.AnonymousDeleteMapping; import me.zhengjie.annotation.rest.AnonymousDeleteMapping;
import me.zhengjie.annotation.rest.AnonymousGetMapping; import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.annotation.rest.AnonymousPostMapping; import me.zhengjie.annotation.rest.AnonymousPostMapping;
...@@ -70,6 +71,7 @@ public class AuthorizationController { ...@@ -70,6 +71,7 @@ public class AuthorizationController {
@Resource @Resource
private LoginProperties loginProperties; private LoginProperties loginProperties;
@Log("用户登录")
@ApiOperation("登录授权") @ApiOperation("登录授权")
@AnonymousPostMapping(value = "/login") @AnonymousPostMapping(value = "/login")
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception { public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment