1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package server
- import (
- "encoding/json"
- "github.com/gin-gonic/gin"
- "kpt.notice/apiserver/model/http"
- )
- //消息存储
- func postMessage(c *gin.Context) {
- // body, err := ioutil.ReadAll(c.Request.Body)
- // log.Infof("postMessage body: %s", string(body))
- // if err != nil {
- // eJSON(c, nil, err)
- // }
- msgReq := new(http.MessageReq)
- if !Bind(c, msgReq) {
- return
- }
- body, err := json.Marshal(msgReq)
- if err != nil {
- eJSON(c, nil, err)
- }
- resp, err := svc.InsertMessage(msgReq, body)
- eJSON(c, resp, err)
- }
- // save message type
- func postMsgType(c *gin.Context) {
- msgTypeReq := new(http.MessageTypeReq)
- if !Bind(c, msgTypeReq) {
- return
- }
- resp, err := svc.InsertMsgType(msgTypeReq)
- eJSON(c, resp, err)
- }
- // get all message type
- func getMsgType(c *gin.Context) {
- req := new(http.MessageTypeReq)
- if !Bind(c, req) {
- return
- }
- res, err := svc.QueryMsgType(req)
- eJSON(c, res, err)
- }
- func handleMessage(c *gin.Context) {
- responseXML := svc.HandleMessage(c)
- c.Data(200, "application/xml", responseXML)
- }
- func handleVerification(c *gin.Context) {
- res, echostr := svc.HandleVerification(c)
- if res {
- c.String(200, echostr)
- } else {
- c.String(401, "Invalid signature")
- }
- }
|