fix: add form tags to batch update request struct

This commit is contained in:
root 2026-04-27 09:55:18 +08:00
parent 3f80e0e417
commit d2b35f9fc4
2 changed files with 6 additions and 5 deletions

View file

@ -13,10 +13,11 @@ Change Type: Fix
## Changes
- `web/controller/inbound.go:481`: `c.ShouldBindJSON(&request)``c.ShouldBind(&request)`
- `web/controller/inbound.go:477-479`: 为匿名结构体字段添加 `form` 标签,确保 form 绑定能正确映射字段名(`shouldBind` 使用 `form` 标签而非 `json` 标签进行 form 字段映射)
## Impact
- `ShouldBind` 会根据 Content-Type 自动选择 form 绑定(浏览器请求)或 JSON 绑定(其他客户端),与项目其他 handler 一致
- 向后兼容JSON 请求依然能被正确解析
- 向后兼容JSON 请求依然能被正确解析`json` 标签仍保留)
- 不影响数据库、API、配置
## Verification
@ -24,4 +25,4 @@ Change Type: Fix
- `go vet ./web/controller/...` — 通过
## Risks And Follow-Up
- 低风险,单行变更,与项目现有代码风格一致
- 低风险,与项目现有代码风格一致model 中所有 struct 字段均同时携带 `json``form` 标签)

View file

@ -474,9 +474,9 @@ func (a *InboundController) delInboundClientByEmail(c *gin.Context) {
// batchUpdateInboundClients updates multiple clients in an inbound with the same field changes.
func (a *InboundController) batchUpdateInboundClients(c *gin.Context) {
var request struct {
InboundID int `json:"inboundId"`
ClientIDs []string `json:"clientIds"`
UpdateFields string `json:"updateFields"`
InboundID int `json:"inboundId" form:"inboundId"`
ClientIDs []string `json:"clientIds" form:"clientIds"`
UpdateFields string `json:"updateFields" form:"updateFields"`
}
if err := c.ShouldBind(&request); err != nil {
jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)