fix: 修复邮件变量没有替换的问题
This commit is contained in:
parent
117786310e
commit
5212d4b723
|
@ -15,7 +15,8 @@ import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.flywaydb.core.internal.util.StringUtils;
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.mail.MailException;
|
import org.springframework.mail.MailException;
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
@ -96,11 +97,10 @@ public class MailService {
|
||||||
|
|
||||||
private String getContent(String template, Map<String, String> context) {
|
private String getContent(String template, Map<String, String> context) {
|
||||||
if (MapUtils.isNotEmpty(context)) {
|
if (MapUtils.isNotEmpty(context)) {
|
||||||
context.forEach((k, v) -> {
|
for (String k : context.keySet()) {
|
||||||
if (v != null && !v.isEmpty()) {
|
if (StringUtils.isNotBlank(context.get(k)))
|
||||||
StringUtils.replaceAll(template, "${" + k + "}", v);
|
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", context.get(k));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue