Skip to content

Commit 37b7ab2

Browse files
committed
just query ok
1 parent 0651e60 commit 37b7ab2

File tree

8 files changed

+65
-9
lines changed

8 files changed

+65
-9
lines changed

apijson.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (a *ApiJson) Use(p ...func(ctx context.Context, a *ApiJson)) *ApiJson {
4646
}
4747

4848
func (a *ApiJson) Load() {
49-
49+
a.config.Load()
5050
}
5151

5252
func (a *ApiJson) Config() *config.Config {

config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ func New() *Config {
3939

4040
return a
4141
}
42+
43+
func (c *Config) Load() {
44+
45+
c.Access.accessConfigMap = make(map[string]AccessConfig)
46+
47+
for _, access := range c.AccessList {
48+
c.Access.accessConfigMap[access.Alias] = access
49+
}
50+
}

query/node.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const (
2222
NodeTypeFunc // functions 节点
2323
)
2424

25+
type nodeHandler interface {
26+
parse()
27+
fetch()
28+
result()
29+
nodeType() int
30+
}
31+
2532
type Node struct {
2633
ctx context.Context
2734
queryContext *Query
@@ -64,6 +71,8 @@ type Node struct {
6471

6572
total int64 // 数据总条数
6673
needTotal bool
74+
75+
nodeHandler nodeHandler
6776
}
6877

6978
// NodeRef 节点依赖引用
@@ -222,7 +231,7 @@ func (n *Node) parse() {
222231
return
223232
}
224233

225-
if n.queryContext.NoAccessVerify != false {
234+
if n.queryContext.NoAccessVerify == false {
226235
has, condition, err := hasAccess(n, tableKey)
227236
if err != nil {
228237
n.err = err

query/node_func.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package query

query/node_query.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package query
2+
3+
type queryNode struct {
4+
node *Node
5+
}
6+
7+
func newQueryNode(n *Node) queryNode {
8+
return queryNode{node: n}
9+
}
10+
11+
func (q *queryNode) parse() {
12+
13+
}
14+
15+
func (q *queryNode) fetch() {
16+
17+
}
18+
19+
func (q *queryNode) result() {
20+
21+
}
22+
23+
func (q *queryNode) nodeType() int {
24+
return NodeTypeQuery
25+
}

query/node_ref.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package query

query/node_struct.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package query

test/z_main_test.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
_ "github.com/gogf/gf/contrib/drivers/sqlite/v2" // need import for sqlite
1212
"github.com/gogf/gf/v2/frame/g"
1313
"github.com/gogf/gf/v2/os/gctx"
14+
"log"
1415
"strings"
1516
"testing"
1617
)
@@ -61,6 +62,14 @@ func init() {
6162
}
6263

6364
a.Config().AccessList = accessList
65+
a.Config().AccessList = []config.AccessConfig{
66+
{
67+
Name: "user",
68+
Alias: "User",
69+
Get: []string{"UNKNOWN"},
70+
RowKey: "id",
71+
},
72+
}
6473

6574
// request
6675
var requestList []config.Request
@@ -113,26 +122,27 @@ func TestQuery(t *testing.T) {
113122

114123
ctx := gctx.New()
115124
q := query.New(ctx, model.Map{
116-
"user": model.Map{
125+
"User": model.Map{
117126
"id": "123",
118127
"id{}": []string{"123", "456"},
119128
"id>": "222",
120-
"@column": "id,userId",
129+
"@column": "id",
121130
},
122-
"user[]": model.Map{
131+
"User[]": model.Map{
132+
"@column": "id",
123133
//"userId": "123",
124134
},
125-
//"t_todo": model.Map{},
126-
//"_access": model.Map{},
127135
})
128136

129-
q.NoAccessVerify = true //config.AccessVerify
137+
q.NoAccessVerify = true
130138
q.Access = a.Config().Access
139+
q.Access.NoVerify = true
140+
q.Config = a.Config()
131141

132142
result, err := q.Result()
133143

134144
if err != nil {
135-
panic(err)
145+
log.Fatalf("%+v", err)
136146
}
137147

138148
g.Dump(result)

0 commit comments

Comments
 (0)