package com.sundot.airport.ledger.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sundot.airport.common.utils.DateUtils;
import com.sundot.airport.ledger.domain.LedgerUnsafeEvent;
import com.sundot.airport.ledger.mapper.LedgerUnsafeEventMapper;
import com.sundot.airport.ledger.service.ILedgerUnsafeEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 不安全事件记录Service实现
 */
@Service
public class LedgerUnsafeEventServiceImpl extends ServiceImpl<LedgerUnsafeEventMapper, LedgerUnsafeEvent>
        implements ILedgerUnsafeEventService {

    @Autowired
    private LedgerUnsafeEventMapper mapper;

    @Override
    public List<LedgerUnsafeEvent> selectList(LedgerUnsafeEvent query) {
        return mapper.selectList(query);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchInsert(List<LedgerUnsafeEvent> list) {
        list.forEach(item -> item.setCreateTime(DateUtils.getNowDate()));
        saveBatch(list);
        return list.size();
    }
}
