package com.yunfeiyun.agmp.common.framework.oss.cloud;


import com.yunfeiyun.agmp.common.constant.ResConstants;
import com.yunfeiyun.agmp.common.framework.config.properties.OSSProperties;
import com.yunfeiyun.agmp.common.framework.web.service.PolicyService;
import com.yunfeiyun.agmp.common.utils.spring.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 文件上传OssFactory
 * @author 杨晓辉
 */
@Component
public final class OSSFactory {
    private static final Logger log = LoggerFactory.getLogger(OSSFactory.class);
    private static OSSProperties ossConfig;

    static {
        ossConfig = SpringUtils.getBean(PolicyService.class).getOSSConfig();
        log.info("OSSConfig={}", ossConfig.toString());
    }

    public static AbstractCloudStorageService build(){
        if(ossConfig.getOssType() == Integer.parseInt(ResConstants.ossType.ALIYUN.getValue())){
            return new AliyunCloudStorageService(ossConfig);
        }

        return null;
    }

}