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

import com.bocloud.common.utils.MapTools;
import com.bocloud.ims.entity.resource.hmc.HmcSystemMemoryConfig;
import com.bocloud.ims.repository.resource.common.EnhancedBaseRepository;
import org.springframework.stereotype.Repository;

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

/**
 * HMC系统内存配置数据访问对象
 * 
 * @author sxp
 * @since May 23, 2018
 */
@Deprecated
@Repository("hmcSystemMemoryConfigRepository")
public class HmcSystemMemoryConfigRepository extends EnhancedBaseRepository<HmcSystemMemoryConfig, Long> {

	public void deleteByServerId(Long serverId) {
		String sql = "delete from hmc_system_memory_config where server_id = :serverId";
		Map<String, Object> params = MapTools.simpleMap("serverId", serverId);
		this.update(sql, params);
	}

	public HmcSystemMemoryConfig getByServerId(Long serverId) {
		String sql = "select a.* from hmc_system_memory_config a where a.server_id = :serverId";
		Map<String, Object> params = MapTools.simpleMap("serverId", serverId);
		List<HmcSystemMemoryConfig> list = this.list(HmcSystemMemoryConfig.class, sql, params);
		if (list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}
}
