mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-08 14:14:19 +00:00
fix: add form tags to batch update request struct
This commit is contained in:
parent
3f80e0e417
commit
d2b35f9fc4
2 changed files with 6 additions and 5 deletions
|
|
@ -13,10 +13,11 @@ Change Type: Fix
|
||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
- `web/controller/inbound.go:481`: `c.ShouldBindJSON(&request)` → `c.ShouldBind(&request)`
|
- `web/controller/inbound.go:481`: `c.ShouldBindJSON(&request)` → `c.ShouldBind(&request)`
|
||||||
|
- `web/controller/inbound.go:477-479`: 为匿名结构体字段添加 `form` 标签,确保 form 绑定能正确映射字段名(`shouldBind` 使用 `form` 标签而非 `json` 标签进行 form 字段映射)
|
||||||
|
|
||||||
## Impact
|
## Impact
|
||||||
- `ShouldBind` 会根据 Content-Type 自动选择 form 绑定(浏览器请求)或 JSON 绑定(其他客户端),与项目其他 handler 一致
|
- `ShouldBind` 会根据 Content-Type 自动选择 form 绑定(浏览器请求)或 JSON 绑定(其他客户端),与项目其他 handler 一致
|
||||||
- 向后兼容:JSON 请求依然能被正确解析
|
- 向后兼容:JSON 请求依然能被正确解析(`json` 标签仍保留)
|
||||||
- 不影响数据库、API、配置
|
- 不影响数据库、API、配置
|
||||||
|
|
||||||
## Verification
|
## Verification
|
||||||
|
|
@ -24,4 +25,4 @@ Change Type: Fix
|
||||||
- `go vet ./web/controller/...` — 通过
|
- `go vet ./web/controller/...` — 通过
|
||||||
|
|
||||||
## Risks And Follow-Up
|
## Risks And Follow-Up
|
||||||
- 低风险,单行变更,与项目现有代码风格一致
|
- 低风险,与项目现有代码风格一致(model 中所有 struct 字段均同时携带 `json` 和 `form` 标签)
|
||||||
|
|
|
||||||
|
|
@ -474,9 +474,9 @@ func (a *InboundController) delInboundClientByEmail(c *gin.Context) {
|
||||||
// batchUpdateInboundClients updates multiple clients in an inbound with the same field changes.
|
// batchUpdateInboundClients updates multiple clients in an inbound with the same field changes.
|
||||||
func (a *InboundController) batchUpdateInboundClients(c *gin.Context) {
|
func (a *InboundController) batchUpdateInboundClients(c *gin.Context) {
|
||||||
var request struct {
|
var request struct {
|
||||||
InboundID int `json:"inboundId"`
|
InboundID int `json:"inboundId" form:"inboundId"`
|
||||||
ClientIDs []string `json:"clientIds"`
|
ClientIDs []string `json:"clientIds" form:"clientIds"`
|
||||||
UpdateFields string `json:"updateFields"`
|
UpdateFields string `json:"updateFields" form:"updateFields"`
|
||||||
}
|
}
|
||||||
if err := c.ShouldBind(&request); err != nil {
|
if err := c.ShouldBind(&request); err != nil {
|
||||||
jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue