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

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

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

/**
 * HMC系统CPU配置数据访问对象
 *
 * @author sxp
 * @since May 23, 2018
 */
@Deprecated
@Repository("hmcSystemProcessorConfigRepository")
public class HmcSystemProcessorConfigRepository extends EnhancedBaseRepository<HmcSystemProcessorConfig, Long> {

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