feat: 收藏夹系统 + Studio 趋势图 + 通知偏好设置
- 新增收藏夹系统 (Folder/FolderItem 模型、CRUD API、前端管理页) - 新增文章详情页收藏按钮 (书签图标、ToggleFavorite 一键收藏) - 新增 Studio 趋势图 (赋能值/评论/点赞/收藏 4 线图, 7d/30d/90d) - 新增通知偏好设置页 (评论/回复/点赞/关注 4 类开关) - 后端通知列表支持按偏好过滤 (排除已关闭的通知类型) - 下载 Chart.js 到本地静态资源 (static/js/chart.umd.min.js) - 补充收藏夹卡片、开关滑块、趋势图网格等 CSS 样式
This commit is contained in:
@ -2,6 +2,7 @@ package repository
|
||||
|
||||
import (
|
||||
"metazone.cc/metalab/internal/model"
|
||||
"metazone.cc/metalab/internal/service"
|
||||
"strconv"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@ -258,6 +259,22 @@ func (r *CommentRepo) FindPostAuthorID(postID uint) (uint, error) {
|
||||
return authorID, err
|
||||
}
|
||||
|
||||
// AggregateCommentsByAuthor 按日期聚合评论量(作者所有文章在时间段内的评论)
|
||||
func (r *CommentRepo) AggregateCommentsByAuthor(userID uint, since string) ([]service.TrendPoint, error) {
|
||||
var results []service.TrendPoint
|
||||
err := r.db.Table("comments").
|
||||
Select("TO_CHAR(comments.created_at, 'YYYY-MM-DD') AS date, COUNT(*) AS value").
|
||||
Joins("JOIN posts ON posts.id = comments.post_id").
|
||||
Where("posts.user_id = ? AND comments.created_at >= ?", userID, since).
|
||||
Group("TO_CHAR(comments.created_at, 'YYYY-MM-DD')").
|
||||
Order("date ASC").
|
||||
Scan(&results).Error
|
||||
if results == nil {
|
||||
results = []service.TrendPoint{}
|
||||
}
|
||||
return results, err
|
||||
}
|
||||
|
||||
// ListAllComments 后台评论列表(支持关键词搜索、分页)
|
||||
func (r *CommentRepo) ListAllComments(keyword string, showDeleted bool, offset, limit int) ([]model.AdminCommentRow, int64, error) {
|
||||
var total int64
|
||||
|
||||
Reference in New Issue
Block a user