|
@@ -35,12 +35,14 @@ class AppAccoutView(View):
|
|
|
return self.validation(request_dict, request, operation)
|
|
|
|
|
|
def validation(self, request_dict, request, operation):
|
|
|
- token = TokenObject(request.META.get('HTTP_AUTHORIZATION'))
|
|
|
- lang = request_dict.get('lang', token.lang)
|
|
|
- response = ResponseObject(lang)
|
|
|
- userID = token.userID
|
|
|
+ token = request_dict.get('token', None)
|
|
|
+ response = ResponseObject()
|
|
|
+ if token is None:
|
|
|
+ return response.json(309)
|
|
|
+ token = TokenObject(token)
|
|
|
if token.code != 0:
|
|
|
return response.json(token.code)
|
|
|
+ userID = token.userID
|
|
|
if operation == 'getAuthorizationCode': # 获取用户请求/生成授权码
|
|
|
return self.getAuthorizationCode(request_dict, response, userID)
|
|
|
if operation == 'customerServiceManagement': # 编辑超级密码请求表
|
|
@@ -49,6 +51,8 @@ class AppAccoutView(View):
|
|
|
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)
|
|
|
|
|
@@ -94,34 +98,6 @@ class AppAccoutView(View):
|
|
|
print('生成验证码异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
- # def storeTheVerificationCode(self, userID, uid, lang, authcode, status, hint, response):
|
|
|
- # now = int(time.time())
|
|
|
- # try:
|
|
|
- # with transaction.atomic():
|
|
|
- # if authcode and uid and userID:
|
|
|
- # device_super_password_qs = DeviceSuperPassword.objects.filter(uid=uid, userID=userID)
|
|
|
- # if not device_super_password_qs.exists():
|
|
|
- # return response.json(173)
|
|
|
- # authcode = CommonService.decode_data(authcode)
|
|
|
- # if status == 1:
|
|
|
- # if lang == 'en':
|
|
|
- # msg = "Your authorization code is " + authcode + ",valid within 24 hours"
|
|
|
- # else:
|
|
|
- # msg = "您的授权代码:" + authcode + ",24小时内有效"
|
|
|
- # code = CommonService.encode_data(authcode)
|
|
|
- # SysMsgModel.objects.create(userID_id=userID, msg=msg, addTime=now, updTime=now, uid=uid,
|
|
|
- # eventType=2, code=code)
|
|
|
- # return response.json(0)
|
|
|
- # if status == 0 and len(hint) > 1:
|
|
|
- # 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(444)
|
|
|
- # except Exception as e:
|
|
|
- # 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:请求参数
|
|
@@ -129,7 +105,7 @@ class AppAccoutView(View):
|
|
|
@param hint:提示内容
|
|
|
@return:
|
|
|
"""
|
|
|
- userID = request_dict.get('userID')
|
|
|
+ userID = request_dict.get('userID', None)
|
|
|
uid = request_dict.get('uid', None)
|
|
|
status = request_dict.get('status', None)
|
|
|
hint = request_dict.get('hint', None)
|
|
@@ -154,19 +130,12 @@ class AppAccoutView(View):
|
|
|
if redis_super_code is False:
|
|
|
return response.json(120)
|
|
|
authcode = CommonService.encode_data(redis_super_code)
|
|
|
- if status == 0:
|
|
|
+ if status == 0 and len(hint) > 1:
|
|
|
device_super_password_qs.update(status=status, hint=hint)
|
|
|
- super_password_id = 'super_password_' + userID
|
|
|
- redisObj = RedisObject()
|
|
|
- # redis里面的验证码
|
|
|
- redis_super_code = redisObj.get_data(key=super_password_id)
|
|
|
- # 验证用户输入的验证码和redis中的验证码
|
|
|
- if redis_super_code is False:
|
|
|
- return response.json(120)
|
|
|
- authcode = CommonService.encode_data(redis_super_code)
|
|
|
- device_super_password_qs = DeviceSuperPassword.objects.filter(uid=uid, userID=userID)
|
|
|
- if not device_super_password_qs.exists():
|
|
|
- return response.json(173)
|
|
|
+ msg = hint
|
|
|
+ SysMsgModel.objects.create(userID_id=userID, msg=msg, addTime=now, updTime=now, uid=uid,
|
|
|
+ eventType=2)
|
|
|
+ return response.json(0)
|
|
|
authcode = CommonService.decode_data(authcode)
|
|
|
if status == 1:
|
|
|
if lang == 'en':
|
|
@@ -176,11 +145,6 @@ class AppAccoutView(View):
|
|
|
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:
|
|
|
- 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)))
|
|
@@ -232,7 +196,7 @@ class AppAccoutView(View):
|
|
|
|
|
|
def verifyTheVerificationCode(self, request_dict, response, userID):
|
|
|
"""
|
|
|
- @czVccccccc request_dict:请求参数
|
|
|
+ @param request_dict:请求参数
|
|
|
@param response:响应对象
|
|
|
@param userID:用户ID
|
|
|
@param authcode:验证码
|
|
@@ -252,3 +216,19 @@ class AppAccoutView(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)
|
|
|
+
|