Browse Source

update

master
dengbiao 4 months ago
parent
commit
c3870810a0
3 changed files with 50 additions and 0 deletions
  1. +34
    -0
      app/hdl/hdl_wx_open.go
  2. +5
    -0
      app/router/router.go
  3. +11
    -0
      app/utils/file.go

+ 34
- 0
app/hdl/hdl_wx_open.go View File

@@ -0,0 +1,34 @@
package hdl

import (
"applet/app/utils"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)

type ReqWxMessage struct {
AppId string `json:"AppId"`
FromUserName string `json:"CreateTime"`
InfoType string `json:"InfoType"`
ComponentVerifyTicket string `json:"ComponentVerifyTicket"` // text | image | voice | shortvideo | location
}

func SetTicket(c *gin.Context) {
params := c.QueryMap("*")
utils.FilePutContents("SetTicket_Get", utils.SerializeStr(params))

var wxMsg ReqWxMessage
err := c.BindXML(&wxMsg)
if err != nil {
fmt.Println("setTicket>>>>>>>>", err.Error())
}
utils.FilePutContents("SetTicket_XML", utils.SerializeStr(wxMsg))
c.String(http.StatusOK, "success")
return
}

func WechatMsgRecieve(c *gin.Context) {

return
}

+ 5
- 0
app/router/router.go View File

@@ -51,6 +51,11 @@ func Init() *gin.Engine {

func route(r *gin.RouterGroup) {
r.GET("/test", hdl.Demo)
wxOpenNotify := r.Group("/wxOpenNotify")
{
wxOpenNotify.Any("/:APPID/wechatMsgRecieve", hdl.WechatMsgRecieve)
wxOpenNotify.Any("/setTicket", hdl.SetTicket)
}

r.Use(mw.DB) // 以下接口需要用到数据库
{


+ 11
- 0
app/utils/file.go View File

@@ -1,11 +1,22 @@
package utils

import (
"os"
"path"
"strings"
"time"
)

// 获取文件后缀
func FileExt(fname string) string {
return strings.ToLower(strings.TrimLeft(path.Ext(fname), "."))
}

func FilePutContents(fileName string, content string) {
fd, _ := os.OpenFile("./tmp/"+fileName+".log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
fd_time := time.Now().Format("2006-01-02 15:04:05")
fd_content := strings.Join([]string{"[", fd_time, "] ", content, "\n"}, "")
buf := []byte(fd_content)
fd.Write(buf)
fd.Close()
}

Loading…
Cancel
Save