|
|
@@ -2,6 +2,7 @@ package controllers
|
|
|
|
|
|
import (
|
|
|
"github.com/kataras/iris/v12/mvc"
|
|
|
+ "xps/cache"
|
|
|
"xps/service"
|
|
|
)
|
|
|
|
|
|
@@ -11,8 +12,10 @@ type DbController struct {
|
|
|
}
|
|
|
|
|
|
func (c *DbController) BeforeActivation(b mvc.BeforeActivation) {
|
|
|
- b.Handle("GET", "/{objectCode:string}", "GetList" )
|
|
|
- b.Handle("GET", "/{objectCode:string}/page","GetPage" )
|
|
|
+ b.Handle("GET", "/table/{objectCode:string}", "GetList" )
|
|
|
+ b.Handle("GET", "/table/{objectCode:string}/page", "GetPage" )
|
|
|
+ b.Handle("GET", "/table/{objectCode:string}/fields", "GetFields" )
|
|
|
+
|
|
|
}
|
|
|
|
|
|
func (c *DbController) GetList(objectCode string) *JsonResult {
|
|
|
@@ -31,4 +34,13 @@ func (c *DbController) GetPage(objectCode string) *JsonResult {
|
|
|
} else {
|
|
|
return ResultOk("获取成功", data)
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+func (c *DbController) GetFields(objectCode string) *JsonResult {
|
|
|
+ attrs, err := cache.GetModelObjectAttrs(objectCode)
|
|
|
+ if err != nil {
|
|
|
+ return ResultErr(err.Error(), nil)
|
|
|
+ } else {
|
|
|
+ return ResultOk("获取成功", attrs)
|
|
|
+ }
|
|
|
}
|