Files
jx-callback/controllers/elm_order.go
gazebo b69bac1182 - use auto router for callback msg.
- first normal demo api FinishedPickup added.
2018-08-20 15:08:36 +08:00

33 lines
951 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controllers
import (
"net/http"
"git.rosy.net.cn/baseapi/platformapi/elmapi"
"git.rosy.net.cn/jx-callback/business/partner/purchase/elm"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego"
)
// Operations about ELMOrder
type ElemeController struct {
beego.Controller
}
// https://open.shop.ele.me/openapi/documents/httppushmethod
func (c *ElemeController) Msg() {
if c.Ctx.Input.Method() == http.MethodPost {
obj, callbackResponse := api.ElmAPI.GetCallbackMsg(c.Ctx.Input.RequestBody)
if callbackResponse == nil {
callbackResponse = elm.OnCallbackMsg(obj)
}
c.Data["json"] = callbackResponse
c.ServeJSON()
} else if c.Ctx.Input.Method() == http.MethodGet { // 应用需要支持推送地址的GET访问当GET请求访问时请直接返回{“message”:“ok”},用于推送地址的可用性测试。
c.Data["json"] = elmapi.SuccessResponse
c.ServeJSON()
} else {
c.Abort("404")
}
}