-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.go
More file actions
39 lines (33 loc) · 956 Bytes
/
message.go
File metadata and controls
39 lines (33 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package jpush
import (
"encoding/json"
)
//Message Message
type Message struct {
MsgContent string `json:"msg_content"`
Title string `json:"title,omitempty"`
ContentType string `json:"content_type,omitempty"`
Extras map[string]string `json:"extras,omitempty"`
}
//SmsMessage SmsMessage
type SmsMessage struct {
DelayTime int `json:"delay_time"`
TempID int64 `json:"temp_id"`
TempPara interface{} `json:"temp_para,omitempty"`
}
//CreateMessage 创建消息
func CreateMessage() (message *Message) {
return &Message{}
}
//SetMessageContent 设置消息内容
func (message *Message) SetMessageContent(content interface{}) {
buf, _ := json.Marshal(content)
message.MsgContent = string(buf)
}
//AddExtras 添加扩展字段
func (message *Message) AddExtras(key, val string) {
if message.Extras == nil {
message.Extras = make(map[string]string)
}
message.Extras[key] = val
}