package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;

import cn.estsh.i3plus.ext.mes.pcn.api.base.ICheckErrorLogService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesCheckErrorLog;
import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.MesCheckErrorLogRepository;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
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 yumingxing
 * @version 1.0
 * @date 2021/7/12 9:59
 **/
@Service
public class CheckErrorLogService implements ICheckErrorLogService {

    @Autowired
    private MesCheckErrorLogRepository errorLogRepository;

    @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {ImppBusiException.class, Exception.class})
    public void insertCheckErrorLog(MesCheckErrorLog checkErrorLog, String message, String userInfo) {
        checkErrorLog.setErrorInfo(message);
        ConvertBean.serviceModelInitialize(checkErrorLog, userInfo);
        errorLogRepository.insert(checkErrorLog);
    }
}
