package controllers

import (
	"net/http"

	"git.rosy.net.cn/baseapi/platformapi/elmapi"
	"github.com/astaxie/beego/server/web"
)

// Operations about ELMOrder
type ElemeController struct {
	web.Controller
}

// https://open.shop.ele.me/openapi/documents/httppushmethod
func (c *ElemeController) Msg() {
	if c.Ctx.Input.Method() == http.MethodPost {
		callbackResponse := elmapi.SuccessResponse
		// 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")
	}
}
