diff --git a/apps/auth1/views.py b/apps/auth1/views.py index 11f2914..b5c858e 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 f6b3dba..1631e22 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 @@ -10,6 +9,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', True) is False: return