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

import java.util.List;

import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.hzero.mybatis.domian.Condition;
import org.hzero.mybatis.util.Sqls;

import com.google.common.collect.Lists;
import com.xisc.pm.domain.entity.PmAutoPdPosition;
import com.xisc.pm.domain.repository.PmAutoPdPositionRepository;
import com.xisc.pm.infra.mapper.PmAutoPdPositionMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 板坯子板位置表 资源库实现
 *
 * @author jun.zeng 2024-11-21 11:05:34
 */
@Component
public class PmAutoPdPositionRepositoryImpl extends BaseRepositoryImpl<PmAutoPdPosition>
        implements PmAutoPdPositionRepository {

    @Autowired
    private PmAutoPdPositionMapper pmAutoPdPositionMapper;

    @Override
    public List<PmAutoPdPosition> selectList(String virtualSlabNo, Long tenantId) {
        return pmAutoPdPositionMapper.selectList(virtualSlabNo, tenantId);
    }

    @Override
    public int deleteByRequestId(List<Long> requestIds) {
        return pmAutoPdPositionMapper.deleteByRequestId(requestIds);
    }

    @Override
    public List<PmAutoPdPosition> selectByVirtualSlabNoList(List<String> virtualSlabNoList, Long organizationId) {
        if (virtualSlabNoList == null || virtualSlabNoList.isEmpty()) {
            return Lists.newArrayList();
        }
        return this.selectByCondition(Condition.builder(PmAutoPdPosition.class)
                .andWhere(Sqls.custom().andEqualTo(PmAutoPdPosition.FIELD_TENANT_ID, organizationId)
                        .andIn(PmAutoPdPosition.FIELD_VIRTUAL_SLAB_NO, virtualSlabNoList))
                .build());
    }
}
