diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java index 9eead01..193971d 100644 --- a/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java +++ b/src/main/java/com/sqx/modules/app/service/impl/UserServiceImpl.java @@ -62,6 +62,7 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import weixin.popular.api.SnsAPI; @@ -84,6 +85,9 @@ import java.util.*; @Service("userService") @Slf4j public class UserServiceImpl extends ServiceImpl implements UserService { + @Value("${file.upload.url}") + public static String fileUrl = ""; + @Autowired private UserVipService userVipService; @Autowired @@ -1054,7 +1058,7 @@ public class UserServiceImpl extends ServiceImpl implements // 配置通知栏图标 notification.setLogo("icon.png"); //配置通知栏图标,需要在客户端开发时嵌入,默认为push.png // 配置通知栏网络图标 - notification.setLogoUrl(commonInfoService.findOne(19).getValue() + "/logo.png"); + notification.setLogoUrl(fileUrl + "/file/logo.png"); notification.setTitle(title); notification.setBody(content); notification.setClickType("url"); diff --git a/src/main/java/com/sqx/modules/file/AliFileUploadController.java b/src/main/java/com/sqx/modules/file/AliFileUploadController.java index 8b2aa50..b7ea682 100644 --- a/src/main/java/com/sqx/modules/file/AliFileUploadController.java +++ b/src/main/java/com/sqx/modules/file/AliFileUploadController.java @@ -33,6 +33,8 @@ public class AliFileUploadController { @Value("${file.upload.path}") public String filePath = ""; + @Value("${file.upload.url}") + public String fileUrl = ""; private final CommonInfoService commonRepository; @@ -62,12 +64,12 @@ public class AliFileUploadController { // 关闭OSSClient。 ossClient.shutdown(); // String src = commonRepository.findOne(72).getValue()+"/"+completePath; - String src = commonRepository.findOne(19).getValue()+"/img/"+completePath; + String src = fileUrl + "/img/"+completePath; return Result.success().put("data",src); }else{ try { - String http = commonRepository.findOne(19).getValue(); + String http = fileUrl; String[] split = http.split("://"); // 上传文件路径 // String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; @@ -105,11 +107,11 @@ public class AliFileUploadController { ossClient.putObject(commonRepository.findOne(71).getValue(), completePath, inputStream); // 关闭OSSClient。 ossClient.shutdown(); - return commonRepository.findOne(19).getValue()+"/img/"+completePath; + return fileUrl+"/img/"+completePath; }else{ try { - String http = commonRepository.findOne(19).getValue(); + String http = fileUrl; String[] split = http.split("://"); // 上传文件路径 // String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; @@ -148,11 +150,11 @@ public class AliFileUploadController { ossClient.putObject(commonRepository.findOne(71).getValue(), completePath, inputStream); // 关闭OSSClient。 ossClient.shutdown(); - url = commonRepository.findOne(19).getValue()+"/img/"+completePath; + url = fileUrl+"/img/"+completePath; }else{ try { - String http = commonRepository.findOne(19).getValue(); + String http = fileUrl; String[] split = http.split("://"); // 上传文件路径 // String filePath ="/www/wwwroot/"+split[1]+"/file/uploadPath"; diff --git a/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java b/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java index 87842ef..72fa14d 100644 --- a/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java +++ b/src/main/java/com/sqx/modules/file/utils/FileUploadUtils.java @@ -5,6 +5,7 @@ import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.multipart.MultipartFile; import java.io.File; @@ -32,6 +33,9 @@ public class FileUploadUtils private static CommonInfoService commonRepository; + @Value("${file.upload.url}") + public static String fileUrl = ""; + @Autowired public void setCommonRepository(CommonInfoService commonRepository) { FileUploadUtils.commonRepository = commonRepository; @@ -39,7 +43,7 @@ public class FileUploadUtils public static String getDefaultBaseDir() { - return commonRepository.findOne(19).getValue(); + return fileUrl; } /** diff --git a/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java index 7085d5f..e11c630 100644 --- a/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java +++ b/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java @@ -61,6 +61,7 @@ import jodd.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestBody; @@ -85,6 +86,8 @@ public class WxServiceImpl implements WxService { private static final String TRADE_TYPE_JSAPI = "JSAPI"; private static final String Wap = "MWEB"; + @Value("${file.upload.url}") + public static String fileUrl = ""; @Autowired private CommonInfoService commonInfoService; @@ -1076,8 +1079,8 @@ public class WxServiceImpl implements WxService { @Override public boolean refund(String ordersNo) { WXConfigUtil config = null; - String h5Url = commonInfoService.findOne(19).getValue().split("://")[1]; - String filePath = "/www/wwwroot/" + h5Url + "/service/apiclient_cert.p12"; +// String h5Url = commonInfoService.findOne(19).getValue().split("://")[1]; + String filePath = fileUrl + "/service/apiclient_cert.p12"; try { config = new WXConfigUtil(filePath); } catch (Exception e) { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index c399c12..62d1c36 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -35,3 +35,4 @@ spring: file: upload: path: /mnt/file/ + url: 127.0.0.1:8080/file/ \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index f97f3b1..49659eb 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -34,4 +34,5 @@ spring: multi-statement-allow: true file: upload: - path: /mnt/file/ \ No newline at end of file + path: /mnt/file/ + url: 127.0.0.1:8080/file/ \ No newline at end of file diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 67ab515..6f65a88 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -35,3 +35,4 @@ spring: file: upload: path: /mnt/file/ + url: 127.0.0.1:8080/file/