aix
2024-07-24 2cba01a6b6f67cfa97d0c4e0cc589302fab817ba
skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/builder/oss/OssBuilder.java
@@ -16,6 +16,9 @@
 */
package cn.gistack.resource.builder.oss;
import cn.gistack.common.constant.CommonConstant;
import cn.gistack.resource.rule.MyOssRule;
import cn.gistack.resource.rule.PanoramaOSSRule;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.cache.utils.CacheUtil;
@@ -78,12 +81,32 @@
   /**
    * 获取template
    * @param prefixPath 上传文件前缀路径
    * @return OssTemplate
    */
   public OssTemplate templateByPrefixPath(String prefixPath) {
      return templateByPath(StringPool.EMPTY,prefixPath);
   }
   public OssTemplate templateByPrefixPathPanorama(String prefixPath ,String resGuid) {
      return templateByPathPanorama(StringPool.EMPTY,prefixPath,resGuid);
   }
   /**
    * 获取template
    *
    * @param code 资源编号
    * @return OssTemplate
    */
   public OssTemplate template(String code) {
      String tenantId = AuthUtil.getTenantId();
      if (StringUtil.isBlank(tenantId)){
         tenantId = "000000";
      }
      Oss oss = getOss(tenantId, code);
      Oss ossCached = ossPool.get(tenantId);
      OssTemplate template = templatePool.get(tenantId);
@@ -116,6 +139,67 @@
      return template;
   }
   /**
    * 自定义路径前缀获取template
    *
    * @param code 资源编号
    * @param prefixPath 上传文件前缀路径
    * @return OssTemplate
    */
   public OssTemplate templateByPath(String code,String prefixPath) {
      String tenantId = AuthUtil.getTenantId();
      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;
   }
   /**
    * 全景图片上传
    * @param code
    * @param prefixPath
    * @return
    */
   public OssTemplate templateByPathPanorama(String code,String prefixPath,String resGuid) {
      String tenantId = AuthUtil.getTenantId();
//      System.err.println("tenantId:"+tenantId);
      if (StringUtil.isBlank(tenantId)){
         tenantId = "000000";
      }
      Oss oss = getOss(tenantId, code);
      OssTemplate template = null;
//      template = templatePool.get(tenantId);
      PanoramaOSSRule ossRule = new PanoramaOSSRule(Boolean.FALSE,prefixPath,resGuid);
      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;
   }
   /**
    * 获取对象存储实体
    *