| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.oss.OssTemplate; |
| | |
| | | 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 |
| | | * |
| | | * @return OssProperties |
| | | */ |
| | | public OssProperties ossProperties() { |
| | | return ossProperties; |
| | | } |
| | | |
| | | /** |
| | | * 获取template |
| | | * |
| | | * @return OssTemplate |
| | | */ |
| | | public OssTemplate template() { |
| | |
| | | */ |
| | | public OssTemplate template(String code) { |
| | | String tenantId = AuthUtil.getTenantId(); |
| | | if (Strings.isBlank(tenantId)){ |
| | | tenantId = "000000"; |
| | | } |
| | | Oss oss = getOss(tenantId, code); |
| | | Oss ossCached = ossPool.get(tenantId); |
| | | OssTemplate template = templatePool.get(tenantId); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取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; |
| | | } |
| | | } |