This commit is contained in:
2026-08-19 17:52:13 +08:00
parent 27f00b61ff
commit ea9fde7979
6 changed files with 245 additions and 0 deletions
@@ -0,0 +1,11 @@
package com.yunhai.bschclassmanage.service;
import com.yunhai.bschclassmanage.entity.SyncLog;
public interface ISyncLogService {
/**
* 异步保存一条同步调用日志。
* 由 SyncLogAspect 在 finally 中调用,失败仅记日志、不抛异常、不阻塞主流程。
*/
void saveAsync(SyncLog entity);
}
@@ -0,0 +1,27 @@
package com.yunhai.bschclassmanage.service.impl;
import com.yunhai.bschclassmanage.Repository.SyncLogRepository;
import com.yunhai.bschclassmanage.entity.SyncLog;
import com.yunhai.bschclassmanage.service.ISyncLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SyncLogServiceImpl implements ISyncLogService {
@Autowired
private SyncLogRepository repository;
@Async("logExecutor")
@Override
public void saveAsync(SyncLog entity) {
try {
repository.save(entity);
} catch (Exception e) {
log.error("同步日志异步落库失败, classMethod={}", entity.getClassMethod(), e);
}
}
}