feat: 添加通知模块的 API 处理器和路由配置
This commit is contained in:
@@ -205,11 +205,10 @@ func (h *NotificationHandler) CreateNotification(c *gin.Context) {
|
|||||||
api.Created(c, notification)
|
api.Created(c, notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterRoutes registers all notification routes to the given router group
|
// RegisterUserRoutes registers notification routes for regular users
|
||||||
func (h *NotificationHandler) RegisterRoutes(rg *gin.RouterGroup) {
|
func (h *NotificationHandler) RegisterUserRoutes(rg *gin.RouterGroup) {
|
||||||
notifications := rg.Group("/notifications")
|
notifications := rg.Group("/notifications")
|
||||||
{
|
{
|
||||||
notifications.POST("", h.CreateNotification)
|
|
||||||
notifications.GET("", h.GetNotifications)
|
notifications.GET("", h.GetNotifications)
|
||||||
notifications.GET("/unread-count", h.GetUnreadCount)
|
notifications.GET("/unread-count", h.GetUnreadCount)
|
||||||
notifications.PUT("/:id/read", h.MarkAsRead)
|
notifications.PUT("/:id/read", h.MarkAsRead)
|
||||||
@@ -217,3 +216,11 @@ func (h *NotificationHandler) RegisterRoutes(rg *gin.RouterGroup) {
|
|||||||
notifications.DELETE("/:id", h.DeleteNotification)
|
notifications.DELETE("/:id", h.DeleteNotification)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterAdminRoutes registers notification routes for admin/system use
|
||||||
|
func (h *NotificationHandler) RegisterAdminRoutes(rg *gin.RouterGroup) {
|
||||||
|
notifications := rg.Group("/notifications")
|
||||||
|
{
|
||||||
|
notifications.POST("", h.CreateNotification)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -226,7 +226,8 @@ func Setup(db *gorm.DB, yunAPIClient *service.YunAPIClient, cfg *config.Config)
|
|||||||
aiHandler.RegisterRoutes(protected)
|
aiHandler.RegisterRoutes(protected)
|
||||||
|
|
||||||
// Feature: notification-center - Register notification routes
|
// Feature: notification-center - Register notification routes
|
||||||
notificationHandler.RegisterRoutes(protected)
|
notificationHandler.RegisterUserRoutes(protected)
|
||||||
|
notificationHandler.RegisterAdminRoutes(v1)
|
||||||
|
|
||||||
// Register report routes
|
// Register report routes
|
||||||
protected.GET("/reports/summary", reportHandler.GetTransactionSummary)
|
protected.GET("/reports/summary", reportHandler.GetTransactionSummary)
|
||||||
@@ -520,7 +521,8 @@ func SetupWithRedis(db *gorm.DB, yunAPIClient *service.YunAPIClient, redisClient
|
|||||||
v1.POST("/app-lock/password/change", appLockHandler.ChangePassword)
|
v1.POST("/app-lock/password/change", appLockHandler.ChangePassword)
|
||||||
|
|
||||||
// Register notification routes
|
// Register notification routes
|
||||||
notificationHandler.RegisterRoutes(protected)
|
notificationHandler.RegisterUserRoutes(protected)
|
||||||
|
notificationHandler.RegisterAdminRoutes(v1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, syncScheduler
|
return r, syncScheduler
|
||||||
|
|||||||
Reference in New Issue
Block a user