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

import com.xisc.pm.domain.entity.PmPdRuleSet;
import com.xisc.pm.domain.repository.PmPdRuleSetRepository;
import com.xisc.pm.infra.mapper.PmPdRuleSetMapper;
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;

/**
 * 组板设计规则集(PmPdRuleSet)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-07-30 14:15:47
 */
@Component
public class PmPdRuleSetRepositoryImpl extends BaseRepositoryImpl<PmPdRuleSet> implements PmPdRuleSetRepository {
    @Resource
    private PmPdRuleSetMapper pmPdRuleSetMapper;

    @Override
    public List<PmPdRuleSet> selectList(PmPdRuleSet pmPdRuleSet) {
        return pmPdRuleSetMapper.selectList(pmPdRuleSet);
    }

    @Override
    public PmPdRuleSet selectByPrimary(Long ruleSetId) {
        PmPdRuleSet pmPdRuleSet = new PmPdRuleSet();
        pmPdRuleSet.setRuleSetId(ruleSetId);
        List<PmPdRuleSet> pmPdRuleSets = pmPdRuleSetMapper.selectList(pmPdRuleSet);
        if (CollectionUtils.isEmpty(pmPdRuleSets)) {
            return null;
        }
        return pmPdRuleSets.get(0);
    }
}
