DfsConfiguration.java
1.52 KB
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
package com.diligrp.assistant.dfs;
import com.diligrp.assistant.dfs.pipeline.DefaultDfsPipelineManager;
import com.diligrp.assistant.dfs.pipeline.DfsPipeline;
import com.diligrp.assistant.dfs.pipeline.DfsPipelineManager;
import com.diligrp.assistant.dfs.pipeline.OssPipeline;
import com.diligrp.assistant.shared.mybatis.MybatisMapperSupport;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.diligrp.assistant.dfs")
@MapperScan(basePackages = {"com.diligrp.assistant.dfs.dao"}, markerInterface = MybatisMapperSupport.class)
public class DfsConfiguration {
@Bean
@ConfigurationProperties("dfs")
public DfsProperties dfsProperties() {
return new DfsProperties();
}
@Bean
public DfsPipelineManager dfsPipelineManager(DfsProperties properties) {
DfsPipelineManager pipelineManager = new DefaultDfsPipelineManager();
DfsProperties.Oss oss = properties.getOss();
if (oss != null) {
// 可利用数据库进行通道配置, 前期并没有必要
DfsPipeline pipeline = new OssPipeline(10, "OSS文件存储服务", oss.getUri(),
oss.getAccessKeyId(), oss.getAccessKeySecret());
pipelineManager.registerPipeline(pipeline);
}
return pipelineManager;
}
}