Fix oper log compile dependency
This commit is contained in:
@@ -8,8 +8,8 @@ import com.test.demo.bo.LoginBo;
|
||||
import com.test.demo.common.annotation.Log;
|
||||
import com.test.demo.entity.OperLogEntity;
|
||||
import com.test.demo.entity.UserEntity;
|
||||
import com.test.demo.log.event.OperLogEvent;
|
||||
import com.test.demo.security.SecurityUtil;
|
||||
import com.test.demo.service.OperLogService;
|
||||
import com.test.demo.service.UserService;
|
||||
import com.test.demo.util.DesensitizeUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -20,7 +20,6 @@ import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.BindingResult;
|
||||
@@ -53,9 +52,9 @@ public class LogAspect {
|
||||
private static final Set<String> EMAIL_FIELDS = Set.of("email");
|
||||
private static final Set<String> PHONE_FIELDS = Set.of("phone", "mobile", "phonenumber");
|
||||
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final UserService userService;
|
||||
private final OperLogService operLogService;
|
||||
|
||||
@Around("@annotation(logAnnotation)")
|
||||
public Object around(ProceedingJoinPoint point, Log logAnnotation) throws Throwable {
|
||||
@@ -136,7 +135,7 @@ public class LogAspect {
|
||||
}
|
||||
|
||||
if (logAnnotation.saveToDB()) {
|
||||
eventPublisher.publishEvent(new OperLogEvent(this, operLog));
|
||||
operLogService.record(operLog);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -13,6 +13,8 @@ import java.io.IOException;
|
||||
*/
|
||||
public interface OperLogService extends IService<OperLogEntity> {
|
||||
|
||||
void record(OperLogEntity operLog);
|
||||
|
||||
PageResult<OperLogEntity> page(OperLogQueryBo query);
|
||||
|
||||
void export(OperLogQueryBo query, HttpServletResponse response) throws IOException;
|
||||
|
||||
@@ -26,6 +26,18 @@ import java.util.List;
|
||||
@Service
|
||||
public class OperLogServiceImpl extends ServiceImpl<OperLogMapper, OperLogEntity> implements OperLogService {
|
||||
|
||||
@Override
|
||||
public void record(OperLogEntity operLog) {
|
||||
if (operLog == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
save(operLog);
|
||||
} catch (Exception e) {
|
||||
log.error("写入操作日志失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<OperLogEntity> page(OperLogQueryBo query) {
|
||||
LambdaQueryWrapper<OperLogEntity> wrapper = new LambdaQueryWrapper<OperLogEntity>()
|
||||
|
||||
Reference in New Issue
Block a user