push.go
2.2 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package domain
import (
"encoding/json"
"openapi/pkg/infrastructure/log"
)
/*PushInfo 推送信息*/
type PushInfoOriginalRequest struct {
Type int `json:"msgType"`
ClientIdList []string `json:"clientId"`
AppKey string `json:"appKey" valid:"Required"`
Secret string `json:"secret" valid:"Required"`
AppId string `json:"appId" valid:"Required"`
Title string `json:"title" valid:"Required"`
Content string `json:"content" valid:"Required"`
Ext map[string]interface{} `json:"ext"` //key->transData:透传数据
}
type PushInfoResponse struct {
ExtData map[string]interface{} `json:"-"`
}
/*PushInfo 推送信息*/
type PushInfoRequest struct {
Type int `json:"msgType"`
Receivers []int64 `json:"receivers"` //接受用户id列表
ProjectKey string `json:"project"` //ability
Title string `json:"title" valid:"Required"`
Content string `json:"content" valid:"Required"`
Ext map[string]interface{} `json:"ext"` //key->transData:透传数据
ActualReceivers []int64 `json:"-"` //实际发送的人员id列表
}
/*UpdateDevice 更新设备*/
type UpdateDeviceRequest struct {
ProjectKey string `json:"projectKey"` //项目主编号
Muid int64 `json:"muid" valid:"Required;"` //企业平台中的用户 UID
ClientId string `json:"clientId" valid:"Required"`
DeviceToken string `json:"deviceToken"`
Phone string `json:"phone"`
}
type UpdateDeviceResponse struct {
}
//设备信息
type Device struct {
Uid int64
ClientId string
DeviceToken string
IsActive int
}
//应用信息
type AppInfo struct {
Id int
AppKey string
AppMasterSecret string
AppId string
ProjectId int //项目编号
ExtInfo string
}
type ExtInfo struct {
Intent string `json:"intent"`
Sound string `json:"sound,omitempty"`
}
func (t *AppInfo) GetExtInfo() (*ExtInfo, bool) {
extInfo := &ExtInfo{}
if len(t.ExtInfo) == 0 {
return nil, false
}
if err := json.Unmarshal([]byte(t.ExtInfo), extInfo); err != nil {
log.Error(err.Error())
return nil, false
}
return extInfo, true
}