You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
962 B

package com.gaotao.common.utils;
import com.gaotao.modules.api.dao.SysErrorLogMapper;
import com.gaotao.modules.api.entity.SysErrorLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* 错误日志保存服务
* 使用独立事务保存日志,避免被外层事务回滚
*
* @author rqrq
* @date 2026/01/26
*/
@Service
public class ErrorLogService {
@Autowired
private SysErrorLogMapper sysErrorLogMapper;
/**
* 在独立事务中保存错误日志
* REQUIRES_NEW:开启新事务,不受外层事务影响
*
* @param log 错误日志实体
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveInNewTransaction(SysErrorLog log) {
sysErrorLogMapper.insert(log);
}
}