aa
This commit is contained in:
@@ -1,11 +1,32 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import "github.com/astaxie/beego/server/web"
|
import (
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
type ApiController struct {
|
type ApiController struct {
|
||||||
web.Controller
|
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调用入口
|
// @Title api调用入口
|
||||||
// @Description api调用入口
|
// @Description api调用入口
|
||||||
// @Param app_id formData string true "应用ID"
|
// @Param app_id formData string true "应用ID"
|
||||||
|
|||||||
@@ -1,21 +1,7 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import "reflect"
|
|
||||||
|
|
||||||
type CallResult struct {
|
type CallResult struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
Desc string `json:"desc"`
|
Desc string `json:"desc"`
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//定义路由器结构类型
|
|
||||||
type Routers struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
routerMap map[string]reflect.Value
|
|
||||||
)
|
|
||||||
|
|
||||||
func Init() {
|
|
||||||
routerMap = make(map[string]reflect.Value)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user