synclog
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user