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

import com.xisc.pm.domain.repository.PmWmMatPileRepository;
import com.xisc.pm.domain.vo.WmMatPileVO1;
import com.xisc.pm.domain.vo.WmMatPileVo;
import com.xisc.pm.infra.mapper.WmMatPileMapper;
import org.apache.commons.collections.CollectionUtils;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 材料垛位信息表(WmMatPile)资源库
 *
 * @author 蒋雨航 yuhang.jiang02@hand-china.com
 * @since 2024-08-16 16:17:29
 */
@Component
public class PmWmMatPileRepositoryImpl extends BaseRepositoryImpl<WmMatPileVO1> implements PmWmMatPileRepository {
    @Resource
    private WmMatPileMapper wmMatPileMapper;

    @Override
    public List<WmMatPileVO1> selectList(WmMatPileVO1 wmMatPileVO1) {
        return wmMatPileMapper.selectList(wmMatPileVO1);
    }

    @Override
    public WmMatPileVO1 selectByPrimary(Long matPileId) {
        WmMatPileVO1 wmMatPileVO1 = new WmMatPileVO1();
        wmMatPileVO1.setMatPileId(matPileId);
        List<WmMatPileVO1> wmMatPileVO1s = wmMatPileMapper.selectList(wmMatPileVO1);
        if (CollectionUtils.isEmpty(wmMatPileVO1s)) {
            return null;
        }
        return wmMatPileVO1s.get(0);
    }

    @Override
    public WmMatPileVo selectWmMatPileByMatNo(String matNo, Long tenantId) {
        List<WmMatPileVo> list = wmMatPileMapper.selectWmMatPileByMatNo(matNo, tenantId);
        if (list == null || list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }

}
