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.PmCdRuleSet;
import com.xisc.pm.domain.repository.PmCdRuleSetRepository;
import com.xisc.pm.infra.mapper.PmCdRuleSetMapper;

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

/**
 * 充当规则集(PmCdRuleSet)资源库
 *
 * @author 蒋雨航 yuhang.jiang02@hand-china.com
 * @since 2024-08-16 10:57:16
 */
@Component
public class PmCdRuleSetRepositoryImpl extends BaseRepositoryImpl<PmCdRuleSet> implements PmCdRuleSetRepository {
    @Resource
    private PmCdRuleSetMapper pmCdRuleSetMapper;

    @Override
    public List<PmCdRuleSet> selectList(PmCdRuleSet pmCdRuleSet) {
        return pmCdRuleSetMapper.selectList(pmCdRuleSet);
    }

    @Override
    public PmCdRuleSet selectByPrimary(Long ruleSetId) {
        PmCdRuleSet pmCdRuleSet = new PmCdRuleSet();
        pmCdRuleSet.setRuleSetId(ruleSetId);
        List<PmCdRuleSet> pmCdRuleSets = pmCdRuleSetMapper.selectList(pmCdRuleSet);
        if (CollectionUtils.isEmpty(pmCdRuleSets)) {
            return null;
        }
        return pmCdRuleSets.get(0);
    }

}
