瀏覽代碼

update

master
dengbiao 4 月之前
父節點
當前提交
c3870810a0
共有 3 個檔案被更改,包括 50 行新增0 行删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存