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

import org.apache.commons.collections.CollectionUtils;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.stereotype.Component;
import com.xisc.pm.domain.entity.PmCdRuleItem;
import com.xisc.pm.domain.repository.PmCdRuleItemRepository;
import com.xisc.pm.infra.mapper.PmCdRuleItemMapper;

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

/**
 * 充当规则库(PmCdRuleItem)资源库
 *
 * @author 蒋雨航 yuhang.jiang02@hand-china.com
 * @since 2024-08-16 10:57:46
 */
@Component
public class PmCdRuleItemRepositoryImpl extends BaseRepositoryImpl<PmCdRuleItem> implements PmCdRuleItemRepository {
    @Resource
    private PmCdRuleItemMapper pmCdRuleItemMapper;

    @Override
    public List<PmCdRuleItem> selectList(PmCdRuleItem pmCdRuleItem) {
        return pmCdRuleItemMapper.selectList(pmCdRuleItem);
    }

    @Override
    public PmCdRuleItem selectByPrimary(Long ruleItemId) {
        PmCdRuleItem pmCdRuleItem = new PmCdRuleItem();
        pmCdRuleItem.setRuleItemId(ruleItemId);
        List<PmCdRuleItem> pmCdRuleItems = pmCdRuleItemMapper.selectList(pmCdRuleItem);
        if (CollectionUtils.isEmpty(pmCdRuleItems)) {
            return null;
        }
        return pmCdRuleItems.get(0);
    }

}
