package com.tzld.piaoquan.growth.common.service.Impl;

import com.google.common.collect.Lists;
import com.tzld.piaoquan.growth.common.dao.mapper.HistoryMessageMapper;
import com.tzld.piaoquan.growth.common.model.po.HistoryMessage;
import com.tzld.piaoquan.growth.common.service.HistoryMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class HistoryMessageServiceImpl implements HistoryMessageService {

    @Autowired
    private HistoryMessageMapper historyMessageMapper;

    @Override
    public void batchInsertHistoryMessage(List<HistoryMessage> historyMessageList) {
        if (CollectionUtils.isEmpty(historyMessageList)) {
            return;
        }
        List<List<HistoryMessage>> partition = Lists.partition(historyMessageList, 1000);
        for (List<HistoryMessage> historyMessages : partition) {
            historyMessageMapper.insertList(historyMessages);
        }
    }
}
