msg.py 716 B

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter service
  4. msg
  5. """
  6. from demeter.core import *
  7. class Msg(object):
  8. def push(self, farm_id, uid, type_id, content, push=''):
  9. model = Demeter.model('msg_type')
  10. model.key = type_id
  11. msg_type = model.select(type='fetchone')
  12. if msg_type:
  13. model = Demeter.model('msg')
  14. model.farm_id = farm_id
  15. model.uid = uid
  16. model.type_id = type_id
  17. model.content = content
  18. if not push:
  19. push = msg_type['push']
  20. model.push = push
  21. if 'sms' in model.push:
  22. self.sendSms(uid, content)
  23. if 'wechat' in model.push:
  24. self.sendWechat(uid, content)
  25. id = model.insert()
  26. def sendSms(self, uid, content):
  27. return
  28. def sendWechat(self, uid, content):
  29. return