|
@@ -2,11 +2,16 @@ package ureport
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
|
|
+ "git.qianqiusoft.com/public/glog"
|
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/entitys"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var _ureportHandlerMap map[string]func(ctx *entitys.CtrlContext)interface{} = make(map[string]func(ctx *entitys.CtrlContext)interface{})
|
|
var _ureportHandlerMap map[string]func(ctx *entitys.CtrlContext)interface{} = make(map[string]func(ctx *entitys.CtrlContext)interface{})
|
|
|
|
|
+var _ureportBeanFieldsHandlerMap map[string]func(ctx *entitys.CtrlContext)[]string = make(map[string]func(ctx *entitys.CtrlContext)[]string)
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief: register dataset handler
|
|
|
|
|
+ */
|
|
|
func RegisterUreportHandler(key string, handler func(ctx *entitys.CtrlContext)interface{}){
|
|
func RegisterUreportHandler(key string, handler func(ctx *entitys.CtrlContext)interface{}){
|
|
|
if handler == nil{
|
|
if handler == nil{
|
|
|
return
|
|
return
|
|
@@ -20,6 +25,22 @@ func RegisterUreportHandler(key string, handler func(ctx *entitys.CtrlContext)in
|
|
|
_ureportHandlerMap[key] = handler
|
|
_ureportHandlerMap[key] = handler
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief: register bean fields handler
|
|
|
|
|
+ */
|
|
|
|
|
+func RegisterUreportBeanFieldsHandler(class string, handler func(ctx *entitys.CtrlContext)[]string){
|
|
|
|
|
+ if handler == nil{
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if _, ok := _ureportBeanFieldsHandlerMap[class]; ok{
|
|
|
|
|
+ fmt.Println("---------------------->class is already exists")
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _ureportBeanFieldsHandlerMap[class] = handler
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
func CallUreportHanlder(ctx *entitys.CtrlContext){
|
|
func CallUreportHanlder(ctx *entitys.CtrlContext){
|
|
|
if _ureportHandlerMap == nil{
|
|
if _ureportHandlerMap == nil{
|
|
@@ -36,3 +57,27 @@ func CallUreportHanlder(ctx *entitys.CtrlContext){
|
|
|
ctx.Ctx.JSON(200, map[string]interface{}{"code": 500, "msg": "key is not exists", "data": nil})
|
|
ctx.Ctx.JSON(200, map[string]interface{}{"code": 500, "msg": "key is not exists", "data": nil})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func CallUreportBeanFieldsHandler(ctx *entitys.CtrlContext){
|
|
|
|
|
+ if _ureportBeanFieldsHandlerMap == nil{
|
|
|
|
|
+ fmt.Println("-------------------------bean fields handler is nil>")
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ class := ctx.Ctx.DefaultQuery("class", "")
|
|
|
|
|
+
|
|
|
|
|
+ if handler, ok := _ureportBeanFieldsHandlerMap[class]; ok{
|
|
|
|
|
+ ret := handler(ctx)
|
|
|
|
|
+ mapss := make([]map[string]string, 0)
|
|
|
|
|
+ for i := range ret{
|
|
|
|
|
+ mapss = append(mapss, map[string]string{
|
|
|
|
|
+ "name": ret[i],
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ glog.Infoln(mapss)
|
|
|
|
|
+ ctx.Ctx.JSON(200, mapss)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ glog.Infoln("there is not class bean fields handler", class)
|
|
|
|
|
+ ctx.Ctx.JSON(200, map[string]interface{}{"code": 500, "msg": "class is not exists", "data": nil})
|
|
|
|
|
+ }
|
|
|
|
|
+}
|