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

import com.xisc.pm.domain.entity.PmPdPlateCut;
import com.xisc.pm.domain.repository.PmPdPlateCutRepository;
import com.xisc.pm.infra.mapper.PmPdPlateCutMapper;
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 PmPdPlateCutRepositoryImpl extends BaseRepositoryImpl<PmPdPlateCut> implements PmPdPlateCutRepository {
    
    @Autowired
    private PmPdPlateCutMapper pmPdPlateCutMapper;

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

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

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