package com.securitycontrol.system.base.service.impl;

import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.system.api.domain.SysLog;
import com.securitycontrol.system.base.mapper.ISysLogMapper;
import com.securitycontrol.system.base.service.ISysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import javax.annotation.Resource;

/**
 * @author：cwchen
 * @date：2024-02-28-14:02
 * @version：1.0
 * @description：系统日志-业务逻辑层
 */
@Service(value = "ISysLogService")
@Slf4j
public class SysLogServiceImpl implements ISysLogService {

    @Resource(name = "ISysLogMapper")
    private ISysLogMapper mapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult saveLogs(SysLog sysLog) {
        try {
            mapper.saveLogs(sysLog);
        } catch (Exception e) {
            log.error("保存系统日志");
            //手动回滚异常
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return null;
    }
}
