fix(backend): JWT config mapstructure tag 修复 + 模型从 hotel 重构为 shop
- 修复 JWTConfig 缺少 mapstructure tag 导致 access_expire_min 解析为 0, token 签发即过期,所有 API 请求返回 401 - 全部 config struct 补齐 mapstructure tag(secret/dsn/hmac_secret 等) - 模型层从 hotel/HotelID 统一重命名为 shop/ShopID - 删除旧 migrations(001-004),新增 001_init 综合迁移文件 - 更新 schema.sql、testutil、handler/service/model 相关引用 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,9 +21,9 @@ func NewImportHandler(db *gorm.DB) *ImportHandler {
|
||||
}
|
||||
|
||||
// ImportProducts POST /api/v1/import/products
|
||||
// 支持 .xlsx / .csv,列顺序:名称,系列,规格,单位,品牌,进价,售价,最低库存,备注
|
||||
// 支持 .xlsx / .csv,列顺序:名称,系列,规格,单位,品牌,最低库存,备注
|
||||
func (h *ImportHandler) ImportProducts(c *gin.Context) {
|
||||
hotelID := middleware.GetHotelID(c)
|
||||
shopID := middleware.GetShopID(c)
|
||||
|
||||
file, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
@@ -59,14 +59,14 @@ func (h *ImportHandler) ImportProducts(c *gin.Context) {
|
||||
continue
|
||||
}
|
||||
p := model.Product{
|
||||
TenantBase: model.TenantBase{HotelID: hotelID},
|
||||
TenantBase: model.TenantBase{ShopID: shopID},
|
||||
}
|
||||
p.Name = cell(row, 0)
|
||||
p.Series = cell(row, 1)
|
||||
p.Spec = cell(row, 2)
|
||||
p.Unit = cell(row, 3)
|
||||
p.Brand = cell(row, 4)
|
||||
p.Remark = cell(row, 8)
|
||||
p.Remark = cell(row, 6)
|
||||
|
||||
if p.Name == "" {
|
||||
errRows = append(errRows, map[string]interface{}{"row": i + 2, "error": "name is empty"})
|
||||
@@ -80,7 +80,6 @@ func (h *ImportHandler) ImportProducts(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 批量写入(upsert by hotel_id+name+spec)
|
||||
if err := h.db.CreateInBatches(&products, 100).Error; err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
@@ -95,7 +94,7 @@ func (h *ImportHandler) ImportProducts(c *gin.Context) {
|
||||
// ImportPartners POST /api/v1/import/partners
|
||||
// 列顺序:名称,类型(supplier/customer),联系人,电话,地址,备注
|
||||
func (h *ImportHandler) ImportPartners(c *gin.Context) {
|
||||
hotelID := middleware.GetHotelID(c)
|
||||
shopID := middleware.GetShopID(c)
|
||||
|
||||
file, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
@@ -132,7 +131,7 @@ func (h *ImportHandler) ImportPartners(c *gin.Context) {
|
||||
t = "supplier"
|
||||
}
|
||||
partners = append(partners, model.Partner{
|
||||
TenantBase: model.TenantBase{HotelID: hotelID},
|
||||
TenantBase: model.TenantBase{ShopID: shopID},
|
||||
Name: cell(row, 0),
|
||||
Type: t,
|
||||
Contact: cell(row, 2),
|
||||
|
||||
Reference in New Issue
Block a user