package com.ym.mec.biz.service.impl;

import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.service.impl.BaseServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
	
	@Autowired
	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;

	@Override
	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
		return musicGroupPaymentCalenderDao;
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
		if(musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0){
			musicGroupPaymentCalenderDao.delByGroupId(musicGroupPaymentCalenders.get(0).getMusicGroupId());
			musicGroupPaymentCalenders.forEach(e -> {
				musicGroupPaymentCalenderDao.insert(e);
			});
		}
	}
}