package com.jwipc.supplier.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwipc.supplier.entity.SupplierBankInfo;
import com.jwipc.supplier.mapper.SupplierBankInfoMapper;
import com.jwipc.supplier.service.ISupplierBankInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;


import java.util.List;

import static com.jwipc.constant.DbTypeConst.SQLSERVER;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author qizhicai
 * @since 2024-05-10
 */
@Service
public class SupplierBankInfoServiceImpl extends ServiceImpl<SupplierBankInfoMapper, SupplierBankInfo> implements ISupplierBankInfoService {

    @Override
    @DS(SQLSERVER)
    public void deleteBySupplieId(List<Long> supplierIds) {
        LambdaQueryWrapper<SupplierBankInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(SupplierBankInfo::getSupplierId, supplierIds);
        boolean isRemoved = this.remove(wrapper);
    }

    @Override
    @DS(SQLSERVER)
    public void saveSupplierBankInfos(List<SupplierBankInfo> supplierBankInfos) {
        if(CollectionUtils.isNotEmpty(supplierBankInfos)){
            for(SupplierBankInfo s:supplierBankInfos){
                this.save(s);
            }
        }

    }
}

