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

import com.xisc.pm.domain.entity.PmPolicyGrKpi;
import com.xisc.pm.domain.repository.PmPolicyGrKpiRepository;
import com.xisc.pm.infra.mapper.PmPolicyGrKpiMapper;
import org.hzero.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.stereotype.Component;

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

/**
 * 策略组与评价指标关系表(PmPolicyGrKpi)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-11-08 12:29:12
 */
@Component
public class PmPolicyGrKpiRepositoryImpl extends BaseRepositoryImpl<PmPolicyGrKpi> implements PmPolicyGrKpiRepository {
    @Resource
    private PmPolicyGrKpiMapper pmPolicyGrKpiMapper;

    @Override
    public List<PmPolicyGrKpi> selectList(PmPolicyGrKpi pmPolicyGrKpi) {
        return pmPolicyGrKpiMapper.selectList(pmPolicyGrKpi);
    }

    @Override
    public PmPolicyGrKpi selectByPrimary(Long policyGroupKpiId) {
        PmPolicyGrKpi pmPolicyGrKpi = new PmPolicyGrKpi();
        pmPolicyGrKpi.setPolicyGroupKpiId(policyGroupKpiId);
        List<PmPolicyGrKpi> pmPolicyGrKpis = pmPolicyGrKpiMapper.selectList(pmPolicyGrKpi);
        if (pmPolicyGrKpis.size() == 0) {
            return null;
        }
        return pmPolicyGrKpis.get(0);
    }

    @Override
    public List<PmPolicyGrKpi> selectByGroupId(Long policyGroupId, Long tenantId) {
        PmPolicyGrKpi pmPolicyGrKpi = new PmPolicyGrKpi();
        pmPolicyGrKpi.setPolicyGroupId(policyGroupId);
        pmPolicyGrKpi.setTenantId(tenantId);
        return pmPolicyGrKpiMapper.selectList(pmPolicyGrKpi);
    }

}
