From 38e75e6b6b81cf551f57fbb8da42dc43438e17b1 Mon Sep 17 00:00:00 2001
From: mocheng <3057647414@qq.com>
Date: Mon, 18 Aug 2025 19:46:03 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=BF=E5=AE=A2=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E5=9B=BE=E7=89=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../api/RemoteVisitoreGetCodeInfoService.java | 5 +++++
.../dubbo/RemoteVisitoreGetCodeInfo.java | 19 +++++++++++++++++++
ruoyi-modules/ruoyi-resource/pom.xml | 4 ++++
.../resource/controller/SysOssController.java | 13 +++++++++----
.../resource/service/ISysOssService.java | 2 +-
.../service/impl/SysOssServiceImpl.java | 6 +++---
6 files changed, 41 insertions(+), 8 deletions(-)
create mode 100644 ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteVisitoreGetCodeInfoService.java
create mode 100644 ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteVisitoreGetCodeInfo.java
diff --git a/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteVisitoreGetCodeInfoService.java b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteVisitoreGetCodeInfoService.java
new file mode 100644
index 00000000..255df77f
--- /dev/null
+++ b/ruoyi-api/property-api/src/main/java/org/dromara/property/api/RemoteVisitoreGetCodeInfoService.java
@@ -0,0 +1,5 @@
+package org.dromara.property.api;
+
+public interface RemoteVisitoreGetCodeInfoService {
+ String getCodeInfo(String code);
+}
diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteVisitoreGetCodeInfo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteVisitoreGetCodeInfo.java
new file mode 100644
index 00000000..726ab370
--- /dev/null
+++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteVisitoreGetCodeInfo.java
@@ -0,0 +1,19 @@
+package org.dromara.property.dubbo;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.dromara.common.core.constant.GlobalConstants;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.property.api.RemoteVisitoreGetCodeInfoService;
+import org.dromara.property.domain.bo.QrCodeInfo;
+
+@DubboService
+@RequiredArgsConstructor
+public class RemoteVisitoreGetCodeInfo implements RemoteVisitoreGetCodeInfoService {
+
+ @Override
+ public String getCodeInfo(String code) {
+ QrCodeInfo info = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY +"Qrcode" +code);
+ return info.getUserid().toString();
+ }
+}
diff --git a/ruoyi-modules/ruoyi-resource/pom.xml b/ruoyi-modules/ruoyi-resource/pom.xml
index 90e4b66e..13bc9242 100644
--- a/ruoyi-modules/ruoyi-resource/pom.xml
+++ b/ruoyi-modules/ruoyi-resource/pom.xml
@@ -117,6 +117,10 @@
org.dromara
ruoyi-api-resource
+
+ org.dromara
+ property-api
+
diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysOssController.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysOssController.java
index 8d6a8849..231e3dc3 100644
--- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysOssController.java
+++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/controller/SysOssController.java
@@ -4,6 +4,8 @@ package org.dromara.resource.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.constant.GlobalConstants;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.QueryGroup;
@@ -13,6 +15,7 @@ import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.property.api.RemoteVisitoreGetCodeInfoService;
import org.dromara.resource.domain.QrCodeInfo;
import org.dromara.resource.domain.bo.SysOssBo;
import org.dromara.resource.domain.vo.SysOssUploadVo;
@@ -41,7 +44,8 @@ import java.util.List;
public class SysOssController extends BaseController {
private final ISysOssService iSysOssService;
-
+ @DubboReference
+ private RemoteVisitoreGetCodeInfoService remoteVisitoreGetCodeInfoService;
/**
* 查询OSS对象存储列表
*/
@@ -96,12 +100,13 @@ public class SysOssController extends BaseController {
if (ObjectUtil.isNull(file)) {
return R.fail("上传文件不能为空");
}
- QrCodeInfo info = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY+"Qrcode" + code);
- if (info==null){
+ String codeInfo = remoteVisitoreGetCodeInfoService.getCodeInfo(code);
+// QrCodeInfo info = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY+"Qrcode" + code);
+ if (codeInfo.isBlank()){
return R.fail("二维码已过期");
}
- SysOssVo oss = iSysOssService.qrupload(file,info);
+ SysOssVo oss = iSysOssService.qrupload(file,codeInfo);
SysOssUploadVo uploadVo = new SysOssUploadVo();
uploadVo.setUrl(oss.getUrl());
uploadVo.setFileName(oss.getOriginalName());
diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/ISysOssService.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/ISysOssService.java
index 22472437..1b2a2b9c 100644
--- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/ISysOssService.java
+++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/ISysOssService.java
@@ -67,7 +67,7 @@ public interface ISysOssService {
* @param file 要上传的 MultipartFile 对象
* @return 上传成功后的 SysOssVo 对象,包含文件信息
*/
- SysOssVo qrupload(MultipartFile file, QrCodeInfo qrCodeInfo);
+ SysOssVo qrupload(MultipartFile file, String qrCodeInfo);
/**
* 上传文件到对象存储服务,并保存文件信息到数据库
diff --git a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/impl/SysOssServiceImpl.java b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/impl/SysOssServiceImpl.java
index 6069bc5d..48ab3a39 100644
--- a/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/impl/SysOssServiceImpl.java
+++ b/ruoyi-modules/ruoyi-resource/src/main/java/org/dromara/resource/service/impl/SysOssServiceImpl.java
@@ -200,7 +200,7 @@ public class SysOssServiceImpl implements ISysOssService {
}
@Override
- public SysOssVo qrupload(MultipartFile file, QrCodeInfo info) {
+ public SysOssVo qrupload(MultipartFile file, String info) {
String originalfileName = file.getOriginalFilename();
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
OssClient storage = OssFactory.instance();
@@ -242,14 +242,14 @@ public class SysOssServiceImpl implements ISysOssService {
return this.matchingUrl(sysOssVo);
}
- private SysOssVo buildResultEntityQr(String originalfileName, String suffix, String configKey, UploadResult uploadResult,QrCodeInfo info) {
+ private SysOssVo buildResultEntityQr(String originalfileName, String suffix, String configKey, UploadResult uploadResult,String info) {
SysOss oss = new SysOss();
oss.setUrl(uploadResult.getUrl());
oss.setFileSuffix(suffix);
oss.setFileName(uploadResult.getFilename());
oss.setOriginalName(originalfileName);
oss.setService(configKey);
- oss.setCreateBy(info.getUserid());
+ oss.setCreateBy(Long.valueOf(info));
oss.setCreateTime(new Date());
baseMapper.insert(oss);
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);