50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package controllers
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.rosy.net.cn/baseapi/platform/elmapi"
|
|
"git.rosy.net.cn/jx-callback/business/elm/controller"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
"github.com/astaxie/beego"
|
|
)
|
|
|
|
// Operations about ELMOrder
|
|
type ELMOrderController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
func (c *ELMOrderController) URLMapping() {
|
|
c.Mapping("MsgPost", c.MsgPost)
|
|
c.Mapping("MsgGet", c.MsgGet)
|
|
}
|
|
|
|
// @Title all msg
|
|
// @Description create object
|
|
// @Success 200 {string} models.Object.Id
|
|
// @Failure 403 body is empty
|
|
// @router /msg [post]
|
|
func (c *ELMOrderController) MsgPost() {
|
|
var obj elmapi.ELMCallbackMsg
|
|
jdParamJSON := c.Ctx.Input.RequestBody
|
|
|
|
err := json.Unmarshal([]byte(jdParamJSON), &obj)
|
|
if err != nil {
|
|
globals.SugarLogger.Warnf("error when Unmarshal data:%v, error:%v", jdParamJSON, err)
|
|
c.Data["json"] = elmapi.ELMCallbackResponse{Message: "failed"}
|
|
} else {
|
|
cc := &controller.OrderController{}
|
|
c.Data["json"] = cc.OrderMessage(&obj)
|
|
}
|
|
c.ServeJSON()
|
|
}
|
|
|
|
// @Title all msg test
|
|
// @Description create object
|
|
// @Success 200 {string} models.Object.Id
|
|
// @router /msg [get]
|
|
func (c *ELMOrderController) MsgGet() {
|
|
c.Data["json"] = elmapi.ELMResponseOK
|
|
c.ServeJSON()
|
|
}
|