package com.bocloud.ims.service.transportor;

import com.bocloud.common.model.BocloudResult;
import com.bocloud.ims.entity.resource.CloudVendor;
import com.bocloud.ims.entity.resource.hmc.HmdServer;
import com.bocloud.ims.repository.resource.hmc.HmdServerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HmdTransportor {

	@Autowired
	private HmdServerRepository serverRepository;

	@Transactional
	public BocloudResult sync(CloudVendor vendor, Object data, Long userId) {
		List<HmdServer> newServers = (List<HmdServer>) data;
		List<HmdServer> oldServers = serverRepository.listByVendorId(vendor.getId());
		serverRepository.syncList(newServers, oldServers, userId);
		return new BocloudResult(true, "执行成功");
	}

}
