Commit 3172c351 by 胡悦

提交邮件模板

1 parent e3a47419
......@@ -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
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;
......
// 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)
}
};
......
......@@ -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.validClicks %>
<%= row.uniqueAccounts %>
</td>
<td>
<%= row.clickCount %>
<%= 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.validClicks %>
<%= row.uniqueAccounts %>
</td>
<td>
<%= row.clickCount %>
<%= 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.date %>
<%= row.title %>
</td>
<td>
<%= row.submit %>
<%= row.count %>
</td>
<td>
<%= row.fill %>
<%= row.peopleTotal %>
</td>
<td>
<%= row.submitRate %>%
<%= row.batchTotal %>
</td>
</tr>
<% }); %>
......@@ -233,19 +225,21 @@
</tr>
</thead>
<tbody>
<% locals.assessmentList.forEach(row=> { %>
<% locals.sales_content.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.date %>
</td>
<td>
<%= row.submit %>
<%= row.count %>
</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.assessmentList.forEach(row=> { %>
<% locals.scene_market.forEach(row=> { %>
<tr class="highlight">
<td>
<%= row.date %>
</td>
<td>
<%= row.submit %>
<%= row.count %>
</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.submit %>
<%= row.count %>
</td>
<td>
<%= row.fill %>
<%= row.uniqueAccounts %>
</td>
<td>
<%= row.submitRate ? row.submitRate : '——' %>%
<% row.remark.forEach(i=> { %>
<div><%= i.name + ': ' + i.count %></div>
<% }); %>
</td>
</tr>
<% }); %>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!