This commit is contained in:
suyl
2021-06-25 10:50:30 +08:00
parent 97cc8cce0d
commit e54e865ce5
2 changed files with 22 additions and 15 deletions

View File

@@ -1,11 +1,32 @@
package controllers
import "github.com/astaxie/beego/server/web"
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"

View File

@@ -1,21 +1,7 @@
package controllers
import "reflect"
type CallResult struct {
Code string `json:"code"`
Desc string `json:"desc"`
Data string `json:"data"`
}
//定义路由器结构类型
type Routers struct {
}
var (
routerMap map[string]reflect.Value
)
func Init() {
routerMap = make(map[string]reflect.Value)
}