Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-email
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-email
Commits
00fb1021
Commit
00fb1021
authored
Sep 29, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
58ee9833
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
yd-email-api/src/main/java/com/yd/email/api/service/impl/ApiEmailContactServiceImpl.java
+18
-4
No files found.
yd-email-api/src/main/java/com/yd/email/api/service/impl/ApiEmailContactServiceImpl.java
View file @
00fb1021
...
...
@@ -23,6 +23,7 @@ import com.yd.email.service.dto.EmailContactDto;
import
com.yd.email.service.model.EmailContact
;
import
com.yd.email.service.service.IEmailContactService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -30,6 +31,7 @@ import org.springframework.util.CollectionUtils;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -188,14 +190,26 @@ public class ApiEmailContactServiceImpl implements ApiEmailContactService {
*/
@Override
public
String
replacePlaceholders
(
String
content
,
String
contactBizId
)
{
if
(
StringUtils
.
isBlank
(
content
))
return
""
;
String
result
=
content
;
//查询收件人信息
EmailContact
emailContact
=
iEmailContactService
.
queryOne
(
contactBizId
);
if
(!
Objects
.
isNull
(
emailContact
))
{
result
=
result
.
replace
(
"{{name}}"
,
emailContact
.
getName
());
result
=
result
.
replace
(
"{{appellation}}"
,
emailContact
.
getAppellation
());
result
=
result
.
replace
(
"{{compantName}}"
,
emailContact
.
getCompanyName
());
// 使用 Optional 或三目运算符处理 null
String
name
=
Optional
.
ofNullable
(
emailContact
.
getName
())
.
filter
(
s
->
!
s
.
trim
().
isEmpty
())
.
orElse
(
""
);
String
appellation
=
Optional
.
ofNullable
(
emailContact
.
getAppellation
())
.
orElse
(
""
);
String
companyName
=
Optional
.
ofNullable
(
emailContact
.
getCompanyName
())
.
orElse
(
""
);
result
=
result
.
replace
(
"{{name}}"
,
name
)
.
replace
(
"{{appellation}}"
,
appellation
)
.
replace
(
"{{compantName}}"
,
companyName
);
}
return
result
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment