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

import com.xisc.pm.api.dto.PmSubOrdResponseDTO;
import org.apache.commons.collections.CollectionUtils;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.stereotype.Component;
import com.xisc.pm.domain.entity.PmSubOrd;
import com.xisc.pm.domain.repository.PmSubOrdRepository;
import com.xisc.pm.infra.mapper.PmSubOrdMapper;

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

/**
 * 组板履历合同表(PmSubOrd)资源库
 *
 * @author BKGY
 * @since 2025-01-02 10:39:48
 */
@Component
public class PmSubOrdRepositoryImpl extends BaseRepositoryImpl<PmSubOrd> implements PmSubOrdRepository {
    @Resource
    private PmSubOrdMapper pmSubOrdMapper;

    @Override
    public List<PmSubOrd> selectList(PmSubOrd pmSubOrd) {
        return pmSubOrdMapper.selectList(pmSubOrd);
    }

    @Override
    public PmSubOrd selectByPrimary(Long id) {
        PmSubOrd pmSubOrd = new PmSubOrd();
        pmSubOrd.setId(id);
        List<PmSubOrd> pmSubOrds = pmSubOrdMapper.selectList(pmSubOrd);
        if (CollectionUtils.isEmpty(pmSubOrds)) {
            return null;
        }
        return pmSubOrds.get(0);
    }

    @Override
    public List<PmSubOrdResponseDTO> selectOrdList(PmSubOrd pmSubOrd) {
        return pmSubOrdMapper.selectOrdList(pmSubOrd);
    }

}

