fix: internal reminder路由+user_id支持 — 修复401/404

- Gateway新增 POST/GET/DELETE /api/v1/internal/reminders
- CreateReminderRequest新增UserID字段,JWT为空时回退
- GatewayClient URL改为 /api/v1/internal/reminders

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-23 20:24:09 +08:00
parent fea67d05eb
commit edc2e77d2f
2 changed files with 10 additions and 0 deletions
@@ -35,6 +35,7 @@ type CreateReminderRequest struct {
RemindAt string `json:"remind_at" binding:"required"` // ISO 8601 格式 RemindAt string `json:"remind_at" binding:"required"` // ISO 8601 格式
RepeatType string `json:"repeat_type"` // none, daily, weekly, monthly RepeatType string `json:"repeat_type"` // none, daily, weekly, monthly
SessionID string `json:"session_id"` SessionID string `json:"session_id"`
UserID string `json:"user_id,omitempty"` // 内部调用时直接传 userID
} }
// UpdateReminderRequest 更新提醒请求体 // UpdateReminderRequest 更新提醒请求体
@@ -95,6 +96,12 @@ func (h *ReminderHandler) Create(c *gin.Context) {
// 从 JWT 获取 userID // 从 JWT 获取 userID
userID := middleware.GetUserID(c) userID := middleware.GetUserID(c)
if userID == "" {
userID = req.UserID
}
if userID == "" {
userID = req.UserID
}
if userID == "" { if userID == "" {
c.JSON(http.StatusUnauthorized, gin.H{"error": "未认证"}) c.JSON(http.StatusUnauthorized, gin.H{"error": "未认证"})
return return
@@ -234,6 +234,9 @@ func Setup(r *gin.Engine, hub *ws.Hub, cfg *config.Config, sessionStore *store.S
{ {
internal.POST("/notify", notificationHandler.InternalNotify) internal.POST("/notify", notificationHandler.InternalNotify)
internal.POST("/proactive-message", chatHandler.HandleProactiveMessage) internal.POST("/proactive-message", chatHandler.HandleProactiveMessage)
internal.POST("/reminders", reminderHandler.Create)
internal.GET("/reminders", reminderHandler.List)
internal.DELETE("/reminders/:id", reminderHandler.Delete)
} }
// ========== WebSocket路由 ========== // ========== WebSocket路由 ==========