| | |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springblade.modules.resource.endpoint.OssEndpoint; |
| | | import org.springblade.modules.resource.entity.Oss; |
| | | import org.springblade.modules.resource.rule.MyOssRule; |
| | | import org.springblade.modules.resource.service.IOssService; |
| | | |
| | | import java.util.Map; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取template |
| | | * @param prefixPath 上传文件前缀路径 |
| | | * @return OssTemplate |
| | | */ |
| | | public OssTemplate templateByPrefixPath(String prefixPath) { |
| | | return templateByPath(StringPool.EMPTY,prefixPath); |
| | | } |
| | | |
| | | /** |
| | | * 自定义路径前缀获取template |
| | | * |
| | | * @param code 资源编号 |
| | | * @param prefixPath 上传文件前缀路径 |
| | | * @return OssTemplate |
| | | */ |
| | | public OssTemplate templateByPath(String code,String prefixPath) { |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | if (Strings.isBlank(tenantId)){ |
| | | tenantId = "000000"; |
| | | } |
| | | Oss oss = getOss(tenantId, code); |
| | | OssTemplate template = templatePool.get(tenantId); |
| | | template = templatePool.get(tenantId); |
| | | OssRule ossRule = new MyOssRule(Boolean.FALSE,prefixPath); |
| | | if (oss.getCategory() == OssEnum.MINIO.getCategory()) { |
| | | template = MinioOssBuilder.template(oss, ossRule); |
| | | } else if (oss.getCategory() == OssEnum.QINIU.getCategory()) { |
| | | template = QiniuOssBuilder.template(oss, ossRule); |
| | | } else if (oss.getCategory() == OssEnum.ALI.getCategory()) { |
| | | template = AliOssBuilder.template(oss, ossRule); |
| | | } else if (oss.getCategory() == OssEnum.TENCENT.getCategory()) { |
| | | template = TencentOssBuilder.template(oss, ossRule); |
| | | } |
| | | templatePool.put(tenantId, template); |
| | | ossPool.put(tenantId, oss); |
| | | return template; |
| | | } |
| | | } |