httplib_mmm_open_api_service_gateway.go
1.9 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package serviceGateway
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
)
type HttplibMmmOpenApiServiceGateway struct {
httpLibBaseServiceGateway
}
// MessageOptions 个推参数
type MessageOptions struct {
MmmType int `json:"mmmType"` // 通知类型 0:系统透传消息 1:系统通知消息 默认:系统透传
Project string `json:"project"` // 单一终端类型 项目编码 "mmm.tianlian.performance"
Projects []string `json:"projects"` // 多终端类型
Receivers []int64 `json:"receivers"` // 消息接收者uid
Title string `json:"title"` // 个推标题
Content string `json:"content"` // 个推内容
Ext MessageExt `json:"ext"` // 为保证请求正常,保留字段. 暂时用不到的字段。
}
type MessageExt struct {
TransData struct {
MmmType string `json:"mmmType"`
MmmTitle string `json:"mmmTitle"`
MmmContent string `json:"mmmContent"`
} `json:"transData"`
}
// PushInfo 个推
func (serviceGateway *HttplibMmmOpenApiServiceGateway) PushInfo(msgType int, project string, uids []int64, title string, content string) (map[string]interface{}, error) {
url := "/v1/push/pushInfo"
serviceGateway.CreateRequest("post", url)
options := &MessageOptions{
MmmType: msgType,
Project: project,
Receivers: uids,
Title: title,
Content: content,
}
options.Ext.TransData.MmmType = "103" //固定值,需要手机端配合设置
options.Ext.TransData.MmmTitle = title
options.Ext.TransData.MmmContent = content
serviceGateway.SetBody(options)
response := make(map[string]interface{})
err := serviceGateway.ToJson(&response)
return response, err
}
func NewHttplibMmmOpenApiServiceGateway() *HttplibMmmOpenApiServiceGateway {
return &HttplibMmmOpenApiServiceGateway{
httpLibBaseServiceGateway{
baseURL: constant.MMM_OPEN_API_SERVICE_HOST,
},
}
}