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

import com.xisc.pm.domain.entity.PmPolicyGroupRel;
import com.xisc.pm.domain.repository.PmPolicyGroupRelRepository;
import com.xisc.pm.infra.mapper.PmPolicyGroupRelMapper;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.stereotype.Component;

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

/**
 * 策略组与策略关系表(PmPolicyGroupRel)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-11-08 09:39:42
 */
@Component
public class PmPolicyGroupRelRepositoryImpl extends BaseRepositoryImpl<PmPolicyGroupRel> implements PmPolicyGroupRelRepository {
    @Resource
    private PmPolicyGroupRelMapper pmPolicyGroupRelMapper;

    @Override
    public List<PmPolicyGroupRel> selectList(PmPolicyGroupRel pmPolicyGroupRel) {
        return pmPolicyGroupRelMapper.selectList(pmPolicyGroupRel);
    }

    @Override
    public PmPolicyGroupRel selectByPrimary(Long policyGroupRelId) {
        PmPolicyGroupRel pmPolicyGroupRel = new PmPolicyGroupRel();
        pmPolicyGroupRel.setPolicyGroupRelId(policyGroupRelId);
        List<PmPolicyGroupRel> pmPolicyGroupRels = pmPolicyGroupRelMapper.selectList(pmPolicyGroupRel);
        if (pmPolicyGroupRels.size() == 0) {
            return null;
        }
        return pmPolicyGroupRels.get(0);
    }

}

