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

import com.bocloud.database.core.intf.impl.JdbcGenericDao;
import com.bocloud.ims.entity.resource.hmc.HmcPartitionIo;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

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

@Deprecated
@Repository
public class HmcPartitionIoRepository extends JdbcGenericDao<HmcPartitionIo, Long> {

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

    public List<HmcPartitionIo> listByPartitionId(Long partitionId) {
        String sql = "select * from hmc_partition_io where partition_id = :partitionId and is_deleted = 0 ";
        Map<String, Object> params = new HashMap<>();
        params.put("partitionId", partitionId);
        return super.list(HmcPartitionIo.class, sql, params);
    }

    public void deleteByPartitionId(Long partitionId) {
        String sql = "update hmc_partition_io set is_deleted = 1 where partition_id = :partitionId ";
        Map<String, Object> params = new HashMap<>();
        params.put("partitionId", partitionId);
        super.execute(sql, params);
    }
}
