Browse Source

ureport bean fields api

huangrf 5 years ago
parent
commit
d7959acd72

+ 12 - 0
controllers/gen/SysPublicController_gen.go

@@ -109,3 +109,15 @@ func (c *SysPublicController) Ureport(ctx *gin.Context) {
 	partial.SysPublic_Ureport(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
 	partial.SysPublic_Ureport(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
 }
 }
 
 
+// UreportFields
+// @Title UreportFields
+// @Description 报表bean字段列表         
+// @Success 200 {object} sysReturn
+// @Failure 403 :id is empty
+// @router /ureport_fields  [get]
+func (c *SysPublicController) UreportFields(ctx *gin.Context) {
+	//
+	db:=c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
+	partial.SysPublic_UreportFields(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
+}
+

+ 10 - 0
controllers/partial/SysPublicController.go

@@ -171,6 +171,16 @@ func SysPublic_Ureport(c *entitys.CtrlContext) {
 }
 }
 
 
 
 
+// _UreportFields
+// @Title _UreportFields
+// @Description 报表bean字段列表
+// @Success 200 {object} Account
+// @Failure 403 :id is empty
+func SysPublic_UreportFields(c *entitys.CtrlContext) {
+	ureport.CallUreportBeanFieldsHandler(c)
+}
+
+
 func __none_func_sys_public__(params ... interface{}) bool{
 func __none_func_sys_public__(params ... interface{}) bool{
 	return true
 	return true
 }
 }

+ 2 - 0
light-apiengine.xml

@@ -901,6 +901,8 @@
             </api>
             </api>
             <api name="ureport" desc="报表统一接口" method="get">
             <api name="ureport" desc="报表统一接口" method="get">
             </api>
             </api>
+            <api name="ureport_fields" desc="报表bean字段列表" method="get">
+            </api>
         </controller>
         </controller>
 	</controllers>
 	</controllers>
     <beans>
     <beans>

+ 45 - 0
third/ureport/ureport.go

@@ -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})
+	}
+}