From 1a4792fdff667d3b9590c6ab4c085a08cdca1399 Mon Sep 17 00:00:00 2001
From: zrj <646384940@qq.com>
Date: Thu, 24 Oct 2024 14:07:18 +0800
Subject: [PATCH] 修改端口
---
src/main/java/org/springblade/modules/architecture/controller/ArchitectureController.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/springblade/modules/architecture/controller/ArchitectureController.java b/src/main/java/org/springblade/modules/architecture/controller/ArchitectureController.java
index a40f487..fd46f68 100644
--- a/src/main/java/org/springblade/modules/architecture/controller/ArchitectureController.java
+++ b/src/main/java/org/springblade/modules/architecture/controller/ArchitectureController.java
@@ -16,6 +16,7 @@
*/
package org.springblade.modules.architecture.controller;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.zxing.WriterException;
import io.minio.*;
import io.minio.errors.*;
@@ -33,6 +34,7 @@
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.oss.model.OssFile;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.life.entity.Life;
@@ -40,6 +42,7 @@
import org.springblade.modules.mechanism.entity.Mechanism;
import org.springblade.modules.mechanism.service.IMechanismService;
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.core.io.support.ResourceRegion;
import org.springframework.http.ResponseEntity;
@@ -50,7 +53,7 @@
import org.springblade.modules.architecture.service.IArchitectureService;
import org.springblade.core.boot.ctrl.BladeController;
import springfox.documentation.annotations.ApiIgnore;
-import sun.misc.BASE64Encoder;
+//import sun.misc.BASE64Encoder;
import java.io.*;
import java.net.URLEncoder;
@@ -71,6 +74,9 @@
@RequestMapping("blade-architecture/architecture")
@Api(value = "", tags = "接口")
public class ArchitectureController extends BladeController {
+
+
+ private final IOssService ossService;
private final IArchitectureService architectureService;
private final IMechanismService mechanismService;
@@ -286,8 +292,8 @@
* @return
*/
@GetMapping("/selectArchALL")
- public R selectArchALL() {
- return R.data(architectureService.selectArchALL());
+ public R selectArchALL(ArchitectureVO architecture) {
+ return R.data(architectureService.selectArchALL(architecture));
}
/**
@@ -403,12 +409,13 @@
* 校园搜索
*
* @param mechanismName 名称模糊查询
+ * @param campus 所属校区
* @return
*/
@GetMapping("/selectLook")
- public R selectLook(String mechanismName) {
+ public R selectLook(String mechanismName,String campus) {
List list = new ArrayList();
- List<Map<Object, Object>> maps = architectureService.selectLook(mechanismName);
+ List<Map<Object, Object>> maps = architectureService.selectLook(mechanismName,campus);
//排除为null的数据
List<Map<Object, Object>> list2 = maps.parallelStream().filter(Objects::nonNull).collect(Collectors.toList());
// for (int i = 0; i < list2.size(); i++) {
@@ -426,7 +433,7 @@
*/
@GetMapping("/url")
public void url() throws IOException, ServerException, InsufficientDataException, NoSuchAlgorithmException, InternalException, InvalidResponseException, XmlParserException, InvalidKeyException, ErrorResponseException {
- List<Architecture> list = architectureService.selectArchALL();
+ List<Architecture> list = architectureService.selectArchALL(null);
for (Architecture architecture : list) {
int index = architecture.getCodeurl().lastIndexOf(",") +1;
String substring = architecture.getCodeurl().substring(index);
@@ -441,11 +448,19 @@
}
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)
@@ -471,8 +486,28 @@
.build());
//文件推送
- String urls = "https://dev.jxpskj.com:8023/zhxy/"+newName;
+ String urls = url + "/"+ bucket +"/" + newName;
//返回
return urls;
}
+
+
+ /**
+ * 二维码重新生成 code url 转换
+ */
+ @GetMapping("/refreshCode")
+ public void refreshCode() throws IOException, ServerException, InsufficientDataException, NoSuchAlgorithmException, InternalException, InvalidResponseException, XmlParserException, InvalidKeyException, ErrorResponseException {
+ List<Architecture> list = architectureService.selectArchALL(null);
+ for (Architecture architecture : list) {
+ int index = architecture.getCodeurl().lastIndexOf(",") +1;
+ String substring = architecture.getCodeurl().substring(index);
+ byte[] qrCodeImage = Base64Util.decode(substring);
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(qrCodeImage);
+ String url = upload(inputStream);
+ architecture.setCodeurl(url);
+ architectureService.updateById(architecture);
+ //关闭流
+ inputStream.close();
+ }
+ }
}
--
Gitblit v1.9.3