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

import com.bocloud.common.utils.MapTools;
import com.bocloud.ims.entity.resource.hmc.HmcIplConfig;
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("hmcIplConfigRepository")
public class HmcIplConfigRepository extends EnhancedBaseRepository<HmcIplConfig, Long> {

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

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