From 95b938586c9a6b0fe0d57157a999a999c33a0c48 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Fri, 08 Dec 2023 08:44:37 +0800
Subject: [PATCH] 适配多个校区
---
src/main/java/org/springblade/modules/mechanism/controller/MechanismController.java | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/springblade/modules/mechanism/controller/MechanismController.java b/src/main/java/org/springblade/modules/mechanism/controller/MechanismController.java
index 1a7caf9..d0d7200 100644
--- a/src/main/java/org/springblade/modules/mechanism/controller/MechanismController.java
+++ b/src/main/java/org/springblade/modules/mechanism/controller/MechanismController.java
@@ -16,6 +16,7 @@
*/
package org.springblade.modules.mechanism.controller;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.zxing.WriterException;
import io.minio.*;
import io.minio.errors.*;
@@ -35,6 +36,8 @@
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.resource.builder.oss.OssBuilder;
+import org.springblade.modules.resource.entity.Oss;
+import org.springblade.modules.resource.service.IOssService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.mechanism.entity.Mechanism;
@@ -68,6 +71,8 @@
public class MechanismController extends BladeController {
private final IMechanismService mechanismService;
+
+ private final IOssService ossService;
/**
* 对象存储构建类
@@ -135,7 +140,7 @@
String type = URLEncoder.encode(mechanism.getType(), "UTF-8");
String mtype = URLEncoder.encode(mechanism.getMtype(), "UTF-8");
String loutype = URLEncoder.encode(mechanism.getLoutype(), "UTF-8");
- String xtype = URLEncoder.encode(mechanism.getXtype(), "UTF-8");
+ String campus = URLEncoder.encode(mechanism.getCampus(), "UTF-8");
String heading = URLEncoder.encode(mechanism.getHeading(), "UTF-8");
String pitch = URLEncoder.encode(mechanism.getPitch(), "UTF-8");
String roll = URLEncoder.encode(mechanism.getRoll(), "UTF-8");
@@ -152,7 +157,7 @@
"&type=" + type +
"&mtype=" + mtype +
"&loutype=" + loutype +
- "&xtype=" + xtype +
+ "&campus=" + campus +
"&heading=" + heading +
"&pitch=" + pitch +
"&roll=" + roll +
@@ -223,11 +228,18 @@
}
private String upload(ByteArrayInputStream in) throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, InternalException, XmlParserException, ErrorResponseException {
+ QueryWrapper<Oss> wrapper = new QueryWrapper<>();
+ wrapper.eq("is_deleted",0);
+ Oss one = ossService.getOne(wrapper);
//填写你文件上传的地址以及相应信息
- String url = "http://106.225.193.35:2081";
- String access = "zhbaadmin";
- String secret = "zhbapassword";
- String bucket = "zhxy";
+// String url = "http://106.225.193.35:2081";
+// String access = "zhbaadmin";
+// String secret = "zhbapassword";
+// String bucket = "zhxy";
+ String url = one.getEndpoint();
+ String access = one.getAccessKey();
+ String secret = one.getSecretKey();
+ String bucket = one.getBucketName();
MinioClient minioClient =
MinioClient.builder()
.endpoint(url)
@@ -253,7 +265,8 @@
.build());
//文件推送
- String urls = "https://dev.jxpskj.com:8023/zhxy/"+newName;
+// String urls = "https://dev.jxpskj.com:8023/zhxy/"+newName;
+ String urls = url + "/"+ bucket + "/" + newName;
//返回
return urls;
}
--
Gitblit v1.9.3