rabin 7 years ago
parent
commit
44fd38df65
1 changed files with 33 additions and 0 deletions
  1. 33 0
      service/msg.py

+ 33 - 0
service/msg.py

@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter service
+    msg
+"""
+from demeter.core import *
+class Msg(object):
+
+	def push(self, farm_id, uid, type_id, content, push=''):
+		model = Demeter.model('msg_type')
+		model.key = type_id
+		msg_type = model.select(type='fetchone')
+		if msg_type:
+			model = Demeter.model('msg')
+			model.farm_id = farm_id
+			model.uid = uid
+			model.type_id = type_id
+			model.content = content
+			if not push:
+				push = msg_type['push']
+			model.push = push
+			if 'sms' in model.push:
+				self.sendSms(uid, content)
+			if 'wechat' in model.push:
+				self.sendWechat(uid, content)
+			id = model.insert()
+
+	def sendSms(self, uid, content):
+		return
+
+	def sendWechat(self, uid, content):
+		return
+