mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-13 21:27:19 +08:00
重构AOP日志功能,新增日志查询、删除接口及相关页面,优化日志管理体验;更新前端组件以支持日志展示和操作。
This commit is contained in:
@@ -48,17 +48,11 @@ public class LoggingAspect {
|
||||
return processWithLogging(joinPoint, aopLog);
|
||||
}
|
||||
|
||||
@Around("execution(* com.zl.mjga.service..*(..))")
|
||||
public Object logService(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
AopLog aopLog = new AopLog();
|
||||
return processWithLogging(joinPoint, aopLog);
|
||||
}
|
||||
|
||||
@Around("execution(* com.zl.mjga.repository..*(..))")
|
||||
public Object logRepository(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
AopLog aopLog = new AopLog();
|
||||
return processWithLogging(joinPoint, aopLog);
|
||||
}
|
||||
// @Around("execution(* com.zl.mjga.service..*(..))")
|
||||
// public Object logService(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// AopLog aopLog = new AopLog();
|
||||
// return processWithLogging(joinPoint, aopLog);
|
||||
// }
|
||||
|
||||
private Object processWithLogging(ProceedingJoinPoint joinPoint, AopLog aopLog) throws Throwable {
|
||||
if (shouldSkipLogging(joinPoint) || !isUserAuthenticated()) {
|
||||
@@ -82,7 +76,7 @@ public class LoggingAspect {
|
||||
|
||||
private Long getCurrentUserId() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
String username = (String) authentication.getPrincipal();
|
||||
String username = authentication.getName();
|
||||
User user = userRepository.fetchOneByUsername(username);
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zl.mjga.controller;
|
||||
|
||||
import com.zl.mjga.annotation.SkipAopLog;
|
||||
import com.zl.mjga.dto.PageRequestDto;
|
||||
import com.zl.mjga.dto.PageResponseDto;
|
||||
import com.zl.mjga.dto.department.DepartmentBindDto;
|
||||
@@ -56,6 +57,7 @@ public class IdentityAccessController {
|
||||
}
|
||||
|
||||
@PostMapping("/me")
|
||||
@SkipAopLog
|
||||
void upsertMe(Principal principal, @RequestBody UserUpsertDto userUpsertDto) {
|
||||
String name = principal.getName();
|
||||
User user = userRepository.fetchOneByUsername(name);
|
||||
@@ -65,6 +67,7 @@ public class IdentityAccessController {
|
||||
|
||||
@PreAuthorize("hasAuthority(T(com.zl.mjga.model.urp.EPermission).WRITE_USER_ROLE_PERMISSION)")
|
||||
@PostMapping("/user")
|
||||
@SkipAopLog
|
||||
void upsertUser(@RequestBody @Valid UserUpsertDto userUpsertDto) {
|
||||
identityAccessService.upsertUser(userUpsertDto);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zl.mjga.controller;
|
||||
|
||||
import com.zl.mjga.annotation.SkipAopLog;
|
||||
import com.zl.mjga.config.security.Jwt;
|
||||
import com.zl.mjga.dto.sign.SignInDto;
|
||||
import com.zl.mjga.dto.sign.SignUpDto;
|
||||
@@ -22,6 +23,7 @@ public class SignController {
|
||||
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@PostMapping("/sign-in")
|
||||
@SkipAopLog
|
||||
void signIn(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AopLogRepository extends AopLogDao {
|
||||
}
|
||||
|
||||
public Result<Record> pageFetchBy(PageRequestDto pageRequestDto, AopLogQueryDto queryDto) {
|
||||
return selectBy(queryDto)
|
||||
return selectByWithoutReturnValue(queryDto)
|
||||
.orderBy(pageRequestDto.getSortFields())
|
||||
.limit(pageRequestDto.getSize())
|
||||
.offset(pageRequestDto.getOffset())
|
||||
@@ -47,6 +47,16 @@ public class AopLogRepository extends AopLogDao {
|
||||
.where(buildConditions(queryDto));
|
||||
}
|
||||
|
||||
|
||||
public SelectConditionStep<Record> selectByWithoutReturnValue(AopLogQueryDto queryDto) {
|
||||
return ctx()
|
||||
.select(AOP_LOG.asterisk().except(AOP_LOG.RETURN_VALUE, AOP_LOG.METHOD_ARGS), USER.USERNAME, DSL.count().over().as("total_count"))
|
||||
.from(AOP_LOG)
|
||||
.leftJoin(USER)
|
||||
.on(AOP_LOG.USER_ID.eq(USER.ID))
|
||||
.where(buildConditions(queryDto));
|
||||
}
|
||||
|
||||
private Condition buildConditions(AopLogQueryDto queryDto) {
|
||||
Condition condition = noCondition();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user