package controllers import ( constd "apigame/service/constd" "apigame/sign" "github.com/astaxie/beego" ) type BaseController struct { beego.Controller } // RetData 返回封装 func (c *BaseController) RetData(resp map[string]interface{}) { c.Data["json"] = resp c.ServeJSON() } // GetPostData 获取 PostData func (c *BaseController) GetPostData(postData any) bool { // 接收参数,验证签名登录 code, err := sign.Check(c.Ctx.Input.RequestBody, &postData, true, true) if err != nil { resp := make(map[string]interface{}) resp = constd.CodeMsg(resp, code) c.RetData(resp) return false } return true }