fix: 批量改进 (#2/#23/#38/#39/#40/#47)
- Web: 隐藏 ICP 备案号(条件渲染),联系入口改为微信咨询(条件渲染,配置 wechat 字段后生效) - backend: 拼音回填抽取为独立 cmd/backfill-pinyin 工具,不再在启动时运行 - backend: DB 连接池参数(max_idle_conns/max_open_conns)改为配置可控,默认 10/100 - backend: Inventory 反范式字段添加注释说明快照语义 - backend: 全量 handler 采用 util.RespondSuccess/RespondCreated 统一响应格式(51 处) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/wangjia/jiu/backend/internal/middleware"
|
||||
"github.com/wangjia/jiu/backend/internal/model"
|
||||
"github.com/wangjia/jiu/backend/internal/util"
|
||||
)
|
||||
|
||||
type UserHandler struct {
|
||||
@@ -25,7 +26,7 @@ func (h *UserHandler) List(c *gin.Context) {
|
||||
users := make([]model.User, 0)
|
||||
h.db.Where("shop_id = ? AND deleted_at IS NULL", shopID).
|
||||
Order("id ASC").Find(&users)
|
||||
c.JSON(http.StatusOK, gin.H{"data": users})
|
||||
util.RespondSuccess(c, users)
|
||||
}
|
||||
|
||||
// Create POST /api/v1/users
|
||||
@@ -64,7 +65,7 @@ func (h *UserHandler) Create(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "用户名已存在"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, gin.H{"data": u})
|
||||
util.RespondCreated(c, u)
|
||||
}
|
||||
|
||||
// Update PUT /api/v1/users/:id
|
||||
@@ -100,7 +101,7 @@ func (h *UserHandler) Update(c *gin.Context) {
|
||||
h.db.Model(&u).Where("shop_id = ?", shopID).Updates(updates)
|
||||
}
|
||||
h.db.Where("id = ? AND shop_id = ?", u.ID, shopID).First(&u)
|
||||
c.JSON(http.StatusOK, gin.H{"data": u})
|
||||
util.RespondSuccess(c, u)
|
||||
}
|
||||
|
||||
// ResetPassword PUT /api/v1/users/:id/reset-password
|
||||
|
||||
Reference in New Issue
Block a user