package com.sckw.contract.repository;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sckw.contract.dao.KwcContractLogisticsUnitMapper;
import com.sckw.contract.model.entity.KwcContractLogisticsUnit;
import com.sckw.contract.model.entity.KwcContractTradeUnit;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;

/**
 * @author :chenXiaoFei
 * @version :1.0
 * @description : 物流企业信息
 * @create :2025-11-05 17:31:00
 */
@Repository
public class KwcContractLogisticsUnitRepository extends ServiceImpl<KwcContractLogisticsUnitMapper, KwcContractLogisticsUnit> {
    public List<KwcContractLogisticsUnit> queryByContractId(Long contractId) {
        return list(Wrappers.<KwcContractLogisticsUnit>lambdaQuery()
                .eq(KwcContractLogisticsUnit::getContractId, contractId)
                .eq(KwcContractLogisticsUnit::getDelFlag,0));
    }

    public List<KwcContractLogisticsUnit> queryByContractIds(Set<Long> contractIds) {
        return list(Wrappers.<KwcContractLogisticsUnit>lambdaQuery()
                .eq(KwcContractLogisticsUnit::getDelFlag,0)
                .in(KwcContractLogisticsUnit::getContractId, contractIds));
    }

    @Transactional
    public void saveUnits(List<KwcContractLogisticsUnit> units) {
        saveBatch( units);
    }

    public void removeByContractId(long contactId) {
        remove(Wrappers.<KwcContractLogisticsUnit>lambdaQuery()
                .eq(KwcContractLogisticsUnit::getContractId, contactId));
    }
}
