package handler import ( "github.com/gin-gonic/gin" "github.com/muyuqingfeng/iloom/auth-service/internal/service" "github.com/muyuqingfeng/iloom/shared/pkg/response" ) type NotificationHandler struct { svc *service.NotificationService } func NewNotificationHandler(svc *service.NotificationService) *NotificationHandler { return &NotificationHandler{svc: svc} } func (h *NotificationHandler) List(c *gin.Context) { userID := c.GetHeader("X-User-ID") if userID == "" { response.BadRequest(c, "user id not found") return } notifications, err := h.svc.List(c.Request.Context(), userID) if err != nil { response.InternalError(c, err.Error()) return } response.OK(c, notifications) } func (h *NotificationHandler) MarkRead(c *gin.Context) { id := c.Param("id") userID := c.GetHeader("X-User-ID") if userID == "" { response.BadRequest(c, "user id not found") return } if err := h.svc.MarkRead(c.Request.Context(), id, userID); err != nil { response.InternalError(c, err.Error()) return } response.OK(c, gin.H{"message": "marked as read"}) }