Browse Source

优化了文件上传目录

dev-V1.0.1
ganhao 6 months ago
parent
commit
46f42e14c1
  1. 83
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/common/config/RuoYiConfig.java
  2. 22
      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

83
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;
import org.dromara.common.core.utils.SpringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ -9,57 +10,54 @@ import org.springframework.stereotype.Component;
* @author ruoyi
*/
@Component
@ConfigurationProperties(prefix = "ruoyi")
@ConfigurationProperties(prefix = "zdxt")
public class RuoYiConfig
{
/** 项目名称 */
private String name;
/** 版本 */
private String version;
/** 版权年份 */
private String copyrightYear;
/** 上传路径配置 */
private FileConfig file = new FileConfig();
/** 实例演示开关 */
private boolean demoEnabled;
/**
* 文件配置内部类
*/
public static class FileConfig {
/** 上传路径 */
private static String profile;
private String uploadPath;
/** 获取地址开关 */
private static boolean addressEnabled;
/** URL前缀 */
private String urlPrefix;
public String getName()
{
return name;
}
/** 执法监督码地址 */
private String qrCodeUrl;
public void setName(String name)
{
this.name = name;
public String getUploadPath() {
return uploadPath;
}
public String getVersion()
{
return version;
public void setUploadPath(String uploadPath) {
this.uploadPath = uploadPath;
}
public void setVersion(String version)
{
this.version = version;
public String getUrlPrefix() {
return urlPrefix;
}
public String getCopyrightYear()
{
return copyrightYear;
public void setUrlPrefix(String urlPrefix) {
this.urlPrefix = urlPrefix;
}
public void setCopyrightYear(String copyrightYear)
{
this.copyrightYear = copyrightYear;
public String getQrCodeUrl() {
return qrCodeUrl;
}
public void setQrCodeUrl(String qrCodeUrl) {
this.qrCodeUrl = qrCodeUrl;
}
}
public boolean isDemoEnabled()
{
return demoEnabled;
@ -70,24 +68,31 @@ public class RuoYiConfig
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();
}
/**

22
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zdxt.enforcementcode.common.commonenum.PlatformTypeEnums;
import com.zdxt.enforcementcode.common.config.RuoYiConfig;
import com.zdxt.enforcementcode.common.util.*;
import com.zdxt.enforcementcode.domain.EnterpriseInformation;
import com.zdxt.enforcementcode.domain.EnterpriseUser;
@ -97,11 +98,14 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
@Value("${sjdm.profile}")
private String filePath;
// @Value("${sjdm.profile}")
// private String filePath;
//
// @Value("${sjdm.qr_code_url}")
// private String qrCodeUrl;
@Value("${sjdm.qr_code_url}")
private String qrCodeUrl;
@Autowired
RuoYiConfig ruoYiConfig;
@Value("${siq.mock.enabled:false}")
private boolean mockEnabled;
@ -430,9 +434,9 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService
jsonMap.put("type", "zfjd");
String text = JSON.toJSONString(jsonMap);
//这里设置自定义网站url
String logoPath = qrCodeUrl;
String logoPath = ruoYiConfig.getFile().getQrCodeUrl();
try {
File encode = QRCodeUtil.encodeFile(text, logoPath, filePath, true);
File encode = QRCodeUtil.encodeFile(text, logoPath, ruoYiConfig.getFile().getUploadPath(), true);
MultipartFile multipartFile = QRCodeUtil.getMultipartFile(encode);
String upload = fileUploadApi.upload(multipartFile);
@ -524,8 +528,12 @@ public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService
private JSONObject getMockSiqUserInfo(String code) {
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("account", "test001" + (code != null ? code.hashCode() % 1000 : 1));
userInfo.put("account", account);
userInfo.put("userName", "测试用户");
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:
file:
upload-path: D:/usr/local/uploadPath
upload-path: /usr/local/uploadPath
# upload-path: /Users/vincent/uploadPath
url-prefix: /profile
qr_code_url: /usr/local/uploads/zfjd_logo.png
demo_enabled: false
--- # 监控中心配置
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,用逗号分隔
token-name: ${sa-token.token-name},clientid
# 项目相关配置
sjdm:
## 项目相关配置
#sjdm:
# 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:

Loading…
Cancel
Save