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("短信发送功能未启用")