fix(agent): 修复资产重复注册(每10s新建) + 批量删除400
agent 自动注册前按 hostname 显式查重(asset_servers.hostname 无 UNIQUE 索引,OnConflict 失效导致 Agent 每次上报都 INSERT 新记录,资产越来越多)。
批量删除 BatchDeleteServers 对齐前端 {ids} 格式(原期望裸 []uint 导致 ShouldBindJSON 解析失败 400)。
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
f820f0271f
commit
b7780c5a5a
2 files changed
+51
-33
No files matched your search
@@ -169,11 +169,15 @@ func (h *ServerHandlerV2) BatchCreateServers(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *ServerHandlerV2) BatchDeleteServers(c *gin.Context) {
|
||||
var ids []uint
|
||||
if err := c.ShouldBindJSON(&ids); err != nil {
|
||||
// 前端发 { ids: [...] },对齐格式(原期望裸 []uint 导致解析失败 400) // Logan.Li
|
||||
var req struct {
|
||||
IDs []uint `json:"ids"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil || len(req.IDs) == 0 {
|
||||
utils.BadRequest(c, "请求参数错误")
|
||||
return
|
||||
}
|
||||
ids := req.IDs
|
||||
// 清理关联数据
|
||||
for _, id := range ids {
|
||||
var s model.Server
|
||||
|
||||
Reference in new issue
Block a user