|
@@ -10,11 +10,7 @@ import datetime
|
|
|
import time
|
|
|
import logging
|
|
|
|
|
|
-
|
|
|
-from django.db import transaction
|
|
|
-
|
|
|
-from Controller.CheckUserData import RandomStr
|
|
|
-from Model.models import Device_User, DeviceSuperPassword, SysMsgModel
|
|
|
+from Model.models import Device_User, DeviceSuperPassword
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -48,27 +44,18 @@ class SuperPasswordView(View):
|
|
|
userID = tko.userID
|
|
|
if operation == 'getAuthorizationCode': # 用户提交请求
|
|
|
return self.getAuthorizationCode(request_dict, response, userID)
|
|
|
- if operation == 'customerServiceManagement': # 审核用户请求/生成超级密码
|
|
|
- return self.customerServiceManagement(request_dict, response)
|
|
|
- if operation == 'getDeviceSuperPassword': # 查询用户请求表
|
|
|
- return self.getDeviceSuperPassword(request_dict, response)
|
|
|
if operation == 'verifyTheVerificationCode': # 检验验证码
|
|
|
return self.verifyTheVerificationCode(request_dict, response, userID)
|
|
|
- if operation == 'deleteInformation': # 删除信息
|
|
|
- return self.deleteInformation(request_dict, response)
|
|
|
else:
|
|
|
return response.json(404)
|
|
|
|
|
|
- def getAuthorizationCode(self, request_dict, response, userID):
|
|
|
+ @staticmethod
|
|
|
+ def getAuthorizationCode(request_dict, response, userID):
|
|
|
"""
|
|
|
用户提交请求
|
|
|
- @param uid:设备id
|
|
|
@param request_dict:请求参数
|
|
|
@param response:响应对象
|
|
|
- @param describe:需求描述
|
|
|
- @param Purchase_channel:购买渠道描述
|
|
|
- @param orderID:订单id
|
|
|
- @param buyTime:购买时间
|
|
|
+ @param userID:用户ID
|
|
|
@return:
|
|
|
"""
|
|
|
uid = request_dict.get('uid', None)
|
|
@@ -97,109 +84,13 @@ class SuperPasswordView(View):
|
|
|
print('生成验证码异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
- def customerServiceManagement(self, request_dict, response):
|
|
|
- """
|
|
|
- 审核用户请求/生成超级密码
|
|
|
- @param request_dict:请求参数
|
|
|
- @param response:响应对象
|
|
|
- @param hint:提示内容
|
|
|
- @return:
|
|
|
- """
|
|
|
- ID = request_dict.get('ID', None)
|
|
|
- userID = request_dict.get('userID', None)
|
|
|
- uid = request_dict.get('uid', None)
|
|
|
- status = request_dict.get('status', None)
|
|
|
- hint = request_dict.get('hint', None)
|
|
|
- lang = request_dict.get('lang', 'en')
|
|
|
- if not all({ID, uid, userID}):
|
|
|
- return response.json(444)
|
|
|
- now = int(time.time())
|
|
|
- try:
|
|
|
- with transaction.atomic():
|
|
|
- device_super_password_qs = DeviceSuperPassword.objects.filter(id=ID, uid=uid, userID=userID)
|
|
|
- if not device_super_password_qs.exists():
|
|
|
- return response.json(173)
|
|
|
- status = int(status)
|
|
|
- if status == 1:
|
|
|
- # 验证码生成
|
|
|
- super_code = RandomStr(6, True)
|
|
|
- super_password_id = "super_password_%s" % userID
|
|
|
- redisObj = RedisObject()
|
|
|
- redis = redisObj.set_data(key=super_password_id, val=super_code, expire=86400)
|
|
|
- # if redis is False:
|
|
|
- # return response.json(121)
|
|
|
- device_super_password_qs.update(status=status)
|
|
|
- if lang == 'en':
|
|
|
- msg = "Your authorization code is " + super_code + ",valid within 24 hours"
|
|
|
- else:
|
|
|
- msg = "您的授权代码:" + super_code + ",24小时内有效"
|
|
|
- SysMsgModel.objects.create(userID_id=userID, msg=msg, addTime=now, updTime=now, uid=uid,
|
|
|
- eventType=2)
|
|
|
- return response.json(0)
|
|
|
- if status == 0 and len(hint) > 1:
|
|
|
- device_super_password_qs.update(status=status, hint=hint)
|
|
|
- msg = hint
|
|
|
- SysMsgModel.objects.create(userID_id=userID, msg=msg, addTime=now, updTime=now, uid=uid,
|
|
|
- eventType=2)
|
|
|
- return response.json(0)
|
|
|
- return response.json(177)
|
|
|
- except Exception as e:
|
|
|
- print('修改状态异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
- return response.json(500, repr(e))
|
|
|
-
|
|
|
- def getDeviceSuperPassword(self, request_dict, response):
|
|
|
- """
|
|
|
- 查询用户请求表
|
|
|
- @param request_dict:请求参数
|
|
|
- @param response:响应对象
|
|
|
- @return:
|
|
|
- """
|
|
|
- pageNo = request_dict.get('pageNo', None)
|
|
|
- pageSize = request_dict.get('pageSize', None)
|
|
|
- status = request_dict.get('status', None)
|
|
|
- userID = request_dict.get('userID', None)
|
|
|
- uid = request_dict.get('uid', None)
|
|
|
- if not all([pageNo, pageSize]):
|
|
|
- return response.json(444)
|
|
|
- page = int(pageNo)
|
|
|
- line = int(pageSize)
|
|
|
- try:
|
|
|
- device_super_password_qs = DeviceSuperPassword.objects.all()
|
|
|
- if status:
|
|
|
- device_super_password_qs = device_super_password_qs.filter(status=status)
|
|
|
- if userID:
|
|
|
- device_super_password_qs = device_super_password_qs.filter(userID=userID)
|
|
|
- if uid:
|
|
|
- device_super_password_qs = device_super_password_qs.filter(uid=uid)
|
|
|
- if not device_super_password_qs.exists():
|
|
|
- return response.json(0, [])
|
|
|
- count = device_super_password_qs.count()
|
|
|
- device_super_password_qs = device_super_password_qs.values('id',
|
|
|
- 'uid',
|
|
|
- 'userID',
|
|
|
- 'orderID',
|
|
|
- 'describe',
|
|
|
- 'purchase_channel',
|
|
|
- 'addTime',
|
|
|
- 'status',
|
|
|
- 'buyTime',
|
|
|
- 'hint',
|
|
|
- 'lang',
|
|
|
- 'userID__username')
|
|
|
- device_super_password_qs = device_super_password_qs.order_by('-addTime')[
|
|
|
- (page - 1) * line:page * line]
|
|
|
- return response.json(0, {'list': list(device_super_password_qs), 'count': count})
|
|
|
- except Exception as e:
|
|
|
- print('查询异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
- return response.json(500, repr(e))
|
|
|
-
|
|
|
- def verifyTheVerificationCode(self, request_dict, response, userID):
|
|
|
+ @staticmethod
|
|
|
+ def verifyTheVerificationCode(request_dict, response, userID):
|
|
|
"""
|
|
|
检验验证码
|
|
|
@param request_dict:请求参数
|
|
|
@param response:响应对象
|
|
|
@param userID:用户ID
|
|
|
- @param authcode:验证码
|
|
|
@return:
|
|
|
"""
|
|
|
authcode = request_dict.get('authcode', None)
|
|
@@ -218,20 +109,3 @@ class SuperPasswordView(View):
|
|
|
return response.json(0)
|
|
|
else:
|
|
|
return response.json(444)
|
|
|
-
|
|
|
- def deleteInformation(self, request_dict, response):
|
|
|
- """
|
|
|
- 删除信息
|
|
|
- @param request_dict:请求参数
|
|
|
- @param response:响应对象
|
|
|
- @param id:主键
|
|
|
- """
|
|
|
- id = request_dict.get('id', None)
|
|
|
- if not id:
|
|
|
- return response.json(444)
|
|
|
- device_super_password_qs = DeviceSuperPassword.objects.filter(id=id)
|
|
|
- if not device_super_password_qs.exists():
|
|
|
- return response.json(173)
|
|
|
- device_super_password_qs.delete()
|
|
|
- return response.json(0)
|
|
|
-
|