uidManageResponseObject.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. from django.shortcuts import HttpResponse
  2. import simplejson as json
  3. class uidManageResponseObject(object):
  4. def __init__(self, lang='cn'):
  5. self.lang = lang
  6. def data(self, code, res={}):
  7. data_cn = {
  8. 0: '成功',
  9. 5: '请一分钟后再尝试',
  10. 8: '用户账号已存在',
  11. 9: '用户账号不存在',
  12. 10: res,
  13. 13: '时间戳token校验失败',
  14. 42: '两次输入的新密码错误',
  15. 43: '客户端服务器已关闭,请下载新版本使用',
  16. 44: '系统错误,发送邮件失败',
  17. 45: '系统错误,生成令牌出错!',
  18. 46: '系统错误,发送短信失败!',
  19. 47: '旧密码不正确',
  20. 74: '关联旧用户失败!',
  21. 79: '您已经申请过重置密码,请到邮箱进行确认!',
  22. 89: '您已经获得了验证码,请在10分钟后检查或再次确认。',
  23. 99: '账户或密码错误',
  24. 101: '手机的用户账号已经存在!',
  25. 102: '手机的用户账号不存在!',
  26. 103: '邮箱用户帐户已经存在!',
  27. 104: '邮箱用户帐户不存在!',
  28. 107: '用户名格式不符合规则!',
  29. 108: '邮箱格式不符合规则!',
  30. 110: '因为用户未激活,用户是无效用户!',
  31. 111: '您输入的密码不正确!',
  32. 120: '验证码已过期或不存在、请重新获得验证码!',
  33. 121: '验证码错了!',
  34. 138: '手机格式不符合规则!',
  35. 173: '数据不存在!',
  36. 174: '数据已存在',
  37. 175: 'mac地址已用完',
  38. 176: '数据库异常',
  39. 305: '令牌格式是错误的,相关参数是不存在的!',
  40. 307: '令牌已过期!',
  41. 308: '此次下载已失效',
  42. 309: '你没有权限访问',
  43. 373: '没有相应的公司',
  44. 374: '没有相应的地区',
  45. 375: 'uid不足',
  46. 376: 'uid数据有误',
  47. 377: 'uid已使用',
  48. 378: '更新序列号状态失败',
  49. 379: '序列号不存在',
  50. 404: '没有访问权限!',
  51. 444: '请确认参数的正确性!',
  52. 1112: '您输入的两次密码不一致!',
  53. 208: '只能预定当天的或者以后的!',
  54. 10041: '已超出序列号剩余可绑定数',
  55. 10042: '序列号已被占用',
  56. 10043: '无法解绑,序列号的状态为被占用',
  57. }
  58. data_en = {
  59. 0: 'Success',
  60. 5: 'Please try again one minute later!',
  61. 8: 'User accounts already exist',
  62. 9: 'User accounts is not exist',
  63. 10: res,
  64. 13: 'Timestamp token verification failed',
  65. 42: 'The new password entered twice is incorrect',
  66. 43: 'The client server is closed. Please download the new version for use',
  67. 44: 'System error,send email fail!',
  68. 45: 'System error,generate token fail!',
  69. 46: 'System error, sending SMS failed!',
  70. 47: 'Old password is incorrect',
  71. 74: 'Failed to connect old users!',
  72. 79: 'You have applied for reset password, please go to email for confirmation!',
  73. 89: 'You have already obtained the verification code, please check it or get it again after 10 minutes.',
  74. 99: ' ERROR Incorrect account or password',
  75. 101: 'The user account of the mobile phone has already existed!',
  76. 102: 'The user account of the mobile phone does not exist!',
  77. 103: 'The mailbox user account has already existed!',
  78. 104: 'The mailbox user account does not exist!',
  79. 107: 'The username format does not conform to the rules!',
  80. 108: 'The mailbox format does not conform to the rules! ',
  81. 110: 'Because the user is not activated, the user is an invalid user!',
  82. 111: 'The password you entered is incorrect!',
  83. 120: 'The captcha has expired or does not exist, please obtain the captcha again!',
  84. 121: 'The verification code is wrong!',
  85. 138: 'The phone format does not conform to the rules! ',
  86. 173: 'Data does not exists!',
  87. 174: 'Data already exists',
  88. 175: 'MAC address has been used up',
  89. 176: 'Database exception',
  90. 305: 'The Token format is wrong and the related parameter is None!',
  91. 307: 'The Token has expired!',
  92. 308: 'This download has expired!',
  93. 309: 'You have no access',
  94. 373: 'No corresponding company',
  95. 374: 'Region does not exist',
  96. 375: 'Insufficient uid',
  97. 376: 'wrong uid data',
  98. 377: 'uid used',
  99. 378: 'Failed to update serial number status',
  100. 379: 'Serial number does not exist',
  101. 404: 'You don not have permission to access this!',
  102. 444: 'Please confirm the correctness of the parameters!',
  103. 1112: 'The two passwords you entered do not match!',
  104. 10041: 'The remaining number of serial numbers that can be bound has exceeded',
  105. 10042: 'Serial number is already occupied',
  106. 10043: 'Unable to unbind, the status of the serial number is occupied',
  107. }
  108. if self.lang == 'cn':
  109. msg = data_cn
  110. else:
  111. msg = data_en
  112. try:
  113. message = msg[code]
  114. except Exception as e:
  115. message = '系统错误,code不存在'
  116. return {'result_code': code, 'reason': message, 'result': res, 'error_code': code}
  117. def formal(self, code, res={}):
  118. formal_data = self.data(code, res)
  119. return json.dumps(formal_data,ensure_ascii=False)
  120. def json(self, code, res={}):
  121. result = self.formal(code, res)
  122. return HttpResponse(result)