interface.py 900 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:main.py
  5. author:rabin
  6. """
  7. from .__load__ import *
  8. import json
  9. class Core(object):
  10. @staticmethod
  11. def check(self):
  12. pass
  13. # 同步数据
  14. class sync_path(Load):
  15. @Web.setting
  16. def post(self):
  17. Core.check(self)
  18. data = self.input('data')
  19. data = json.loads(data)
  20. table = self.input('table')
  21. if data:
  22. for v in data:
  23. update = {}
  24. info = self.service('common').one(table, id=v['id'])
  25. if info:
  26. id = v['id']
  27. del v['cdate']
  28. if 'udate' in v:
  29. del v['udate']
  30. del v['id']
  31. for i in v:
  32. if v[i]:
  33. update[i] = v[i]
  34. self.service('common').update(table, id, update, cdate=False)
  35. else:
  36. del v['cdate']
  37. if 'udate' in v:
  38. del v['udate']
  39. for i in v:
  40. if v[i]:
  41. update[i] = v[i]
  42. self.service('common').update(table, False, update)
  43. self.out('ok')