Skip to content

Commit

Permalink
feat: 增加操作日志记录功能
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyw committed Apr 8, 2024
1 parent 11eda0c commit adb8f9c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public void saveSysLog(JoinPoint joinPoint) {
private FeignSysLogQO getSysLog() {
FeignSysLogQO qo = new FeignSysLogQO();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
log.warn("request={}", JSUtil.toJsonString(request));
qo.setUserId(Long.valueOf(request.getHeader(Constants.USER_ID)));
qo.setIp(IPUtil.getIpAddress(request));
qo.setPath(request.getServletPath());
qo.setMethod(request.getMethod());
log.warn("qo={}, request={}", JSUtil.toJsonString(qo), JSUtil.toJsonString(request));
qo.setUserId(Long.valueOf(request.getHeader(Constants.USER_ID)));
return qo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public class AdminGlobalFilter implements GlobalFilter, Ordered {
* admin不需要权限校验的接口
*/
private static final List<String> EXCLUDE_URL = Arrays.asList(
"/system/admin/sys/menu/user/list",
"/system/admin/sys/menu/permission/list",
"/system/admin/sys/user/current"
);

Expand Down Expand Up @@ -83,6 +81,8 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
}

Long userId = getUserId(request);
request.mutate().header(Constants.USER_ID, String.valueOf(userId));

if (AuthFilterUtil.checkUri(uri, AuthFilterUtil.ADMIN_URL_PREFIX)) {
// admin校验
if (!stringRedisTemplate.hasKey(Constants.RedisPre.ADMIN_APIS.concat(userId.toString()))) {
Expand All @@ -96,7 +96,6 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
// 更新时间,使用户菜单不过期
stringRedisTemplate.expire(Constants.RedisPre.ADMIN_APIS.concat(userId.toString()), Constants.SESSIONTIME, TimeUnit.MINUTES);
}
request.mutate().header(Constants.USER_ID, String.valueOf(userId));
return chain.filter(exchange);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.roncoo.education.system.service.admin;

import com.roncoo.education.common.annotation.SysLog;
import com.roncoo.education.common.core.base.Result;
import com.roncoo.education.system.service.admin.biz.AdminLoginBiz;
import com.roncoo.education.system.service.admin.req.AdminSysUserLoginReq;
Expand All @@ -27,7 +26,6 @@ public class AdminLoginController {
private final AdminLoginBiz biz;

@ApiOperation(value = "密码登录", notes = "用户使用密码登录")
@SysLog(value = "密码登录")
@PostMapping(value = "/password")
public Result<AdminSysUserLoginResp> login(@RequestBody @Valid AdminSysUserLoginReq req) {
return biz.login(req);
Expand Down

0 comments on commit adb8f9c

Please sign in to comment.