42 lines
958 B
Go
42 lines
958 B
Go
package controllers
|
|
|
|
import (
|
|
"github.com/astaxie/beego/server/web"
|
|
"reflect"
|
|
)
|
|
|
|
type ApiController struct {
|
|
web.Controller
|
|
}
|
|
|
|
var (
|
|
routerMap map[string]reflect.Value
|
|
)
|
|
|
|
func Init() {
|
|
routerMap = make(map[string]reflect.Value)
|
|
var ruTest ApiController
|
|
vf := reflect.ValueOf(&ruTest)
|
|
vft := vf.Type()
|
|
//读取方法数量
|
|
mNum := vf.NumMethod()
|
|
//遍历路由器的方法,并将其存入控制器映射变量中
|
|
for i := 0; i < mNum; i++ {
|
|
mName := vft.Method(i).Name
|
|
routerMap[mName] = vf.Method(i)
|
|
}
|
|
}
|
|
|
|
// @Title api调用入口
|
|
// @Description api调用入口
|
|
// @Param app_id formData string true "应用ID"
|
|
// @Param timestamp formData int true "unix时间戳"
|
|
// @Param sign formData string true "签名"
|
|
// @Param method formData string true "接口名"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /CallOpenAPI [post]
|
|
func (c *ApiController) CallOpenAPI() {
|
|
|
|
}
|