Browse Source

优化退出登录接口,获取域名日志打印

locky 1 year ago
parent
commit
d02cf74603
2 changed files with 13 additions and 15 deletions
  1. 0 6
      Controller/DeviceConfirmRegion.py
  2. 13 9
      Controller/UserController.py

+ 0 - 6
Controller/DeviceConfirmRegion.py

@@ -9,7 +9,6 @@ from Model.models import CountryModel, RegionModel, P2PIpModel, DeviceDomainMode
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Service.CommonService import CommonService
 from Service.CommonService import CommonService
 from Object.IPWeatherObject import IPQuery
 from Object.IPWeatherObject import IPQuery
-from Ansjer.config import LOGGER
 
 
 
 
 class ConfirmRegion(View):
 class ConfirmRegion(View):
@@ -62,10 +61,8 @@ class ConfirmRegion(View):
                 'push_api_url': push_api,
                 'push_api_url': push_api,
                 'push_region': push_region
                 'push_region': push_region
             }
             }
-            LOGGER.info('获取域名:ip:{},响应数据:{}'.format(ip, res))
             return response.json(0, res)
             return response.json(0, res)
         except Exception as e:
         except Exception as e:
-            LOGGER.info('获取域名异常:error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
 
 
 
@@ -85,7 +82,6 @@ class ConfirmRegionV2(View):
 
 
         serial_number = request.GET.get('serial_number', None)
         serial_number = request.GET.get('serial_number', None)
         if not serial_number:
         if not serial_number:
-            LOGGER.info('V2获取域名缺少序列号:ip:{}'.format(ip))
             return response.json(444)
             return response.json(444)
         try:
         try:
             data_dict = {'serial_number': serial_number}
             data_dict = {'serial_number': serial_number}
@@ -133,10 +129,8 @@ class ConfirmRegionV2(View):
                 'region_id': region_id,
                 'region_id': region_id,
                 'push_region': push_region
                 'push_region': push_region
             }
             }
-            LOGGER.info('V2获取域名:序列号:{},ip:{},响应数据:{}'.format(serial_number, ip, res))
             return response.json(0, res)
             return response.json(0, res)
         except Exception as e:
         except Exception as e:
-            LOGGER.info('V2获取域名异常:error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
 
 
 

+ 13 - 9
Controller/UserController.py

@@ -12,6 +12,7 @@ import simplejson
 import simplejson as json
 import simplejson as json
 from PIL import Image, ImageDraw, ImageFont
 from PIL import Image, ImageDraw, ImageFont
 from django.contrib.auth.hashers import make_password, check_password  # 对密码加密模块
 from django.contrib.auth.hashers import make_password, check_password  # 对密码加密模块
+from django.db import transaction
 from django.db.models import Q
 from django.db.models import Q
 from django.http import HttpResponseRedirect
 from django.http import HttpResponseRedirect
 from django.shortcuts import HttpResponse
 from django.shortcuts import HttpResponse
@@ -306,16 +307,19 @@ class LogoutView(TemplateView):
         if tko.code != 0:
         if tko.code != 0:
             return response.json(tko.code)
             return response.json(tko.code)
 
 
-        Device_User.objects.filter(userID=tko.userID).update(online=False)
-        redisObj = RedisObject(db=3)
-        redisObj.del_data(key=tko.userID)
-        Device_Info.objects.filter(userID=tko.userID).update(NotificationMode=0)
         m_code = request_dict.get('m_code', None)
         m_code = request_dict.get('m_code', None)
-        if m_code:
-            userID = tko.userID
-            UidPushModel.objects.filter(userID_id=userID, m_code=m_code).delete()
-            GatewayPush.objects.filter(user_id=userID, m_code=m_code).update(logout=True)
-        return response.json(0)
+        try:
+            with transaction.atomic():
+                Device_User.objects.filter(userID=tko.userID).update(online=False)
+                Device_Info.objects.filter(userID=tko.userID).update(NotificationMode=0)
+                if m_code:
+                    userID = tko.userID
+                    UidPushModel.objects.filter(userID_id=userID, m_code=m_code).delete()
+                    GatewayPush.objects.filter(user_id=userID, m_code=m_code).update(logout=True)
+            return response.json(0)
+        except Exception as e:
+            LOGGER.info('退出登录异常:error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
+            return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
 
 
 
 
 # 修改密码
 # 修改密码