From 64e6ac37d0bc034f849efa1d94792a7ef97c3adb Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 24 Dec 2024 16:48:00 +0800
Subject: [PATCH] 新增按前缀上传文件,相关查询修改
---
src/main/java/org/springblade/modules/resource/builder/OssBuilder.java | 58 +++++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 41 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/springblade/modules/resource/builder/OssBuilder.java b/src/main/java/org/springblade/modules/resource/builder/OssBuilder.java
index 2f57d34..75932a3 100644
--- a/src/main/java/org/springblade/modules/resource/builder/OssBuilder.java
+++ b/src/main/java/org/springblade/modules/resource/builder/OssBuilder.java
@@ -1,19 +1,3 @@
-/*
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * Neither the name of the dreamlu.net developer nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * Author: Chill 庄骞 (smallchill@163.com)
- */
package org.springblade.modules.resource.builder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -28,14 +12,15 @@
import org.springblade.core.oss.enums.OssEnum;
import org.springblade.core.oss.enums.OssStatusEnum;
import org.springblade.core.oss.props.OssProperties;
+import org.springblade.core.oss.rule.OssRule;
import org.springblade.core.secure.utils.AuthUtil;
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.entity.Oss;
import org.springblade.modules.resource.rule.context.OssContext;
+import org.springblade.modules.resource.rule.oss.MyOssRule;
import org.springblade.modules.resource.service.IOssService;
-
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -144,4 +129,43 @@
}
}
+ /**
+ * 获取template
+ * @param prefixPath 上传文件前缀路径
+ * @return OssTemplate
+ */
+ public OssTemplate templateByPrefix(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);
+
+ OssContext ossContext = new OssContext();
+ ossContext.setPrefix(prefixPath);
+ ossContext.setOss(oss);
+ ossContext.setOssProperties(ossProperties);
+ ossContext.setOssPool(ossPool);
+ ossContext.setTemplatePool(templatePool);
+
+ LiteflowResponse resp = flowExecutor.execute2Resp("ossChain", tenantId, ossContext);
+ if (resp.isSuccess()) {
+ OssContext contextBean = resp.getFirstContextBean();
+ return contextBean.getOssTemplate();
+ } else {
+ throw new ServiceException("未获取到对应的对象存储配置");
+ }
+ }
}
--
Gitblit v1.9.3