package com.xisc.pm.infra.repository.impl;

import com.xisc.pm.domain.entity.PmPdBlockPos;
import com.xisc.pm.domain.repository.PmPdBlockPosRepository;
import com.xisc.pm.infra.mapper.PmPdBlockPosMapper;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.hzero.mybatis.domian.Condition;
import org.hzero.mybatis.util.Sqls;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 组合子板位置表 资源库实现
 *
 * @author 曾俊 jun.zeng@hand-china.com 2024-08-02 08:02:38
 */
@Component
public class PmPdBlockPosRepositoryImpl extends BaseRepositoryImpl<PmPdBlockPos> implements PmPdBlockPosRepository {
    
    @Autowired
    private PmPdBlockPosMapper pmPdBlockPosMapper;

    @Override
    public List<PmPdBlockPos> selectByPdMatNo(Long tenantId, String virtualSlabNo) {
        PmPdBlockPos record = new PmPdBlockPos();
        record.setTenantId(tenantId);
        record.setPdMatNo(virtualSlabNo);
        return this.select(record);
    }

    @Override
    public int deleteByMatNo(Long tenantId, List<String> removePdMatNo) {
        return pmPdBlockPosMapper.deleteByMatNo(tenantId , removePdMatNo);
    }

    @Override
    public List<PmPdBlockPos> selectByPdMatNoList(List<String> pdMatNoList, Long tenantId) {
        return this.selectByCondition(Condition.builder(PmPdBlockPos.class)
                .andWhere(Sqls.custom().andIn(PmPdBlockPos.FIELD_PD_MAT_NO, pdMatNoList))
                .andWhere(Sqls.custom().andEqualTo(PmPdBlockPos.FIELD_TENANT_ID, tenantId)).build());
    }
}
