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

import com.xisc.pm.domain.entity.PmPdRuleItem;
import com.xisc.pm.domain.repository.PmPdRuleItemRepository;
import com.xisc.pm.infra.mapper.PmPdRuleItemMapper;
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;

/**
 * 组板设计规则库(PmPdRuleItem)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-07-30 14:15:27
 */
@Component
public class PmPdRuleItemRepositoryImpl extends BaseRepositoryImpl<PmPdRuleItem> implements PmPdRuleItemRepository {
    @Resource
    private PmPdRuleItemMapper pmPdRuleItemMapper;

    @Override
    public List<PmPdRuleItem> selectList(PmPdRuleItem pmPdRuleItem) {
        return pmPdRuleItemMapper.selectList(pmPdRuleItem);
    }

    @Override
    public PmPdRuleItem selectByPrimary(Long ruleNoId) {
        PmPdRuleItem pmPdRuleItem = new PmPdRuleItem();
        pmPdRuleItem.setRuleNoId(ruleNoId);
        List<PmPdRuleItem> pmPdRuleItems = pmPdRuleItemMapper.selectList(pmPdRuleItem);
        if (CollectionUtils.isEmpty(pmPdRuleItems)) {
            return null;
        }
        return pmPdRuleItems.get(0);
    }
}
