Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the request structure is a slice type structure, it is not bound to a value that meets the requirements. #3600

Closed
hanwei88 opened this issue May 23, 2024 · 2 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@hanwei88
Copy link

Go version

go1.22.2

GoFrame version

2.7.1

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

这是我的表单数据
fid: 4e10784edf8152456e033b19bc860afff6a81edd
lastModified: 1713916538703
name: 9105bc659eed9ac5362dd15bfaf6324.jpg
size: 4386224
type: image/jpeg
is_shard: true
is_allow_upload: false
shards[0][fid]: 861de0e4436ed111bc15c4b5b53e6e319a07a27b
shards[0][size]: 1048576
shards[0][num]: 0
shards[1][fid]: aee099b9bd5b95904b5cdfbc7ff8f3c9919c515d
shards[1][size]: 1048576
shards[1][num]: 1
shards[2][fid]: a0f756c9ca8769e999f773b84add5954e6ad0274
shards[2][size]: 1048576
shards[2][num]: 2
shards[3][fid]: 3f440ee9ed8120f0ec94c81edee4ef01c2565481
shards[3][size]: 1048576
shards[3][num]: 3
shards[4][fid]: 6145e3f801f5fa0ba287a5e778b5e0f40dc204ce
shards[4][size]: 191920
shards[4][num]: 4

这是我的请求结构体
type FileSaveReq struct {
g.Meta path:"/file/test" method:"POST"
Fid string json:"fid"
Type string json:"type"
Name string json:"name"
Shards []*Shard json:"shards"
LastModified int64 json:"lastModified"
Size int64 json:"size"
IsShard bool json:"is_shard"
}

type Shard struct {
Fid string json:"fid"
Size int64 json:"size"
Num int64 json:"num"
}

绑定的值是这样的
image

What did you see happen?

.

What did you expect to see?

我期待能够正确绑定到值

@hanwei88 hanwei88 added the bug It is confirmed a bug, but don't worry, we'll handle it. label May 23, 2024
@Issues-translate-bot Issues-translate-bot changed the title 请求结构体如果是切片类型的结构体没有绑定到符合要求值 If the request structure is a slice type structure, it is not bound to a value that meets the requirements. May 23, 2024
@hanwei88
Copy link
Author

加个中间件将那个值map[string]map[string]interface{}改成[]map[string]interface{} 就可以正常绑定到值

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Add a middleware and change the value map[string]map[string]interface{} to []map[string]interface{} to bind to the value normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

2 participants