Commit 2348d5ec by chentianzhong

提交代码

parent b8ac03c7
...@@ -39,6 +39,7 @@ import java.io.File; ...@@ -39,6 +39,7 @@ import java.io.File;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
/** /**
* <p> * <p>
...@@ -74,6 +75,7 @@ public class EmailAttachController { ...@@ -74,6 +75,7 @@ public class EmailAttachController {
String download = emailAttachService.getDownloadPath(emailAttach); String download = emailAttachService.getDownloadPath(emailAttach);
AssertUtils.hasText(download, "下载地址为空"); AssertUtils.hasText(download, "下载地址为空");
log.info("下载文件地址:" +download);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try { try {
HttpUtil.download(download, outputStream, true); HttpUtil.download(download, outputStream, true);
......
...@@ -21,7 +21,6 @@ public interface IEmailAttachService extends IService<EmailAttach> { ...@@ -21,7 +21,6 @@ public interface IEmailAttachService extends IService<EmailAttach> {
List<EmailAttach> saveAttach(EmailEditVo vo, EmailContent content); List<EmailAttach> saveAttach(EmailEditVo vo, EmailContent content);
List<EmailAttach> findByContentId(Long contentId); List<EmailAttach> findByContentId(Long contentId);
String getDownloadPath(Long id); String getDownloadPath(Long id);
......
...@@ -40,6 +40,7 @@ import java.util.List; ...@@ -40,6 +40,7 @@ import java.util.List;
public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, EmailAttach> implements IEmailAttachService { public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, EmailAttach> implements IEmailAttachService {
private final FileFeignClient fileFeignClient; private final FileFeignClient fileFeignClient;
@Value("${spring.cloud.config.profile}") @Value("${spring.cloud.config.profile}")
private String profile; private String profile;
...@@ -98,7 +99,16 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email ...@@ -98,7 +99,16 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
@Override @Override
public List<EmailAttach> findByContentId(Long contentId) { public List<EmailAttach> findByContentId(Long contentId) {
return this.lambdaQuery().eq(EmailAttach::getEmailContentId, contentId).orderByAsc(EmailAttach::getId).list(); List<EmailAttach> attaches = new ArrayList<>();
List<EmailAttach> list = this.lambdaQuery().eq(EmailAttach::getEmailContentId, contentId).orderByAsc(EmailAttach::getId).list();
for (EmailAttach attach : list) {
String download = attach.getDownloadPath();
if (StrUtil.isNotBlank(download) && profile.contains("wan")){
attach.setDownloadPath(download.replaceAll("147.2.3.3", "172.28.1.71"));
}
attaches.add(attach);
}
return attaches;
} }
@Override @Override
...@@ -118,8 +128,8 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email ...@@ -118,8 +128,8 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
download = "http://172.28.1.159:82/attwjsf_yj" + path; download = "http://172.28.1.159:82/attwjsf_yj" + path;
} }
}else{ }else{
if (profile.equals("wanpro") || profile.equals("wantest")) { if (profile.contains("wan")) {
download.replaceAll("147.2.3.3", "172.28.1.71"); download = download.replaceAll("147.2.3.3", "172.28.1.71");
} }
} }
return download; return download;
...@@ -140,7 +150,7 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email ...@@ -140,7 +150,7 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
} }
}else{ }else{
if (profile.equals("wanpro") || profile.equals("wantest")) { if (profile.equals("wanpro") || profile.equals("wantest")) {
download.replaceAll("147.2.3.3", "172.28.1.71"); download = download.replaceAll("147.2.3.3", "172.28.1.71");
} }
} }
return download; return download;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment