package com.bocloud.ims.repository.resource.hmc;

import com.bocloud.common.utils.MapTools;
import com.bocloud.database.core.intf.impl.JdbcGenericDao;
import com.bocloud.ims.entity.resource.hmc.HmcPhysicalEthernetAdapter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Deprecated
@Component
public class HmcPhysicalEthernetAdapterRepository extends JdbcGenericDao<HmcPhysicalEthernetAdapter, Long> {

    public HmcPhysicalEthernetAdapterRepository(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate npJdbcTemplate) {
        super(jdbcTemplate, npJdbcTemplate);
    }

    public List<HmcPhysicalEthernetAdapter> listByPartition(Long partitionId) {
        String sql = "select a.* from hmc_physical_ethernet_adapter a where a.partition_id = :partitionId and a.is_deleted = 0";
        Map<String, Object> param = MapTools.simpleMap("partitionId", partitionId);
        return this.list(HmcPhysicalEthernetAdapter.class, sql, param);
    }

    public HmcPhysicalEthernetAdapter getByPartitionAndPhysicalLocation(Long partitionId, String physicalLocation) {
        String sql = "select a.* from hmc_physical_ethernet_adapter a where a.partition_id = :partitionId and a.is_deleted = 0 and a.physical_location = :physicalLocation ";
        Map<String, Object> param = MapTools.simpleMap("partitionId", partitionId);
        param.put("physicalLocation", physicalLocation);
        List<HmcPhysicalEthernetAdapter> list = this.list(HmcPhysicalEthernetAdapter.class, sql, param);
        return list == null || list.size() == 0 ? null : list.get(0);
    }
}
