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:
wangjia
2026-06-11 09:33:43 +08:00
parent d28aba863e
commit e0bee00ff4
21 changed files with 144 additions and 89 deletions
+10 -9
View File
@@ -8,6 +8,7 @@ import (
"github.com/wangjia/jiu/backend/internal/middleware"
"github.com/wangjia/jiu/backend/internal/model"
"github.com/wangjia/jiu/backend/internal/util"
)
type ProductOptionHandler struct {
@@ -24,7 +25,7 @@ func (h *ProductOptionHandler) ListNames(c *gin.Context) {
shopID := middleware.GetShopID(c)
items := make([]model.ProductNameOption, 0)
h.db.Where("shop_id = ?", shopID).Order("id ASC").Find(&items)
c.JSON(http.StatusOK, gin.H{"data": items})
util.RespondSuccess(c, items)
}
func (h *ProductOptionHandler) CreateName(c *gin.Context) {
@@ -48,7 +49,7 @@ func (h *ProductOptionHandler) CreateName(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, gin.H{"data": item})
util.RespondCreated(c, item)
}
func (h *ProductOptionHandler) UpdateName(c *gin.Context) {
@@ -70,7 +71,7 @@ func (h *ProductOptionHandler) UpdateName(c *gin.Context) {
h.db.Model(&item).Where("shop_id = ?", shopID).Updates(map[string]interface{}{
"code": req.Code, "name": req.Name, "remark": req.Remark,
})
c.JSON(http.StatusOK, gin.H{"data": item})
util.RespondSuccess(c, item)
}
func (h *ProductOptionHandler) DeleteName(c *gin.Context) {
@@ -85,7 +86,7 @@ func (h *ProductOptionHandler) ListSeries(c *gin.Context) {
shopID := middleware.GetShopID(c)
items := make([]model.ProductSeriesOption, 0)
h.db.Where("shop_id = ?", shopID).Order("id ASC").Find(&items)
c.JSON(http.StatusOK, gin.H{"data": items})
util.RespondSuccess(c, items)
}
func (h *ProductOptionHandler) CreateSeries(c *gin.Context) {
@@ -109,7 +110,7 @@ func (h *ProductOptionHandler) CreateSeries(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, gin.H{"data": item})
util.RespondCreated(c, item)
}
func (h *ProductOptionHandler) UpdateSeries(c *gin.Context) {
@@ -131,7 +132,7 @@ func (h *ProductOptionHandler) UpdateSeries(c *gin.Context) {
h.db.Model(&item).Where("shop_id = ?", shopID).Updates(map[string]interface{}{
"code": req.Code, "name": req.Name, "remark": req.Remark,
})
c.JSON(http.StatusOK, gin.H{"data": item})
util.RespondSuccess(c, item)
}
func (h *ProductOptionHandler) DeleteSeries(c *gin.Context) {
@@ -146,7 +147,7 @@ func (h *ProductOptionHandler) ListSpecs(c *gin.Context) {
shopID := middleware.GetShopID(c)
items := make([]model.ProductSpecOption, 0)
h.db.Where("shop_id = ?", shopID).Order("id ASC").Find(&items)
c.JSON(http.StatusOK, gin.H{"data": items})
util.RespondSuccess(c, items)
}
func (h *ProductOptionHandler) CreateSpec(c *gin.Context) {
@@ -172,7 +173,7 @@ func (h *ProductOptionHandler) CreateSpec(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, gin.H{"data": item})
util.RespondCreated(c, item)
}
func (h *ProductOptionHandler) UpdateSpec(c *gin.Context) {
@@ -195,7 +196,7 @@ func (h *ProductOptionHandler) UpdateSpec(c *gin.Context) {
h.db.Model(&item).Where("shop_id = ?", shopID).Updates(map[string]interface{}{
"code": req.Code, "name": req.Name, "quantity": req.Quantity, "remark": req.Remark,
})
c.JSON(http.StatusOK, gin.H{"data": item})
util.RespondSuccess(c, item)
}
func (h *ProductOptionHandler) DeleteSpec(c *gin.Context) {