package com.cool.store.dao;

import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.TallyBookDetailDO;
import com.cool.store.mapper.TallyBookDetailMapper;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: WangShuo
 * @Date: 2025/04/01/13:38
 * @Version 1.0
 * @注释:
 */
@Repository
public class TallyBookDetailDAO {
    @Resource
    private TallyBookDetailMapper tallyBookDetailMapper;
    public Integer batchInsert(List<TallyBookDetailDO> tallyBookDetailDOList) {
        if (CollectionUtils.isEmpty(tallyBookDetailDOList)){
            return  null;
        }
        return tallyBookDetailMapper.batchInsert(tallyBookDetailDOList);
    }

    public Integer batchDeleteByTallyBookId(Long tallyBookId){
        Example example = new Example(TallyBookDetailDO.class);
        example.createCriteria().andEqualTo("tallyBookId",tallyBookId);
        return tallyBookDetailMapper.deleteByExample(example);
    }

    public List<TallyBookDetailDO> getTallyBookDetailListByTallyBookId(Long tallyBookId){
        Example example = new Example(TallyBookDetailDO.class);
        example.createCriteria().andEqualTo("tallyBookId",tallyBookId);
        return tallyBookDetailMapper.selectByExample(example);
    }
}
