feat: 实现通知管理功能,包括模型、仓库、服务和API处理器。
This commit is contained in:
@@ -233,6 +233,24 @@ func (h *NotificationHandler) BroadcastNotification(c *gin.Context) {
|
||||
api.Success(c, gin.H{"message": "Notification broadcast started"})
|
||||
}
|
||||
|
||||
// GetBroadcastHistory handles GET /api/v1/notifications/announcements
|
||||
// Returns a list of system broadcast history
|
||||
func (h *NotificationHandler) GetBroadcastHistory(c *gin.Context) {
|
||||
limitStr := c.DefaultQuery("limit", "10")
|
||||
offsetStr := c.DefaultQuery("offset", "0")
|
||||
|
||||
limit, _ := strconv.Atoi(limitStr)
|
||||
offset, _ := strconv.Atoi(offsetStr)
|
||||
|
||||
result, err := h.notificationService.ListAnnouncements(limit, offset)
|
||||
if err != nil {
|
||||
api.InternalError(c, "Failed to get broadcast history: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
api.Success(c, result)
|
||||
}
|
||||
|
||||
// RegisterUserRoutes registers notification routes for regular users
|
||||
func (h *NotificationHandler) RegisterUserRoutes(rg *gin.RouterGroup) {
|
||||
notifications := rg.Group("/notifications")
|
||||
@@ -251,5 +269,6 @@ func (h *NotificationHandler) RegisterAdminRoutes(rg *gin.RouterGroup) {
|
||||
{
|
||||
notifications.POST("", h.CreateNotification)
|
||||
notifications.POST("/broadcast", h.BroadcastNotification)
|
||||
notifications.GET("/announcements", h.GetBroadcastHistory)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user