TemplateService.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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: Ansjer
  7. @software: PyCharm
  8. @DATE: 2018/7/3 11:11
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: TemplateService.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. class TemplateService:
  15. @staticmethod
  16. def log_api():
  17. apiList = [
  18. 'account/login',
  19. 'account/logout',
  20. 'account/changePwd',
  21. 'account/forget',
  22. # 'account/email-re-pwd'
  23. 'account/refreshTk',
  24. 'account/showUserMore',
  25. 'account/perfectUserInfo',
  26. 'account/getAvatar',
  27. 'account/delUser',
  28. 'account/setUserValid',
  29. 'account/unsharedUserEquipment',
  30. 'equipment/queryUserEquipment',
  31. 'equipment/addNewUserEquipment',
  32. 'equipment/delUserEquipment',
  33. 'equipment/modifyUserEquipment',
  34. 'OTA/uploads',
  35. 'OTA/download',
  36. 'OTA/downloads',
  37. 'OTA/getEquipmentVersion',
  38. 'OTA/getUpdataFileUrl',
  39. 'OTA/addNewEquipmentVersion',
  40. 'OTA/getUpdataFileUrl',
  41. 'roles/addNewRole',
  42. 'roles/delRole',
  43. 'roles/modifyRole',
  44. 'perms/addNewPerms',
  45. 'perms/delPerms',
  46. 'perms/modifyPerms',
  47. 'uploads/upgrade',
  48. 'downloads/upgrade',
  49. 'getOTAurl/getUpdataFileUrl',
  50. 'adminManage/manage',
  51. 'equipment/OTA',
  52. 'appInfo',
  53. 'OTA/getNewVer',
  54. 'v2/account/authcode',
  55. 'v2/account/register',
  56. 'v2/account/forgetCode',
  57. 'v2/account/resetPwdByCode',
  58. 'cloudVod/createOrder',
  59. 'cloudVod/payExecute',
  60. 'cloudVod/getHlsList',
  61. 'cloudVod/status',
  62. 'cloudVod/details',
  63. 'cloudVod/playlist',
  64. # 'equipment/info'
  65. ]
  66. return apiList
  67. @staticmethod
  68. def email_message(type, language):
  69. if language != 'cn':
  70. language = 'en'
  71. if type == 'register_code':
  72. data = {
  73. 'cn': {
  74. 'title': '注册码获取邮件',
  75. 'body': """
  76. <!DOCTYPE html>
  77. <html lang="en">
  78. <head>
  79. <meta charset="UTF-8">
  80. <title>Title</title>
  81. </head>
  82. <body>
  83. <div class="content"
  84. style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
  85. <h2 style="margin: 30px 0;">Hello, {username}</h2>
  86. <p style="margin-bottom: 40px;">请输入验证码完成注册,有效期10分钟:</p>
  87. <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{captcha}</span>
  88. </div>
  89. </body>
  90. </html>
  91. """,
  92. },
  93. 'en': {
  94. 'title': 'Registration code Email',
  95. 'body': """
  96. <!DOCTYPE html>
  97. <html lang="en">
  98. <head>
  99. <meta charset="UTF-8">
  100. <title>Title</title>
  101. </head>
  102. <body>
  103. <div class="content"
  104. style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
  105. <h2 style="margin: 30px 0;">Hello, {username}</h2>
  106. <p style="margin-bottom: 40px;">Please input code to reg. only valid in 10 minutes!</p>
  107. <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{captcha}</span>
  108. </div>
  109. </body>
  110. </html>
  111. """
  112. }
  113. }
  114. elif type == 'register':
  115. data = {
  116. 'cn': {
  117. 'title': '注册激活链接',
  118. 'body': '<br>尊敬的用户{username},您好!<br>恭喜您已经成功注册珠海安士佳物联网系统的用户,欢迎您使用该系统!<br>为确保您能即时收到本站的各项邮件通知,并及时获取相关信息,请您点击一下连接验证您的邮箱,忘记账号密码时您可使用该邮箱重新找回哟.' +
  119. '<br><p>'
  120. '<a href="{domain}/account/activate/{token}">{domain}/account/activate/{token}</a>'
  121. '<p>'
  122. },
  123. 'en': {
  124. 'title': 'Registration activation link',
  125. 'body': 'Dear user {username}, Hello!' +
  126. '<br>' + 'Congratulations, you have successfully registered users of the Zhuhai Internet security system, welcome you to use the system!' +
  127. '<br>' + 'In order to ensure that you can receive timely notification of the site, and timely access to relevant information.Please click on the following open link to verify your mailbox, and you can use the mailbox to retrieve it when you forget your account password.' +
  128. '<br>' + '<p><a href="{domain}/account/activate/{token}">{domain}/account/activate/{token}</a><p>'
  129. }
  130. }
  131. elif type == 'forget':
  132. data = {
  133. 'cn': {
  134. 'title': '重置密码信息',
  135. 'body': '您好{username}\n' + '您已经请求了重置密码,可以点击下面的链接来重置密码\n' + '<p><a href="{reset_link}">{reset_link}</a></p>\n' + '更改后的密码为: {reset_pwd}\n如果你没有请求重置密码,请忽略这封邮件.\n在你点击上面链接修改密码之前,你的密码将会保持不变\n'
  136. },
  137. 'en': {
  138. 'title': 'Reset the password information',
  139. 'body': 'Hello! Dear {username}.<br>You have asked to reset the password, and you can click the link below to reset the password.<br>' + '<p><a href="{reset_link}">{reset_link}</a></p><br>' + 'The new password is: {reset_pwd}<br>If you do not request to reset the password, please ignore this mail.',
  140. }
  141. }
  142. elif type == 'forgetCode':
  143. data = {
  144. 'cn': {
  145. 'title': '重置密码验证码',
  146. 'body': """
  147. <!DOCTYPE html>
  148. <html lang="en">
  149. <head>
  150. <meta charset="UTF-8">
  151. <title>Title</title>
  152. </head>
  153. <body>
  154. <div class="content"
  155. style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
  156. <h2 style="margin: 30px 0;">{userEmail},您好</h2>
  157. <p style="margin-bottom: 40px;">请使用下面的验证码重置您的密码,验证码 10 分钟内有效: </p>
  158. <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{email_valid_code}</span>
  159. </div>
  160. </body>
  161. </html>
  162. """
  163. },
  164. 'en': {
  165. 'title': 'Reset password verification code',
  166. 'body': """
  167. <!DOCTYPE html>
  168. <html lang="en">
  169. <head>
  170. <meta charset="UTF-8">
  171. <title>Title</title>
  172. </head>
  173. <body>
  174. <div class="content"
  175. style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
  176. <h2 style="margin: 30px 0;">Hello, {userEmail}</h2>
  177. <p style="margin-bottom: 40px;">Please reset your password with the following captcha, which is valid for 10 minutes:</p>
  178. <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{email_valid_code}</span>
  179. </div>
  180. </body>
  181. </html>
  182. """
  183. }
  184. }
  185. return data[language]