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:
wangjia
2026-04-07 22:20:12 +08:00
parent 37112d6599
commit 31ea370cea
50 changed files with 2675 additions and 951 deletions
+4 -4
View File
@@ -37,14 +37,14 @@ func (h *LicenseHandler) Activate(c *gin.Context) {
// Verify GET /api/v1/license/verify
func (h *LicenseHandler) Verify(c *gin.Context) {
hotelID := middleware.GetHotelID(c)
shopID := middleware.GetShopID(c)
deviceID := c.Query("device_id")
if deviceID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "device_id required"})
return
}
lic, err := h.svc.Verify(hotelID, deviceID)
lic, err := h.svc.Verify(shopID, deviceID)
if err != nil {
c.JSON(http.StatusForbidden, gin.H{"error": err.Error()})
return
@@ -54,7 +54,7 @@ func (h *LicenseHandler) Verify(c *gin.Context) {
// Deactivate POST /api/v1/license/deactivate
func (h *LicenseHandler) Deactivate(c *gin.Context) {
hotelID := middleware.GetHotelID(c)
shopID := middleware.GetShopID(c)
var req struct {
DeviceID string `json:"device_id" binding:"required"`
}
@@ -63,7 +63,7 @@ func (h *LicenseHandler) Deactivate(c *gin.Context) {
return
}
if err := h.svc.Deactivate(hotelID, req.DeviceID); err != nil {
if err := h.svc.Deactivate(shopID, req.DeviceID); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}