feat: 添加通知处理程序,实现通知的获取、标记已读、删除、创建和广播功能。
This commit is contained in:
@@ -73,23 +73,17 @@ func (h *NotificationHandler) GetNotifications(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate total pages
|
|
||||||
totalPages := 0
|
|
||||||
if result.Limit > 0 {
|
|
||||||
totalPages = int((result.Total + int64(result.Limit) - 1) / int64(result.Limit))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate current page (1-indexed)
|
// Calculate current page (1-indexed)
|
||||||
currentPage := 1
|
currentPage := 1
|
||||||
if result.Limit > 0 {
|
if result.Limit > 0 {
|
||||||
currentPage = (result.Offset / result.Limit) + 1
|
currentPage = (result.Offset / result.Limit) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
api.SuccessWithMeta(c, result.Notifications, &api.Meta{
|
api.Success(c, gin.H{
|
||||||
Page: currentPage,
|
"notifications": result.Notifications,
|
||||||
PageSize: result.Limit,
|
"total": result.Total,
|
||||||
TotalCount: result.Total,
|
"page": currentPage,
|
||||||
TotalPages: totalPages,
|
"limit": result.Limit,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user