fix: 加入api路径和样式修改

This commit is contained in:
2025-05-29 17:20:04 +08:00
parent df112f4e43
commit 5f052bb2b3
5 changed files with 146 additions and 15 deletions

View File

@@ -0,0 +1,23 @@
package org.nl.common.security.satoken;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @Author: lyd
* @Date: 2025/5/29
*/
@Component
public class ApiPathInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
// 获取请求的API路径并存入MDC
String apiPath = request.getRequestURI();
MDC.put("apiPath", apiPath);
return true;
}
}

View File

@@ -26,6 +26,8 @@ public class SaTokenConfigure implements WebMvcConfigurer {
*/
@Autowired
private SecurityProperties securityProperties;
@Autowired
private ApiPathInterceptor apiPathInterceptor;
/**
* Sa-Token 整合 jwt (Simple 简单模式)
@@ -42,6 +44,10 @@ public class SaTokenConfigure implements WebMvcConfigurer {
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(apiPathInterceptor)
.addPathPatterns("/**")
// 设置最高优先级
.order(0);
/*
* 注册 Sa-Token 拦截器,打开注解式鉴权功能
* .excludePathPatterns(securityProperties.getExcludes()): 白名单

View File

@@ -30,7 +30,7 @@ public class SysNoticeController {
private ISysNoticeService noticeService;
@GetMapping
@Log("查询消息通知")
// @Log("查询消息通知")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
return new ResponseEntity<>(TableDataInfo.build(noticeService.queryAll(whereJson,page)),HttpStatus.OK);
}
@@ -56,13 +56,13 @@ public class SysNoticeController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("获取未读的接收消息条数")
// @Log("获取未读的接收消息条数")
@GetMapping("/countByReceiveNotRead")
public ResponseEntity<Object> countByReceiveNotRead(){
return new ResponseEntity<>(noticeService.countByReceiveNotRead(), HttpStatus.OK);
}
@Log("接收消息分页")
// @Log("接收消息分页")
@GetMapping("/pageByReceive")
public ResponseEntity<Object> pageByReceive(){
return new ResponseEntity<>(noticeService.pageByReceive(), HttpStatus.OK);
@@ -75,7 +75,7 @@ public class SysNoticeController {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("消息详情")
// @Log("消息详情")
@PostMapping("/findById")
public ResponseEntity<Object> findById(@RequestBody String id){
return new ResponseEntity<>(noticeService.getById(id), HttpStatus.OK);
@@ -90,7 +90,6 @@ public class SysNoticeController {
@Log("批量已读")
@PostMapping("/changeRead")
public ResponseEntity<Object> changeRead(@RequestBody JSONObject jsonObject) {
noticeService.changeRead(jsonObject);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);

View File

@@ -35,6 +35,9 @@ public class EsLogDto {
@Field(type = FieldType.Keyword)
private String thread;
@Field(type = FieldType.Keyword)
private String apiPath;
@Field(type = FieldType.Keyword)
private String logger;
@Field(type = FieldType.Keyword)
@@ -61,6 +64,14 @@ public class EsLogDto {
this.time = time;
}
public String getApiPath() {
return apiPath;
}
public void setApiPath(String apiPath) {
this.apiPath = apiPath;
}
public String getMessage() {
return message;
}