Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-serivce
/
glsk-analysis-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3172c351
authored
May 30, 2025
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交邮件模板
1 parent
e3a47419
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
46 deletions
src/dto/email.dto.ts
src/email/email.controller.ts
src/email/email.service.ts
src/email/templates/function.point.ejs
src/dto/email.dto.ts
View file @
3172c35
...
...
@@ -15,4 +15,25 @@ export class EmailQueryDto {
required
:
true
})
subject
?:
string
;
@
ApiProperty
({
type
:
String
,
description
:
'内容'
,
required
:
true
})
mentorship_page
?:
string
;
supervisor_daily_page
?:
string
;
extraction
?:
string
;
sales_content
?:
string
;
training_materials
?:
string
;
scene_market
?:
string
;
}
class
MentorshipPage
{
count
:
number
;
peakDay
:
Array
<
PeakDay
>
;
uniqueAccounts
:
number
;
queryTime
:
Object
;
}
class
PeakDay
{
count
:
number
;
date
:
string
;
}
\ No newline at end of file
src/email/email.controller.ts
View file @
3172c35
import
{
Controller
,
Get
,
Query
,
Render
}
from
'@nestjs/common'
;
import
{
Body
,
Controller
,
Get
,
Post
,
Query
,
Render
,
Logger
,
UsePipes
}
from
'@nestjs/common'
;
import
{
EmailService
}
from
'./email.service'
;
import
{
EmailQueryDto
}
from
'src/dto/email.dto'
;
import
{
PagesPipe
,
ValidationPipe
}
from
'../common/pipes'
import
{
ApiOperation
}
from
'@nestjs/swagger'
;
@
Controller
(
'email'
)
@
UsePipes
(
new
ValidationPipe
())
// 使用管道验证
export
class
EmailController
{
constructor
(
private
readonly
emailService
:
EmailService
)
{}
@
Get
(
'send'
)
async
sendEmail
(@
Query
()
query
:
EmailQueryDto
)
{
const
{
to
,
subject
}
=
query
@
Post
(
'send'
)
@
UsePipes
(
new
PagesPipe
())
@
ApiOperation
({
summary
:
'发送邮件'
})
async
sendEmail
(@
Body
()
query
:
EmailQueryDto
)
{
// const {to, subject} = query
Logger
.
log
(
query
,
'=========='
)
try
{
await
this
.
emailService
.
sendMail
(
to
,
subject
);
await
this
.
emailService
.
sendMail
(
query
);
return
'Email sent successfully!'
;
}
catch
(
error
)
{
return
'Email sending failed: '
+
error
;
...
...
src/email/email.service.ts
View file @
3172c35
// mail/mail.service.ts
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
,
Logger
}
from
'@nestjs/common'
;
import
{
MailerService
}
from
'@nestjs-modules/mailer'
;
import
*
as
nodemailer
from
'nodemailer'
;
import
{
EmailQueryDto
}
from
'src/dto/email.dto'
;
@
Injectable
()
export
class
EmailService
{
// private transporter;
...
...
@@ -17,7 +18,9 @@ export class EmailService {
// },
// });
// }
async
sendMail
(
to
:
string
,
subject
:
string
):
Promise
<
void
>
{
async
sendMail
(
query
:
EmailQueryDto
):
Promise
<
void
>
{
const
{
to
,
subject
,
mentorship_page
,
supervisor_daily_page
,
extraction
,
sales_content
,
training_materials
,
scene_market
}
=
query
Logger
.
log
(
supervisor_daily_page
,
'supervisor_daily_page'
)
// 模拟数据
const
weeklyData
=
[
{
...
...
@@ -82,7 +85,13 @@ export class EmailService {
sign
:
'系统邮件,回复无效。'
,
//发送的签名,当然也可以不要
weeklyData
,
reportData
,
assessmentList
assessmentList
,
mentorship_page
:
JSON
.
parse
(
mentorship_page
),
supervisor_daily_page
:
JSON
.
parse
(
supervisor_daily_page
),
extraction
:
JSON
.
parse
(
extraction
),
sales_content
:
JSON
.
parse
(
sales_content
),
training_materials
:
JSON
.
parse
(
training_materials
),
scene_market
:
JSON
.
parse
(
scene_market
)
}
};
...
...
src/email/templates/function.point.ejs
View file @
3172c35
...
...
@@ -52,34 +52,26 @@
<th>
总数(人)
</th>
<th>
有效点击人员数(人)
</th>
<th>
点击量(次)
</th>
<th>
进行中的带教条数(条)
</th>
<th>
创建任务(条)
</th>
<th>
最高点击日 / 次数(原因)
</th>
</tr>
</thead>
<tbody>
<
% locals.
weeklyData
.forEach(row=> { %>
<
% locals.
mentorship_page
.forEach(row=> { %>
<tr
class=
"highlight"
>
<td>
<
%= row.date %>
</td>
<td>
<
%= row.
totalPeople
%>
<
%= row.
count
%>
</td>
<td>
<
%= row.
validClick
s %>
<
%= row.
uniqueAccount
s %>
</td>
<td>
<
%= row.c
lickC
ount %>
<
%= row.count %>
</td>
<td>
<
%= row.activeItems %>
</td>
<td>
<
%= row.createdTasks %>
</td>
<td>
<
%= row.peakDay %>
<
%= row.peakDay.date + ' / ' + row.peakDay.count %>
</td>
</tr>
<
% }); %>
...
...
@@ -99,25 +91,25 @@
</tr>
</thead>
<tbody>
<
% locals.
weeklyData
.forEach(row=> { %>
<
% locals.
supervisor_daily_page
.forEach(row=> { %>
<tr
class=
"highlight"
>
<td>
<
%= row.date %>
</td>
<td>
<
%= row.
totalPeople
%>
<
%= row.
count
%>
</td>
<td>
<
%= row.
validClick
s %>
<
%= row.
uniqueAccount
s %>
</td>
<td>
<
%= row.c
lickC
ount %>
<
%= row.count %>
</td>
<td>
<
%= row.
activeItems
%>
<
%= row.
equityCount
%>
</td>
<td>
<
%= row.
createdTasks
%>
<
%= row.
upgradeCount
%>
</td>
</tr>
<
% }); %>
...
...
@@ -197,20 +189,20 @@
<th>
总浏览批次(次)③
</th>
</tr>
</thead>
<tbody>
<
% locals.
assessmentList
.forEach(row=> { %>
<tr
class=
"highlight"
>
<tbody>
<
% locals.
extraction
.forEach(row=> { %>
<tr>
<td>
<
%= row.
dat
e %>
<
%= row.
titl
e %>
</td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
<td>
<
%= row.
fil
l %>
<
%= row.
peopleTota
l %>
</td>
<td>
<
%= row.
submitRate %>%
<
%= row.
batchTotal %>
</td>
</tr>
<
% }); %>
...
...
@@ -233,19 +225,21 @@
</tr>
</thead>
<tbody>
<
% locals.
assessmentLis
t.forEach(row=> { %>
<
% locals.
sales_conten
t.forEach(row=> { %>
<tr
class=
"highlight"
>
<td>
<
%= row.date %>
</td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
<td>
<
%= row.
fill
%>
<
%= row.
uniqueAccounts
%>
</td>
<td>
<
%= row.submitRate ? row.submitRate : '——' %>%
<
% row.remark.forEach(i=> { %>
<div>
<
%= i.name + ': ' + i.count %>
</div>
<
% }); %>
</td>
</tr>
<
% }); %>
...
...
@@ -263,19 +257,21 @@
</tr>
</thead>
<tbody>
<
% locals.
assessmentLis
t.forEach(row=> { %>
<
% locals.
scene_marke
t.forEach(row=> { %>
<tr
class=
"highlight"
>
<td>
<
%= row.date %>
</td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
<td>
<
%= row.
fill
%>
<
%= row.
uniqueAccounts
%>
</td>
<td>
<
%= row.submitRate ? row.submitRate : '——' %>%
<
% row.remark.forEach(i=> { %>
<div>
<
%= i.name + ': ' + i.count %>
</div>
<
% }); %>
</td>
</tr>
<
% }); %>
...
...
@@ -293,19 +289,21 @@
</tr>
</thead>
<tbody>
<
% locals.
assessmentList
.forEach(row=> { %>
<
% locals.
training_materials
.forEach(row=> { %>
<tr
class=
"highlight"
>
<td>
<
%= row.date %>
</td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
<td>
<
%= row.
fill
%>
<
%= row.
uniqueAccounts
%>
</td>
<td>
<
%= row.submitRate ? row.submitRate : '——' %>%
<
% row.remark.forEach(i=> { %>
<div>
<
%= i.name + ': ' + i.count %>
</div>
<
% }); %>
</td>
</tr>
<
% }); %>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment