From 09d39bd7f1bfc72b78e0060c197562610a0ca9f8 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期五, 05 九月 2025 14:37:36 +0800
Subject: [PATCH] feat:开发

---
 FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs b/FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs
index e629770..fe1f343 100644
--- a/FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs
+++ b/FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs
@@ -7,6 +7,7 @@
 using MediatR;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Options;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -22,14 +23,28 @@
     public class SmsUtils
     {
         private readonly IRepository<SmsLog, LogDbContextLocator> rep;
+        private readonly IOptions<AliyunOptions> options;
         private readonly AliyunSmsUtils aliyunSmsUtils;
 
         public SmsUtils(
             IRepository<SmsLog, LogDbContextLocator> rep,
+            IOptions<AliyunOptions> options,
             AliyunSmsUtils aliyunSmsUtils)
         {
             this.rep = rep;
+            this.options = options;
             this.aliyunSmsUtils = aliyunSmsUtils;
+        }
+
+        public async Task<Guid> Send(SendSmsModel model, object templateParam, CancellationToken cancellationToken = default)
+        {
+            var entity = new SmsLog();
+            model.Adapt(entity);
+            entity.Expiry = DateTime.Now.AddMinutes(10);
+            entity.TemplateParam = templateParam.ToJson();
+            await aliyunSmsUtils.SendAsync(model.PhoneNumber, model.TemplateCode, entity.TemplateParam, cancellationToken);
+            await rep.InsertAsync(entity);
+            return entity.Id;
         }
 
         public async Task<Guid> SendVerifyCode(SendVerifyCodeModel model, CancellationToken cancellationToken = default)
@@ -41,7 +56,7 @@
             entity.TemplateParam = new { code }.ToJson();
             await aliyunSmsUtils.SendAsync(model.PhoneNumber, model.TemplateCode, entity.TemplateParam, cancellationToken);
             await rep.InsertAsync(entity);
-            if (App.HostEnvironment.IsDevelopment())
+            if (options.Value.SMS.WithoutVerifyCode)
             {
                 UnifyContext.Fill(new
                 {

--
Gitblit v1.9.1