Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
ShopERP
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
杜龙飞
ShopERP
Commits
51afee1b
Commit
51afee1b
authored
Jul 16, 2025
by
PC-20220610JUCQ\Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
<develop>:(ShopERP 端)<无> 增加 发送邮件的测试功能。
parent
e8760627
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
186 additions
and
7 deletions
+186
-7
CoreCms.Net.Model/FromBody/FMWxPost.cs
+19
-0
CoreCms.Net.Web.WebApi/Controllers/DemoController.cs
+7
-1
CoreCms.Net.Web.WebApi/Controllers/TestController.cs
+85
-0
CoreCms.Net.Web.WebApi/Doc.xml
+18
-0
CoreCms.Net.Web.WebApi/Infrastructure/ConfigureHTTPipeline.cs
+1
-0
CoreCms.Net.Web.WebApi/Infrastructure/ServicesContainerExtend.cs
+18
-0
CoreCms.Net.Web.WebApi/appsettings.json
+10
-3
CoreCms.Net.Web.WebApi/bin/Debug/net8.0/Doc.xml
+18
-0
CoreCms.Net.Web.WebApi/bin/Debug/net8.0/appsettings.json
+10
-3
No files found.
CoreCms.Net.Model/FromBody/FMWxPost.cs
View file @
51afee1b
...
...
@@ -124,6 +124,25 @@ namespace CoreCms.Net.Model.FromBody
public
string
method
{
get
;
set
;
}
}
public
class
FMSendEmail
{
/// <summary>
/// 操作类型
/// </summary>
public
string
code
{
get
;
set
;
}
/// <summary>
/// 邮箱
/// </summary>
public
string
email
{
get
;
set
;
}
/// <summary>
/// 发送内容
/// </summary>
public
string
content
{
get
;
set
;
}
}
/// <summary>
/// 用户发起订阅提交
/// </summary>
...
...
CoreCms.Net.Web.WebApi/Controllers/DemoController.cs
View file @
51afee1b
using
CoreCms.Net.Model.ViewModels.Email
;
using
CoreCms.Net.Utility.Helper
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
namespace
CoreCms.Net.Web.WebApi.Controllers
{
...
...
@@ -9,12 +13,13 @@ namespace CoreCms.Net.Web.WebApi.Controllers
public
class
DemoController
:
ControllerBase
{
/// <summary>
///
默认首页
///默认首页
/// </summary>
/// <returns></returns>
public
IActionResult
Index
()
{
return
Content
(
"已结束"
);
}
}
}
\ No newline at end of file
CoreCms.Net.Web.WebApi/Controllers/TestController.cs
0 → 100644
View file @
51afee1b
using
CoreCms.Net.Model.FromBody
;
using
CoreCms.Net.Model.ViewModels.Email
;
using
CoreCms.Net.Model.ViewModels.UI
;
using
CoreCms.Net.Utility.Helper
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
namespace
CoreCms.Net.Web.WebApi.Controllers
{
/// <summary>
/// 用户测试事件
/// </summary>
[
Route
(
"api/[controller]/[action]"
)]
[
ApiController
]
public
class
TestController
:
ControllerBase
{
private
readonly
EmailSenderHelper
_emailSender
;
//发邮件的服务
/// <summary>
/// 构造函数注入
/// </summary>
/// <param name="emailSender"></param>
public
TestController
(
EmailSenderHelper
emailSender
)
{
_emailSender
=
emailSender
;
}
#
region
用户邮箱发送
===================================================================
/// <summary>
/// 用户邮箱发送
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[
HttpPost
]
public
async
Task
<
WebApiCallBack
>
SendEmail
([
FromBody
]
FMSendEmail
entity
)
{
var
jm
=
new
WebApiCallBack
();
if
(
string
.
IsNullOrEmpty
(
entity
.
email
))
{
jm
.
msg
=
"请输入合法的邮箱地址"
;
return
jm
;
}
//发送验证码, 发送邮件
Random
rd
=
new
Random
();
int
codeNumber
=
rd
.
Next
(
100000
,
999999
);
var
message
=
new
MailMessageModel
()
{
ToAddresses
=
new
List
<
string
>
{
entity
.
email
},
Subject
=
"邮箱验证码"
,
Body
=
$"""
<!
DOCTYPE
html
>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>
邮箱验证
</
title
>
</
head
>
<
body
>
<
div
style
=
"max-width: 600px; margin: 0 auto; font-family: Arial, sans-serif;"
>
<
h2
style
=
"color: #1e9fff;"
>
邮箱验证请求
</
h2
>
<
p
>
您的验证码是:
<
strong
style
=
"font-size: 24px; letter-spacing: 2px;"
>
{
codeNumber
}
</
strong
></
p
>
<
p
>
验证码将在
30
分钟后失效,请尽快使用。
</
p
>
<
hr
style
=
"border: 0; border-top: 1px solid #eee;"
>
<
p
style
=
"color: #999; font-size: 12px;"
>
此为系统邮件,请勿直接回复
</
p
>
</
div
>
</
body
>
</
html
>
""",
IsBodyHtml
=
true
};
await
_emailSender
.
SendEmailAsync
(
message
);
return
jm
;
}
#
endregion
}
}
CoreCms.Net.Web.WebApi/Doc.xml
View file @
51afee1b
...
...
@@ -723,6 +723,24 @@
</summary>
<returns></returns>
</member>
<member
name=
"T:CoreCms.Net.Web.WebApi.Controllers.TestController"
>
<summary>
用户测试事件
</summary>
</member>
<member
name=
"M:CoreCms.Net.Web.WebApi.Controllers.TestController.#ctor(CoreCms.Net.Utility.Helper.EmailSenderHelper)"
>
<summary>
构造函数注入
</summary>
<param
name=
"emailSender"
></param>
</member>
<member
name=
"M:CoreCms.Net.Web.WebApi.Controllers.TestController.SendEmail(CoreCms.Net.Model.FromBody.FMSendEmail)"
>
<summary>
用户邮箱发送
</summary>
<param
name=
"entity"
></param>
<returns></returns>
</member>
<member
name=
"T:CoreCms.Net.Web.WebApi.Controllers.UserController"
>
<summary>
用户操作事件
...
...
CoreCms.Net.Web.WebApi/Infrastructure/ConfigureHTTPipeline.cs
View file @
51afee1b
...
...
@@ -35,6 +35,7 @@ namespace CoreCms.Net.Web.WebApi.Infrastructure
app
.
UseRecordAccessLogsMildd
();
// 记录ip请求 (注意开启权限,不然本地无法写入)
app
.
UseIpLogMildd
();
// Swagger授权登录拦截
app
.
UseSwaggerAuthorizedMildd
();
//强制显示中文
...
...
CoreCms.Net.Web.WebApi/Infrastructure/ServicesContainerExtend.cs
View file @
51afee1b
...
...
@@ -3,10 +3,13 @@ using CoreCms.Net.Configuration;
using
CoreCms.Net.Core.Config
;
using
CoreCms.Net.Loging
;
using
CoreCms.Net.Mapping
;
using
CoreCms.Net.Model.ViewModels.Email
;
using
CoreCms.Net.Utility.Helper
;
using
Essensoft.Paylink.Alipay
;
using
Essensoft.Paylink.WeChatPay
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Mvc.Controllers
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection.Extensions
;
using
Newtonsoft.Json
;
...
...
@@ -35,6 +38,21 @@ namespace CoreCms.Net.Web.WebApi.Infrastructure
//Redis缓存
builder
.
Services
.
AddRedisCacheSetup
();
// 从配置中读取邮件设置
var
mailConfig
=
new
MailConfiguration
{
SmtpServer
=
builder
.
Configuration
[
"Smtp:Server"
],
SmtpPort
=
builder
.
Configuration
.
GetValue
<
int
>(
"Smtp:Port"
),
UserName
=
builder
.
Configuration
[
"Smtp:Username"
],
Password
=
builder
.
Configuration
[
"Smtp:Password"
],
FromAddress
=
builder
.
Configuration
[
"Smtp:FromAddress"
],
DisplayName
=
builder
.
Configuration
[
"Smtp:DisplayName"
]
??
"My Application"
};
// 注册邮件服务
builder
.
Services
.
AddSingleton
(
mailConfig
);
builder
.
Services
.
AddScoped
<
EmailSenderHelper
>();
//添加数据库连接SqlSugar注入支持
builder
.
Services
.
AddSqlSugarSetup
();
//配置跨域(CORS)
...
...
CoreCms.Net.Web.WebApi/appsettings.json
View file @
51afee1b
...
...
@@ -15,9 +15,16 @@
},
//Swagger授权访问设置
"SwaggerConfig"
:
{
"RoutePrefix"
:
"doc"
,
//路由地址,默认doc
"UserName"
:
""
,
"PassWord"
:
""
"RoutePrefix"
:
"Doc"
,
//路由地址,默认doc
"UserName"
:
"admin"
,
"PassWord"
:
"123456"
},
"Smtp"
:
{
"Server"
:
"smtp.qiye.aliyun.com"
,
"Port"
:
465
,
"Username"
:
"erpservice@geekbuy.com"
,
"Password"
:
"co69W7xEZ6qjBo01"
,
"FromAddress"
:
"erpservice@geekbuy.com"
},
"AppConfig"
:
{
"AppUrl"
:
"https://admin.demo.coreshop.cn/"
,
//后端管理地址
...
...
CoreCms.Net.Web.WebApi/bin/Debug/net8.0/Doc.xml
View file @
51afee1b
...
...
@@ -723,6 +723,24 @@
</summary>
<returns></returns>
</member>
<member
name=
"T:CoreCms.Net.Web.WebApi.Controllers.TestController"
>
<summary>
用户测试事件
</summary>
</member>
<member
name=
"M:CoreCms.Net.Web.WebApi.Controllers.TestController.#ctor(CoreCms.Net.Utility.Helper.EmailSenderHelper)"
>
<summary>
构造函数注入
</summary>
<param
name=
"emailSender"
></param>
</member>
<member
name=
"M:CoreCms.Net.Web.WebApi.Controllers.TestController.SendEmail(CoreCms.Net.Model.FromBody.FMSendEmail)"
>
<summary>
用户邮箱发送
</summary>
<param
name=
"entity"
></param>
<returns></returns>
</member>
<member
name=
"T:CoreCms.Net.Web.WebApi.Controllers.UserController"
>
<summary>
用户操作事件
...
...
CoreCms.Net.Web.WebApi/bin/Debug/net8.0/appsettings.json
View file @
51afee1b
...
...
@@ -15,9 +15,16 @@
},
//Swagger授权访问设置
"SwaggerConfig"
:
{
"RoutePrefix"
:
"doc"
,
//路由地址,默认doc
"UserName"
:
""
,
"PassWord"
:
""
"RoutePrefix"
:
"Doc"
,
//路由地址,默认doc
"UserName"
:
"admin"
,
"PassWord"
:
"123456"
},
"Smtp"
:
{
"Server"
:
"smtp.qiye.aliyun.com"
,
"Port"
:
465
,
"Username"
:
"erpservice@geekbuy.com"
,
"Password"
:
"co69W7xEZ6qjBo01"
,
"FromAddress"
:
"erpservice@geekbuy.com"
},
"AppConfig"
:
{
"AppUrl"
:
"https://admin.demo.coreshop.cn/"
,
//后端管理地址
...
...
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