ShadowController.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerPush
  7. @software: PyCharm
  8. @DATE: 2020/2/14 13:54
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: ShadowController.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. # 测试环境
  15. # test.shadow.dvema.com
  16. # 生产环境
  17. # shadow.dvema.com
  18. # 设备影子更新
  19. import logging
  20. import time
  21. import requests
  22. from django.http import JsonResponse
  23. from ratelimit.decorators import ratelimit
  24. from AnsjerPush.config import SERVER_TYPE
  25. from Model.models import Device_Info, UidSetModel, UID_Preview, VoicePromptModel, UID_Bucket, UidChannelSetModel, \
  26. AiService, CountryModel
  27. from Object.ETkObject import ETkObject
  28. from Object.ResponseObject import ResponseObject
  29. from Service.CommonService import CommonService
  30. def generate_utk(request):
  31. request.encoding = 'utf-8'
  32. response = ResponseObject()
  33. if request.method == 'GET':
  34. request_dict = request.GET
  35. elif request.method == 'POST':
  36. request_dict = request.POST
  37. else:
  38. return response.json(444, 'wrong method')
  39. username = request_dict.get('username', None)
  40. password = request_dict.get('password', None)
  41. uid = request_dict.get('uid', None)
  42. if username and password:
  43. if username == 'debug_user' and password == 'debug_password':
  44. # utko = UidTokenObject()
  45. # # right
  46. # utko.generate(data={'uid': uid})
  47. etkObj = ETkObject(etk='')
  48. etk = etkObj.encrypt(uid)
  49. return response.json(0, {'etk': etk})
  50. else:
  51. return response.json(404)
  52. else:
  53. return response.json(444, 'username password')
  54. # 设备影子更新
  55. def update_device_shadow(request):
  56. return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})