task.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from data import MySQLTool
  2. import hashlib
  3. import uuid
  4. import TokenUtils
  5. from returnTemp import get_template, get_error_message
  6. import json
  7. from datetime import datetime
  8. class TikTask:
  9. def __init__(self, action, data, logger):
  10. self.action = action
  11. self.data = data
  12. self.logger = logger
  13. def tik_task_router(self):
  14. if self.action == "create":
  15. return self.create()
  16. elif self.action == "status":
  17. return self.status()
  18. elif self.action == "signcheck":
  19. return self.signcheck()
  20. elif self.action == "signset":
  21. return self.signset()
  22. else:
  23. return self.test()
  24. def create(self):
  25. print("---create---")
  26. return create(self.data)
  27. def status(self):
  28. print("---status----")
  29. return status(self.data)
  30. def signcheck(self):
  31. print("---signcheck----")
  32. return signcheck()
  33. def signset(self):
  34. print("---signset----")
  35. return signset(self.data)
  36. def test(self):
  37. return self.data
  38. def signcheck():
  39. with open('needsign.json') as json_file:
  40. r = json.load(json_file)
  41. return r
  42. def signset(data):
  43. with open('needsign.json', 'w') as json_file:
  44. json.dump(data, json_file)
  45. with open('needsign.json') as json_file:
  46. r = json.load(json_file)
  47. now = datetime.now()
  48. formatted_time = now.strftime("%Y-%m-%d %H:%M:%S")
  49. r["changetime"] = formatted_time
  50. return r
  51. def create(data):
  52. return data
  53. def status(data):
  54. return data