fix: 修复通知系统链接错误、标记已读失败及帖子404页渲染异常
- 修复 post_rejected 通知链接到帖子详情页(原来链接到 /studio/posts) - 为 audit_approved/audit_rejected 通知添加链接到 /settings - 通知已读标记改用 fetch keepalive 代替 sendBeacon,附带 CSRF token,避免页面跳转时请求丢失 - 修复 repository 层 id 列名应为 uid(BaseModel 定义 primarykey column:uid) - 帖子404页添加 ExtraCSS 引入 posts.css,修复 SVG 图标无尺寸约束全屏渲染异常
This commit is contained in:
@ -50,7 +50,7 @@ func (r *NotificationRepo) CountUnread(userID uint) (int64, error) {
|
||||
// MarkRead 标记单条消息为已读
|
||||
func (r *NotificationRepo) MarkRead(id, userID uint) error {
|
||||
return r.db.Model(&model.Notification{}).
|
||||
Where("id = ? AND user_id = ?", id, userID).
|
||||
Where("uid = ? AND user_id = ?", id, userID).
|
||||
Update("is_read", true).Error
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ func (r *PostRepo) FindByIDWithAuthor(id uint) (*model.Post, error) {
|
||||
err := r.db.Table("posts").
|
||||
Select("posts.*, users.username as author_name").
|
||||
Joins("LEFT JOIN users ON users.uid = posts.user_id").
|
||||
Where("posts.id = ?", id).
|
||||
Where("posts.uid = ?", id).
|
||||
First(&post).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -157,7 +157,7 @@ func (r *PostRepo) CountPending() (int64, error) {
|
||||
|
||||
// Restore 恢复软删除
|
||||
func (r *PostRepo) Restore(id uint) error {
|
||||
result := r.db.Unscoped().Model(&model.Post{}).Where("id = ?", id).Update("deleted_at", nil)
|
||||
result := r.db.Unscoped().Model(&model.Post{}).Where("uid = ?", id).Update("deleted_at", nil)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user