generated from songquanpeng/gin-template
-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathwechat-message.go
33 lines (29 loc) · 958 Bytes
/
wechat-message.go
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
package common
import "encoding/xml"
type WeChatMessageRequest struct {
XMLName xml.Name `xml:"xml"`
ToUserName string `xml:"ToUserName"`
FromUserName string `xml:"FromUserName"`
CreateTime int64 `xml:"CreateTime"`
MsgType string `xml:"MsgType"`
Content string `xml:"Content"`
MsgId int64 `xml:"MsgId"`
MsgDataId int64 `xml:"MsgDataId"`
Idx int64 `xml:"Idx"`
}
type WeChatMessageResponse struct {
XMLName xml.Name `xml:"xml"`
ToUserName string `xml:"ToUserName"`
FromUserName string `xml:"FromUserName"`
CreateTime int64 `xml:"CreateTime"`
MsgType string `xml:"MsgType"`
Content string `xml:"Content"`
}
func ProcessWeChatMessage(req *WeChatMessageRequest, res *WeChatMessageResponse) {
switch req.Content {
case "验证码":
code := GenerateAllNumberVerificationCode(6)
RegisterWeChatCodeAndID(code, req.FromUserName)
res.Content = code
}
}