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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
45 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 {
...
@@ -15,4 +15,25 @@ export class EmailQueryDto {
required
:
true
required
:
true
})
})
subject
?:
string
;
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
\ 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
{
EmailService
}
from
'./email.service'
;
import
{
EmailQueryDto
}
from
'src/dto/email.dto'
;
import
{
EmailQueryDto
}
from
'src/dto/email.dto'
;
import
{
PagesPipe
,
ValidationPipe
}
from
'../common/pipes'
import
{
ApiOperation
}
from
'@nestjs/swagger'
;
@
Controller
(
'email'
)
@
Controller
(
'email'
)
@
UsePipes
(
new
ValidationPipe
())
// 使用管道验证
export
class
EmailController
{
export
class
EmailController
{
constructor
(
private
readonly
emailService
:
EmailService
)
{}
constructor
(
private
readonly
emailService
:
EmailService
)
{}
@
Get
(
'send'
)
@
Post
(
'send'
)
async
sendEmail
(@
Query
()
query
:
EmailQueryDto
)
{
@
UsePipes
(
new
PagesPipe
())
const
{
to
,
subject
}
=
query
@
ApiOperation
({
summary
:
'发送邮件'
})
async
sendEmail
(@
Body
()
query
:
EmailQueryDto
)
{
// const {to, subject} = query
Logger
.
log
(
query
,
'=========='
)
try
{
try
{
await
this
.
emailService
.
sendMail
(
to
,
subject
);
await
this
.
emailService
.
sendMail
(
query
);
return
'Email sent successfully!'
;
return
'Email sent successfully!'
;
}
catch
(
error
)
{
}
catch
(
error
)
{
return
'Email sending failed: '
+
error
;
return
'Email sending failed: '
+
error
;
...
...
src/email/email.service.ts
View file @
3172c35
// mail/mail.service.ts
// mail/mail.service.ts
import
{
Injectable
}
from
'@nestjs/common'
;
import
{
Injectable
,
Logger
}
from
'@nestjs/common'
;
import
{
MailerService
}
from
'@nestjs-modules/mailer'
;
import
{
MailerService
}
from
'@nestjs-modules/mailer'
;
import
*
as
nodemailer
from
'nodemailer'
;
import
*
as
nodemailer
from
'nodemailer'
;
import
{
EmailQueryDto
}
from
'src/dto/email.dto'
;
@
Injectable
()
@
Injectable
()
export
class
EmailService
{
export
class
EmailService
{
// private transporter;
// private transporter;
...
@@ -17,7 +18,9 @@ export class EmailService {
...
@@ -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
=
[
const
weeklyData
=
[
{
{
...
@@ -82,7 +85,13 @@ export class EmailService {
...
@@ -82,7 +85,13 @@ export class EmailService {
sign
:
'系统邮件,回复无效。'
,
//发送的签名,当然也可以不要
sign
:
'系统邮件,回复无效。'
,
//发送的签名,当然也可以不要
weeklyData
,
weeklyData
,
reportData
,
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 @@
...
@@ -52,34 +52,26 @@
<th>
总数(人)
</th>
<th>
总数(人)
</th>
<th>
有效点击人员数(人)
</th>
<th>
有效点击人员数(人)
</th>
<th>
点击量(次)
</th>
<th>
点击量(次)
</th>
<th>
进行中的带教条数(条)
</th>
<th>
创建任务(条)
</th>
<th>
最高点击日 / 次数(原因)
</th>
<th>
最高点击日 / 次数(原因)
</th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
% locals.
weeklyData
.forEach(row=> { %>
<
% locals.
mentorship_page
.forEach(row=> { %>
<tr
class=
"highlight"
>
<tr
class=
"highlight"
>
<td>
<td>
<
%= row.date %>
<
%= row.date %>
</td>
</td>
<td>
<td>
<
%= row.
totalPeople
%>
<
%= row.
count
%>
</td>
</td>
<td>
<td>
<
%= row.
validClick
s %>
<
%= row.
uniqueAccount
s %>
</td>
</td>
<td>
<td>
<
%= row.c
lickC
ount %>
<
%= row.count %>
</td>
</td>
<td>
<td>
<
%= row.activeItems %>
<
%= row.peakDay.date + ' / ' + row.peakDay.count %>
</td>
<td>
<
%= row.createdTasks %>
</td>
<td>
<
%= row.peakDay %>
</td>
</td>
</tr>
</tr>
<
% }); %>
<
% }); %>
...
@@ -99,25 +91,25 @@
...
@@ -99,25 +91,25 @@
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
% locals.
weeklyData
.forEach(row=> { %>
<
% locals.
supervisor_daily_page
.forEach(row=> { %>
<tr
class=
"highlight"
>
<tr
class=
"highlight"
>
<td>
<td>
<
%= row.date %>
<
%= row.date %>
</td>
</td>
<td>
<td>
<
%= row.
totalPeople
%>
<
%= row.
count
%>
</td>
</td>
<td>
<td>
<
%= row.
validClick
s %>
<
%= row.
uniqueAccount
s %>
</td>
</td>
<td>
<td>
<
%= row.c
lickC
ount %>
<
%= row.count %>
</td>
</td>
<td>
<td>
<
%= row.
activeItems
%>
<
%= row.
equityCount
%>
</td>
</td>
<td>
<td>
<
%= row.
createdTasks
%>
<
%= row.
upgradeCount
%>
</td>
</td>
</tr>
</tr>
<
% }); %>
<
% }); %>
...
@@ -198,19 +190,19 @@
...
@@ -198,19 +190,19 @@
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
% locals.
assessmentList
.forEach(row=> { %>
<
% locals.
extraction
.forEach(row=> { %>
<tr
class=
"highlight"
>
<tr>
<td>
<td>
<
%= row.
dat
e %>
<
%= row.
titl
e %>
</td>
</td>
<td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
</td>
<td>
<td>
<
%= row.
fil
l %>
<
%= row.
peopleTota
l %>
</td>
</td>
<td>
<td>
<
%= row.
submitRate %>%
<
%= row.
batchTotal %>
</td>
</td>
</tr>
</tr>
<
% }); %>
<
% }); %>
...
@@ -233,19 +225,21 @@
...
@@ -233,19 +225,21 @@
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
% locals.
assessmentLis
t.forEach(row=> { %>
<
% locals.
sales_conten
t.forEach(row=> { %>
<tr
class=
"highlight"
>
<tr
class=
"highlight"
>
<td>
<td>
<
%= row.date %>
<
%= row.date %>
</td>
</td>
<td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
</td>
<td>
<td>
<
%= row.
fill
%>
<
%= row.
uniqueAccounts
%>
</td>
</td>
<td>
<td>
<
%= row.submitRate ? row.submitRate : '——' %>%
<
% row.remark.forEach(i=> { %>
<div>
<
%= i.name + ': ' + i.count %>
</div>
<
% }); %>
</td>
</td>
</tr>
</tr>
<
% }); %>
<
% }); %>
...
@@ -263,19 +257,21 @@
...
@@ -263,19 +257,21 @@
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
% locals.
assessmentLis
t.forEach(row=> { %>
<
% locals.
scene_marke
t.forEach(row=> { %>
<tr
class=
"highlight"
>
<tr
class=
"highlight"
>
<td>
<td>
<
%= row.date %>
<
%= row.date %>
</td>
</td>
<td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
</td>
<td>
<td>
<
%= row.
fill
%>
<
%= row.
uniqueAccounts
%>
</td>
</td>
<td>
<td>
<
%= row.submitRate ? row.submitRate : '——' %>%
<
% row.remark.forEach(i=> { %>
<div>
<
%= i.name + ': ' + i.count %>
</div>
<
% }); %>
</td>
</td>
</tr>
</tr>
<
% }); %>
<
% }); %>
...
@@ -293,19 +289,21 @@
...
@@ -293,19 +289,21 @@
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
% locals.
assessmentList
.forEach(row=> { %>
<
% locals.
training_materials
.forEach(row=> { %>
<tr
class=
"highlight"
>
<tr
class=
"highlight"
>
<td>
<td>
<
%= row.date %>
<
%= row.date %>
</td>
</td>
<td>
<td>
<
%= row.
submi
t %>
<
%= row.
coun
t %>
</td>
</td>
<td>
<td>
<
%= row.
fill
%>
<
%= row.
uniqueAccounts
%>
</td>
</td>
<td>
<td>
<
%= row.submitRate ? row.submitRate : '——' %>%
<
% row.remark.forEach(i=> { %>
<div>
<
%= i.name + ': ' + i.count %>
</div>
<
% }); %>
</td>
</td>
</tr>
</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