forked from lilishop/lilishop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
519a608
commit a22ccbd
Showing
11 changed files
with
320 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
framework/src/main/java/cn/lili/modules/file/entity/enums/OssEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cn.lili.modules.file.entity.enums; | ||
|
||
import com.aliyun.oss.OSS; | ||
|
||
/** | ||
* OssEnum | ||
* | ||
* @author Chopper | ||
* @version v1.0 | ||
* 2022-06-06 11:23 | ||
*/ | ||
public enum OssEnum { | ||
/** | ||
* | ||
*/ | ||
ALI_OSS, MINIO; | ||
} |
11 changes: 9 additions & 2 deletions
11
...odules/file/plugin/FileManagerPlugin.java → .../lili/modules/file/plugin/FilePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
framework/src/main/java/cn/lili/modules/file/plugin/FilePluginFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cn.lili.modules.file.plugin; | ||
|
||
import cn.hutool.json.JSONUtil; | ||
import cn.lili.common.exception.ServiceException; | ||
import cn.lili.modules.file.entity.enums.OssEnum; | ||
import cn.lili.modules.file.plugin.impl.AliFilePlugin; | ||
import cn.lili.modules.file.plugin.impl.MinioFilePlugin; | ||
import cn.lili.modules.system.entity.dos.Setting; | ||
import cn.lili.modules.system.entity.dto.OssSetting; | ||
import cn.lili.modules.system.entity.enums.SettingEnum; | ||
import cn.lili.modules.system.service.SettingService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* 文件服务抽象工厂 直接返回操作类 | ||
* | ||
* @author Chopper | ||
* @version v1.0 | ||
* 2022-06-06 11:35 | ||
*/ | ||
@Component | ||
public class FilePluginFactory { | ||
|
||
|
||
@Autowired | ||
private SettingService settingService; | ||
|
||
|
||
/** | ||
* 获取oss client | ||
* | ||
* @return | ||
*/ | ||
public FilePlugin filePlugin() { | ||
|
||
OssSetting ossSetting = null; | ||
try { | ||
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name()); | ||
|
||
ossSetting = JSONUtil.toBean(setting.getSettingValue(), OssSetting.class); | ||
|
||
|
||
switch (OssEnum.valueOf(ossSetting.getType())) { | ||
|
||
case MINIO: | ||
return new MinioFilePlugin(ossSetting); | ||
case ALI_OSS: | ||
return new AliFilePlugin(ossSetting); | ||
default: | ||
throw new ServiceException(); | ||
} | ||
} catch (Exception e) { | ||
throw new ServiceException(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.