package com.bocloud.ims.service.resource;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.cmp.driver.compute.FolderDriver;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.ims.entity.resource.CloudVendor;
import com.bocloud.ims.interfaces.resource.FolderService;
import com.bocloud.ims.repository.resource.CloudVendorRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: FolderServiceImpl
 * @Description:
 * @Author lxy
 * @Date 2021/5/12 10:58
 */
@Service("folderService")
public class FolderServiceImpl implements FolderService {
    private static Logger logger = LoggerFactory.getLogger(FolderServiceImpl.class);
    @Autowired
    private CloudVendorRepository cloudVendorRepository;
    @Autowired
    private FolderDriver folderDriver;

    @Override
    public BocloudResult list(Long vendorId,String vdcName) {
        CloudVendor vendor = cloudVendorRepository.query(vendorId);
        if (null != vendor) {
            BocloudResult result = folderDriver.list(vendor.getUuid(),vdcName);
            if (null != result.getData()) {
                return result;
            }
        }
        return new BocloudResult(false, "获取虚拟机文件夹失败,"+vendorId+"对应vendor查询失败");
    }
}
