parent
2ebbf46432
commit
324f577dc5
@ -0,0 +1,43 @@
|
|||||||
|
package control
|
||||||
|
|
||||||
|
import (
|
||||||
|
"call-back-http/model"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CallbackBeforeSendSingleMsgCommand(c *gin.Context) {
|
||||||
|
var req model.CallbackBeforeSendSingleMsgReq
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
fmt.Printf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Printf("CallbackBeforeSendSingleMsgCommand received:%#v\n", req)
|
||||||
|
str := "callback return message"
|
||||||
|
byte, err := json.Marshal(str)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, &model.CallbackBeforeSendSingleMsgResp{
|
||||||
|
CommonCallbackResp: model.CommonCallbackResp{
|
||||||
|
ActionCode: 500,
|
||||||
|
ErrCode: 5001,
|
||||||
|
ErrMsg: "callback error",
|
||||||
|
ErrDlt: err.Error(),
|
||||||
|
NextCode: 2,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
resp := &model.CallbackBeforeSendSingleMsgResp{
|
||||||
|
CommonCallbackResp: model.CommonCallbackResp{
|
||||||
|
ActionCode: 0,
|
||||||
|
ErrCode: 2000,
|
||||||
|
ErrMsg: "Success",
|
||||||
|
ErrDlt: "Successful",
|
||||||
|
NextCode: 2,
|
||||||
|
},
|
||||||
|
Content: byte,
|
||||||
|
}
|
||||||
|
fmt.Printf("CallbackBeforeSendSingleMsgCommand return:%#v\n", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
module call-back-http
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require github.com/gin-gonic/gin v1.9.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/bytedance/sonic v1.9.1 // indirect
|
||||||
|
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||||
|
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||||
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
||||||
|
github.com/goccy/go-json v0.10.2 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||||
|
github.com/leodido/go-urn v1.2.4 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
|
||||||
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||||
|
golang.org/x/arch v0.3.0 // indirect
|
||||||
|
golang.org/x/crypto v0.9.0 // indirect
|
||||||
|
golang.org/x/net v0.10.0 // indirect
|
||||||
|
golang.org/x/sys v0.8.0 // indirect
|
||||||
|
golang.org/x/text v0.9.0 // indirect
|
||||||
|
google.golang.org/protobuf v1.30.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"call-back-http/control"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
engine := gin.Default()
|
||||||
|
router := engine.Group("/callback")
|
||||||
|
router.POST("/callbackBeforeSendSingleMsgCommand", control.CallbackBeforeSendSingleMsgCommand)
|
||||||
|
|
||||||
|
if err := engine.Run("0.0.0.0:18889"); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
|
||||||
|
type CommonCallbackReq struct {
|
||||||
|
SendID string `json:"sendID"`
|
||||||
|
CallbackCommand string `json:"callbackCommand"`
|
||||||
|
ServerMsgID string `json:"serverMsgID"`
|
||||||
|
ClientMsgID string `json:"clientMsgID"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||||
|
SenderNickname string `json:"senderNickname"`
|
||||||
|
SessionType int32 `json:"sessionType"`
|
||||||
|
MsgFrom int32 `json:"msgFrom"`
|
||||||
|
ContentType int32 `json:"contentType"`
|
||||||
|
Status int32 `json:"status"`
|
||||||
|
CreateTime int64 `json:"createTime"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
Seq uint32 `json:"seq"`
|
||||||
|
AtUserIDList []string `json:"atUserList"`
|
||||||
|
SenderFaceURL string `json:"faceURL"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackBeforeSendSingleMsgReq struct {
|
||||||
|
CommonCallbackReq
|
||||||
|
RecvID string `json:"recvID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackBeforeSendSingleMsgResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
Content []byte `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CommonCallbackResp struct {
|
||||||
|
ActionCode int32 `json:"actionCode"`
|
||||||
|
ErrCode int32 ` json:"errCode"`
|
||||||
|
ErrMsg string ` json:"errMsg"`
|
||||||
|
ErrDlt string `json:"errDlt"`
|
||||||
|
NextCode int32 `json:"nextCode"`
|
||||||
|
}
|
Loading…
Reference in new issue