From 465f14d18c1ee52efffd7095bf7535a6bbb2e06f Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期二, 02 九月 2025 14:56:11 +0800
Subject: [PATCH] feat:开发

---
 FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs         |    6 +++++-
 FlexJobApi.Core/Utils/AliyunUtils/AliyunOptions.cs |    2 ++
 FlexJobApi.Web.Entry/appsettings.json              |    1 +
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/FlexJobApi.Core/Utils/AliyunUtils/AliyunOptions.cs b/FlexJobApi.Core/Utils/AliyunUtils/AliyunOptions.cs
index 8b1d057..3353f69 100644
--- a/FlexJobApi.Core/Utils/AliyunUtils/AliyunOptions.cs
+++ b/FlexJobApi.Core/Utils/AliyunUtils/AliyunOptions.cs
@@ -47,6 +47,8 @@
         /// </summary>
         public bool Enable { get; set; }
 
+        public bool WithoutVerifyCode { get; set; }
+
         /// <summary>
         /// 鐗堟湰
         /// </summary>
diff --git a/FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs b/FlexJobApi.Core/Utils/SmsUtils/SmsUtils.cs
index e629770..a54090b 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,13 +23,16 @@
     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;
         }
 
@@ -41,7 +45,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
                 {
diff --git a/FlexJobApi.Web.Entry/appsettings.json b/FlexJobApi.Web.Entry/appsettings.json
index 6383c3b..6623cbc 100644
--- a/FlexJobApi.Web.Entry/appsettings.json
+++ b/FlexJobApi.Web.Entry/appsettings.json
@@ -76,6 +76,7 @@
     },
     "SMS": {
       "Enable": true,
+      "WithoutVerifyCode": true,
       "AccessKeyId": "LTAI5tLzz2jnXrUAAiC2kduH",
       "AccessSecret": "do1XqrgHJ5gOuFHhO5eku0FyYzZvbQ",
       "Version": "2017-05-25",

--
Gitblit v1.9.1