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.PmPolicySection;
import com.xisc.pm.domain.repository.PmPolicySectionRepository;
import com.xisc.pm.infra.mapper.PmPolicySectionMapper;

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

/**
 * 策略信息与断面关系表(PmPolicySection)资源库
 *
 * @author 纪文桃 wentao.ji01@hand-china.com
 * @since 2024-10-16 10:46:27
 */
@Component
public class PmPolicySectionRepositoryImpl extends BaseRepositoryImpl<PmPolicySection> implements PmPolicySectionRepository {
    @Resource
    private PmPolicySectionMapper pmPolicySectionMapper;

    @Override
    public List<PmPolicySection> selectList(PmPolicySection pmPolicySection) {
        return pmPolicySectionMapper.selectList(pmPolicySection);
    }

    @Override
    public PmPolicySection selectByPrimary(Long policySectionId) {
        PmPolicySection pmPolicySection = new PmPolicySection();
        pmPolicySection.setPolicySectionId(policySectionId);
        List<PmPolicySection> pmPolicySections = pmPolicySectionMapper.selectList(pmPolicySection);
        if (CollectionUtils.isEmpty(pmPolicySections)) {
            return null;
        }
        return pmPolicySections.get(0);
    }
}
