generated from songquanpeng/gin-template
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Able to generate & handle verification code now
- Loading branch information
1 parent
f59a659
commit a988285
Showing
5 changed files
with
126 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters