@@ -3,9 +3,7 @@ package action
33import (
44 "context"
55 "github.com/glennliao/apijson-go/config"
6- "github.com/glennliao/apijson-go/config/db"
76 "github.com/glennliao/apijson-go/config/executor"
8- "github.com/glennliao/apijson-go/config/functions"
97 "github.com/glennliao/apijson-go/consts"
108 "github.com/glennliao/apijson-go/model"
119 "github.com/glennliao/apijson-go/util"
@@ -27,15 +25,15 @@ type Node struct {
2725 Where []model.Map // 条件
2826 RowKey string // 主键
2927
30- structure * db .Structure
28+ structure * config .Structure
3129 executor string
3230
3331 keyNode map [string ]* Node
3432
3533 access * config.Access
3634}
3735
38- func newNode (key string , req []model.Map , structure * db .Structure , executor string ) Node {
36+ func newNode (key string , req []model.Map , structure * config .Structure , executor string ) Node {
3937 return Node {
4038 Key : key , req : req , structure : structure , executor : executor ,
4139 }
@@ -54,7 +52,7 @@ func (n *Node) parseReq(method string) {
5452 if key == consts .Role {
5553 n .Role = util .String (val )
5654 } else {
57- key = config . GetDbFieldStyle () (n .ctx , n .TableName , key )
55+ key = n . action . DbFieldStyle (n .ctx , n .TableName , key )
5856
5957 if method == http .MethodDelete {
6058 n.Where [i ][key ] = val
@@ -82,7 +80,7 @@ func (n *Node) parse(ctx context.Context, method string) error {
8280 if strings .HasSuffix (key , consts .ListKeySuffix ) {
8381 key = key [0 : len (key )- 2 ]
8482 }
85- access , err := db .GetAccess (key , true )
83+ access , err := n . access .GetAccess (key , true )
8684
8785 if err != nil {
8886 return err
@@ -245,7 +243,7 @@ func (n *Node) reqUpdate() error {
245243 }
246244 }
247245 k := key [0 : len (key )- 2 ]
248- val , err := functions .Call (n .ctx , functionName , param )
246+ val , err := n . action . Functions .Call (n .ctx , functionName , param )
249247 if err != nil {
250248 return err
251249 }
@@ -278,9 +276,9 @@ func (n *Node) reqUpdateBeforeDo() error {
278276 if strings .HasSuffix (k , consts .RefKeySuffix ) {
279277 refNodeKey , refCol := util .ParseRefCol (v .(string ))
280278 if strings .HasSuffix (refNodeKey , consts .ListKeySuffix ) { // 双列表
281- n.Data [i ][k ] = n .keyNode [refNodeKey ].Data [i ][config . GetDbFieldStyle () (n .ctx , n .TableName , refCol )]
279+ n.Data [i ][k ] = n .keyNode [refNodeKey ].Data [i ][n . action . DbFieldStyle (n .ctx , n .TableName , refCol )]
282280 } else {
283- n.Data [i ][k ] = n .keyNode [refNodeKey ].Data [0 ][config . GetDbFieldStyle () (n .ctx , n .TableName , refCol )]
281+ n.Data [i ][k ] = n .keyNode [refNodeKey ].Data [0 ][n . action . DbFieldStyle (n .ctx , n .TableName , refCol )]
284282 }
285283 }
286284 }
@@ -303,7 +301,7 @@ func (n *Node) do(ctx context.Context, method string, dataIndex int) (ret model.
303301
304302 var rowKeyVal model.Map
305303
306- access , err := db .GetAccess (n .Key , true )
304+ access , err := n . access .GetAccess (n .Key , true )
307305 if err != nil {
308306 return nil , err
309307 }
@@ -343,7 +341,7 @@ func (n *Node) do(ctx context.Context, method string, dataIndex int) (ret model.
343341
344342 if len (n .Data ) > 0 { //多条插入时返回值已经应该无意义了
345343
346- jsonStyle := config . GetJsonFieldStyle ()
344+ jsonStyle := n . action . JsonFieldStyle
347345 if rowKeyVal != nil {
348346 for k , v := range rowKeyVal {
349347 if k == consts .RowKey {
0 commit comments