package com.engine.salary.biz;

import com.engine.salary.entity.taxrate.TaxRateDetail;
import com.engine.salary.mapper.TaxRateDetailMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
import weaver.general.BaseBean;

import java.util.List;

/**
 * 税率明细操作类
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public class TaxRateDetailBiz extends BaseBean {

    public void saveBatch(List<TaxRateDetail> list) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class);

            list.forEach(taxRateDetailMapper::insertIgnoreNull);

            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }


    public List<TaxRateDetail> listByBaseId(Long baseId) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            TaxRateDetailMapper taxRateDetailMapper = sqlSession.getMapper(TaxRateDetailMapper.class);

            return taxRateDetailMapper.listByBaseId(baseId);

        } finally {
            sqlSession.close();
        }
    }


}
