fix(sip): 优化合作伙伴二维码生成逻辑

- 使用 Paths.get() 构建文件路径,提高代码可读性
- 添加日志记录生成二维码路径
-增加创建父目录逻辑,确保目录结构存在
- 移除冗余的文件存在性检查
master
chenhao 2025-07-11 09:57:56 +08:00
parent 903bdd41d9
commit b8090e4bfe
1 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.ruoyi.sip.controller; package com.ruoyi.sip.controller;
import java.io.File; import java.io.File;
import java.nio.file.Paths;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -166,9 +167,12 @@ public class PartnerInfoController extends BaseController
try { try {
PartnerInfo partnerInfo = partnerInfoService.selectPartnerInfoById(id); PartnerInfo partnerInfo = partnerInfoService.selectPartnerInfoById(id);
String localPath = RuoYiConfig.getProfile(); String localPath = RuoYiConfig.getProfile();
String filePath = localPath + File.separator +"partner"+ File.separator +partnerInfo.getPartnerCode()+".jpg"; String filePath = Paths.get(localPath, "partner", partnerInfo.getPartnerCode() + ".jpg").toString();
if (!FileUtil.exist(filePath)){ log.info("Generating QR code at: {}", filePath);
new File(filePath).createNewFile(); File file = new File(filePath);
if (!file.getParentFile().exists()) {
// 自动创建目录结构
file.getParentFile().mkdirs();
} }
StringBuilder url=new StringBuilder(); StringBuilder url=new StringBuilder();
url.append("http://oms.unissense.top") url.append("http://oms.unissense.top")