fix: 修复发帖后链接404 + 通知卡片跳转错误
- post_repo.go: FindByIDWithAuthor/Restore 中 posts.uid 改为 posts.id(posts 表主键是 id,不存在 uid 列) - theme/loader.go: 新增 derefUint 模板函数,显式解引用 *uint 指针(Go 1.26 模板引擎传参给 printf 时不自动解引用) - messages/index.html: 通知卡片链接使用 derefUint 包裹 RelatedID 避免打印指针地址
This commit is contained in:
@ -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.uid = ?", id).
|
||||
Where("posts.id = ?", 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("uid = ?", id).Update("deleted_at", nil)
|
||||
result := r.db.Unscoped().Model(&model.Post{}).Where("id = ?", id).Update("deleted_at", nil)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user