Browse Source

优化了文件上传目录

dev-V1.0.1
ganhao 6 months ago
parent
commit
46f42e14c1
  1. 93
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/common/config/RuoYiConfig.java
  2. 24
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/enterprise/impl/AppEnterpriseLoginServiceImpl.java
  3. 5
      zdxt-web-server/zdxt-admin-web-server/src/main/resources/application-dev.yml
  4. 7
      zdxt-web-server/zdxt-admin-web-server/src/main/resources/application.yml

93
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/common/config/RuoYiConfig.java

@ -1,5 +1,6 @@
package com.zdxt.enforcementcode.common.config; package com.zdxt.enforcementcode.common.config;
import org.dromara.common.core.utils.SpringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -9,57 +10,54 @@ import org.springframework.stereotype.Component;
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
@ConfigurationProperties(prefix = "ruoyi") @ConfigurationProperties(prefix = "zdxt")
public class RuoYiConfig public class RuoYiConfig
{ {
/** 项目名称 */ /** 上传路径配置 */
private String name; private FileConfig file = new FileConfig();
/** 版本 */
private String version;
/** 版权年份 */
private String copyrightYear;
/** 实例演示开关 */ /** 实例演示开关 */
private boolean demoEnabled; private boolean demoEnabled;
/** 上传路径 */ /**
private static String profile; * 文件配置内部类
*/
public static class FileConfig {
/** 上传路径 */
private String uploadPath;
/** 获取地址开关 */ /** URL前缀 */
private static boolean addressEnabled; private String urlPrefix;
public String getName() /** 执法监督码地址 */
{ private String qrCodeUrl;
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getVersion() public String getUploadPath() {
{ return uploadPath;
return version; }
}
public void setVersion(String version) public void setUploadPath(String uploadPath) {
{ this.uploadPath = uploadPath;
this.version = version; }
}
public String getCopyrightYear() public String getUrlPrefix() {
{ return urlPrefix;
return copyrightYear; }
}
public void setCopyrightYear(String copyrightYear) public void setUrlPrefix(String urlPrefix) {
{ this.urlPrefix = urlPrefix;
this.copyrightYear = copyrightYear; }
public String getQrCodeUrl() {
return qrCodeUrl;
}
public void setQrCodeUrl(String qrCodeUrl) {
this.qrCodeUrl = qrCodeUrl;
}
} }
public boolean isDemoEnabled() public boolean isDemoEnabled()
{ {
return demoEnabled; return demoEnabled;
@ -70,24 +68,31 @@ public class RuoYiConfig
this.demoEnabled = demoEnabled; this.demoEnabled = demoEnabled;
} }
public static String getProfile() public FileConfig getFile()
{ {
return profile; return file;
} }
public void setProfile(String profile) public void setFile(FileConfig file)
{ {
RuoYiConfig.profile = profile; this.file = file;
} }
public static boolean isAddressEnabled() /**
* 获取上传路径(兼容旧代码)
*/
public static String getProfile()
{ {
return addressEnabled; // 需要通过 Spring 上下文获取 bean,这里提供静态访问方式
return SpringUtils.getBean(RuoYiConfig.class).getFile().getUploadPath();
} }
public void setAddressEnabled(boolean addressEnabled) /**
* 获取 URL 前缀(兼容旧代码)
*/
public static String getUrlPrefix()
{ {
RuoYiConfig.addressEnabled = addressEnabled; return SpringUtils.getBean(RuoYiConfig.class).getFile().getUrlPrefix();
} }
/** /**

24
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/enterprise/impl/AppEnterpriseLoginServiceImpl.java

@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zdxt.enforcementcode.common.commonenum.PlatformTypeEnums; import com.zdxt.enforcementcode.common.commonenum.PlatformTypeEnums;
import com.zdxt.enforcementcode.common.config.RuoYiConfig;
import com.zdxt.enforcementcode.common.util.*; import com.zdxt.enforcementcode.common.util.*;
import com.zdxt.enforcementcode.domain.EnterpriseInformation; import com.zdxt.enforcementcode.domain.EnterpriseInformation;
import com.zdxt.enforcementcode.domain.EnterpriseUser; import com.zdxt.enforcementcode.domain.EnterpriseUser;
@ -97,11 +98,14 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
@Value("${sjdm.profile}") // @Value("${sjdm.profile}")
private String filePath; // private String filePath;
//
// @Value("${sjdm.qr_code_url}")
// private String qrCodeUrl;
@Value("${sjdm.qr_code_url}") @Autowired
private String qrCodeUrl; RuoYiConfig ruoYiConfig;
@Value("${siq.mock.enabled:false}") @Value("${siq.mock.enabled:false}")
private boolean mockEnabled; private boolean mockEnabled;
@ -430,9 +434,9 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService
jsonMap.put("type", "zfjd"); jsonMap.put("type", "zfjd");
String text = JSON.toJSONString(jsonMap); String text = JSON.toJSONString(jsonMap);
//这里设置自定义网站url //这里设置自定义网站url
String logoPath = qrCodeUrl; String logoPath = ruoYiConfig.getFile().getQrCodeUrl();
try { try {
File encode = QRCodeUtil.encodeFile(text, logoPath, filePath, true); File encode = QRCodeUtil.encodeFile(text, logoPath, ruoYiConfig.getFile().getUploadPath(), true);
MultipartFile multipartFile = QRCodeUtil.getMultipartFile(encode); MultipartFile multipartFile = QRCodeUtil.getMultipartFile(encode);
String upload = fileUploadApi.upload(multipartFile); String upload = fileUploadApi.upload(multipartFile);
@ -523,9 +527,13 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService
*/ */
private JSONObject getMockSiqUserInfo(String code) { private JSONObject getMockSiqUserInfo(String code) {
JSONObject userInfo = new JSONObject(); JSONObject userInfo = new JSONObject();
// 随机生成账号:test + 6位随机数字
String randomSuffix = String.format("%06d", (int)(Math.random() * 1000000));
String account = "test" + randomSuffix;
userInfo.put("userId", "100001"); userInfo.put("userId", "100001");
userInfo.put("account", "test001" + (code != null ? code.hashCode() % 1000 : 1)); userInfo.put("account", account);
userInfo.put("userName", "测试用户"); userInfo.put("userName", "测试用户");
userInfo.put("phone", IdCardCryptoUtil.symmetricEncryptIdCard(secretKey, "13800138000")); userInfo.put("phone", IdCardCryptoUtil.symmetricEncryptIdCard(secretKey, "13800138000"));

5
zdxt-web-server/zdxt-admin-web-server/src/main/resources/application-dev.yml

@ -1,7 +1,10 @@
zdxt: zdxt:
file: file:
upload-path: D:/usr/local/uploadPath upload-path: /usr/local/uploadPath
# upload-path: /Users/vincent/uploadPath
url-prefix: /profile url-prefix: /profile
qr_code_url: /usr/local/uploads/zfjd_logo.png
demo_enabled: false
--- # 监控中心配置 --- # 监控中心配置
spring.boot.admin.client: spring.boot.admin.client:

7
zdxt-web-server/zdxt-admin-web-server/src/main/resources/application.yml

@ -323,11 +323,10 @@ warm-flow:
# 默认Authorization,如果有多个token,用逗号分隔 # 默认Authorization,如果有多个token,用逗号分隔
token-name: ${sa-token.token-name},clientid token-name: ${sa-token.token-name},clientid
# 项目相关配置 ## 项目相关配置
sjdm: #sjdm:
# profile: /usr/local/uploadPath # profile: /usr/local/uploadPath
profile: /Users/vincent/uploadPath # qr_code_url: /usr/local/uploads/zfjd_logo.png
qr_code_url: /usr/local/uploads/zfjd_logo.png
# Spring Boot RestTemplate 超时配置 # Spring Boot RestTemplate 超时配置
spring: spring:

Loading…
Cancel
Save