package ru.yandex.wmconsole.service.dao;

import ru.yandex.common.util.db.DoubleRowMapper;
import ru.yandex.wmconsole.data.partition.WMCPartition;
import ru.yandex.wmtools.common.error.InternalException;
import ru.yandex.wmtools.common.service.AbstractDbService;

import java.util.List;

/**
 * User: azakharov
 * Date: 21.06.13
 * Time: 17:27
 */
public class TblConfigDao extends AbstractDbService {

    public Double getConfigDoubleValue(String keyName) throws InternalException {
        final String CONFIG_QUERY = "SELECT value FROM tbl_config WHERE name LIKE ?";
        List<Double> d = getJdbcTemplate(WMCPartition.nullPartition()).query(CONFIG_QUERY, new DoubleRowMapper(), keyName);
        return d.isEmpty() ? null : d.iterator().next();
    }
}
