
package com.lideeyunji.core.framework.service;

import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

public interface IBatchService {

    @DSTransactional(rollbackFor = Exception.class)
    default boolean saveBatch(Collection entityList, BaseMapper baseMapper,Class mapperClass,Class entityClazz) {
        return this.saveBatch(entityList, 1000,baseMapper,mapperClass,entityClazz);
    }

    boolean saveBatch(Collection entityList, int batchSize, BaseMapper baseMapper,Class mapperClass,Class entityClazz);

    @DSTransactional(rollbackFor = Exception.class)
    default boolean updateBatchById(Collection entityList,BaseMapper baseMapper,Class mapperClass,Class entityClazz) {
        return this.updateBatchById(entityList, 1000,baseMapper,mapperClass,entityClazz);
    }

    boolean updateBatchById(Collection entityList, int batchSize,BaseMapper baseMapper,Class mapperClass,Class entityClazz);
}
