wente
2024-11-07 12e38a9c58fa02cc42104793609ac4e240bc6184
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有,侵权必究!
 */
 
package com.zt.config;
 
import com.zt.core.oss.encry.IOssEncryptService;
import com.zt.modules.oss.cloud.AbstractStorageService;
import com.zt.modules.oss.cloud.LocalStorageService;
import com.zt.modules.oss.cloud.QdStorageConfig;
import com.zt.modules.oss.cloud.StorageConfig;
import com.zt.modules.oss.enums.CloudChannel;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
/**
 * 云存储配置信息
 *
 * @author hehz
 */
@Configuration
@Data
public class CloudStorageConfig {
 
    @Value("${zt.oss.local-domain}")
    private String localDomain;
 
    @Value("${zt.oss.local-path}")
    private String localPath;
 
    @Value("${zt.oss.local-qd-path}")
    private String qdLocalPath;
 
    @Value("${zt.oss.local-prefix}")
    private String localPrefix;
 
    @Autowired
    private IOssEncryptService ossEncryptService;
 
    @Bean
    public AbstractStorageService getService() {
        StorageConfig config = new StorageConfig();
        QdStorageConfig qdConfig = new QdStorageConfig();
        config.setType(CloudChannel.LOCAL.getValue());
        config.setLocalDomain(localDomain);
        config.setLocalPath(localPath);
        config.setLocalPrefix(localPrefix);
        qdConfig.setQdLype(CloudChannel.LOCAL.getValue());
        qdConfig.setQdLocalDomain(localDomain);
        qdConfig.setQdLocalPath(qdLocalPath);
        qdConfig.setQdLocalPrefix(localPrefix);
        return new LocalStorageService(config, qdConfig, ossEncryptService);
    }
}