package com.bocloud.ims.repository.resource;

import com.bocloud.common.model.Param;
import com.bocloud.database.core.intf.impl.BasicGenericDao;
import com.bocloud.database.utils.QueryBuilder;
import com.bocloud.ims.entity.resource.ClusterUsage;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

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

/**
 * 集群资源使用统计数据访问实现
 * 
 * @author wangyu
 * @version 1.0
 * @since 2020年5月15日
 *
 */
@Repository("clusterUsageRepository")
public class ClusterUsageRepository extends BasicGenericDao<ClusterUsage, Long> {

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

	public List<ClusterUsage> list(List<Param> params, Map<String, String> sorter) throws Exception {
		String sql = "select a.* from cluster_usage a where 1 = 1";
		sql = QueryBuilder.buildRaw(sql, params, sorter, "a");
		Map<String, Object> paramMap = QueryBuilder.getParam(params);
		return this.list(ClusterUsage.class, sql, paramMap);
	}

}
