fix: 批量修复功能问题 - 购物车结算/订单库存积分/搜索/抽奖/个人资料等

This commit is contained in:
2026-05-26 09:27:20 +08:00
parent 760f67c925
commit 012ec873ec
14 changed files with 308 additions and 39 deletions
+24 -5
View File
@@ -27,7 +27,7 @@ func (h *BrandHandler) Create(c *gin.Context) {
return
}
utils.DB.Create(&brand)
c.JSON(http.StatusOK, brand)
c.JSON(http.StatusOK, gin.H{"data": brand})
}
func (h *BrandHandler) Update(c *gin.Context) {
@@ -37,13 +37,32 @@ func (h *BrandHandler) Update(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{"error": "Brand not found"})
return
}
var input models.Brand
if err := c.ShouldBindJSON(&input); err != nil {
var req struct {
Name *string `json:"name"`
Icon *string `json:"icon"`
Info *string `json:"info"`
SortOrder *int `json:"sort_order"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
utils.DB.Model(&brand).Updates(input)
c.JSON(http.StatusOK, brand)
updates := make(map[string]interface{})
if req.Name != nil {
updates["name"] = *req.Name
}
if req.Icon != nil {
updates["icon"] = *req.Icon
}
if req.Info != nil {
updates["info"] = *req.Info
}
if req.SortOrder != nil {
updates["sort_order"] = *req.SortOrder
}
utils.DB.Model(&brand).Updates(updates)
utils.DB.First(&brand, brand.ID)
c.JSON(http.StatusOK, gin.H{"data": brand})
}
func (h *BrandHandler) Delete(c *gin.Context) {