From 446f705eb3cc581e07eca41d159cef9639a2ff7f Mon Sep 17 00:00:00 2001 From: zty Date: Wed, 21 May 2025 09:51:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20auth1=20utils=20enm=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=98=BF=E9=87=8C=E4=BA=91=E5=8F=91=E9=80=81=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1=E5=BC=95=E5=85=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/auth1/views.py | 3 ++- apps/utils/sms.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/auth1/views.py b/apps/auth1/views.py index ecdfecd8..fd40936d 100755 --- a/apps/auth1/views.py +++ b/apps/auth1/views.py @@ -10,7 +10,7 @@ from apps.auth1.errors import USERNAME_OR_PASSWORD_WRONG from rest_framework_simplejwt.tokens import RefreshToken from django.core.cache import cache from apps.auth1.services import check_phone_code -from apps.utils.sms import send_sms + from apps.utils.tools import rannum from apps.utils.wxmp import wxmpClient from apps.utils.wx import wxClient @@ -182,6 +182,7 @@ class SendCode(CreateAPIView): 短信验证码发送 """ + from apps.utils.sms import send_sms phone = request.data['phone'] code = rannum(6) is_ok, _ = send_sms(phone, 505, {'code': code}) diff --git a/apps/utils/sms.py b/apps/utils/sms.py index 7e3d85bb..7e61faa4 100644 --- a/apps/utils/sms.py +++ b/apps/utils/sms.py @@ -1,5 +1,4 @@ -from aliyunsdkcore.client import AcsClient -from aliyunsdkcore.request import CommonRequest + import json import logging from server.settings import get_sysconfig @@ -12,6 +11,8 @@ myLogger = logging.getLogger('log') @auto_log(name='阿里云短信', raise_exception=True, send_mail=True) def send_sms(phone: str, template_code: int, template_param: dict): + from aliyunsdkcore.client import AcsClient + from aliyunsdkcore.request import CommonRequest config = get_sysconfig() if config.get("sms", {}).get('enabled', False) is False: raise ParseError("短信发送功能未启用")