chore: 清理 SSR 改造后的历史遗留死代码与误提交产物
- 删除图形验证码整条死链:service/captcha.go、APICaptcha、 GET /api/captcha、CaptchaService 装配、ErrCaptchaInvalid 及前端 api.captcha()(注册/登录已改用邮箱验证码,Verify 无任何调用方) - 删除 GET /api/posts/hot 死路由:APIHotPosts + PostService.HotPosts (热门排序走 /api/posts?sort=hot) - 删除 GET /api/posts/:id/revisions/:revId 死路由: APIPostRevisionDetail + PostService.GetRevision + ErrRevisionNotFound 及前端 api.postRevision()(历史面板仅用列表接口) - 停止跟踪误提交的 27.5MB Linux 二进制 jiang13-linux-amd64 与 .vite 依赖缓存;.gitignore 补充对应规则并移除已失效的 embed_static 条目
This commit is contained in:
@@ -172,52 +172,6 @@ func (s *PostService) lastReplyInfoMap(postIDs []uint) map[uint]lastReplyInfo {
|
||||
return m
|
||||
}
|
||||
|
||||
// HotPosts 近期活跃讨论(近 7 日有公开回复,按最后回复时间倒序)
|
||||
func (s *PostService) HotPosts(limit int) ([]PostListItem, error) {
|
||||
if limit <= 0 {
|
||||
limit = 10
|
||||
}
|
||||
since := time.Now().Add(-7 * 24 * time.Hour)
|
||||
var posts []model.Post
|
||||
err := model.DB.Preload("User").Preload("Board").
|
||||
Where("status = ?", model.ContentStatusPublished).
|
||||
Where(`EXISTS (
|
||||
SELECT 1 FROM comments
|
||||
WHERE comments.post_id = posts.id
|
||||
AND comments.deleted_at IS NULL
|
||||
AND comments.status = ?
|
||||
AND comments.created_at >= ?
|
||||
)`, model.ContentStatusPublished, since).
|
||||
Order(`(
|
||||
SELECT MAX(created_at) FROM comments
|
||||
WHERE comments.post_id = posts.id
|
||||
AND comments.deleted_at IS NULL
|
||||
AND comments.status = 'published'
|
||||
) DESC`).
|
||||
Limit(limit).Find(&posts).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint, len(posts))
|
||||
for i, p := range posts {
|
||||
ids[i] = p.ID
|
||||
}
|
||||
countMap := s.commentCountMap(ids)
|
||||
replyMap := s.lastReplyInfoMap(ids)
|
||||
items := make([]PostListItem, len(posts))
|
||||
for i, p := range posts {
|
||||
info := replyMap[p.ID]
|
||||
items[i] = PostListItem{
|
||||
Post: p,
|
||||
CommentCount: countMap[p.ID],
|
||||
LastReplyAt: info.At,
|
||||
LastReplyUser: info.User,
|
||||
LastReplyGuestNick: info.GuestNick,
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
// TagCount 标签及其出现次数
|
||||
type TagCount struct {
|
||||
Name string `json:"name"`
|
||||
@@ -680,16 +634,6 @@ func (s *PostService) ListRevisions(postID uint) ([]model.PostRevision, error) {
|
||||
return revs, nil
|
||||
}
|
||||
|
||||
func (s *PostService) GetRevision(postID, revID uint) (*model.PostRevision, error) {
|
||||
var rev model.PostRevision
|
||||
err := model.DB.Preload("Editor").
|
||||
Where("id = ? AND post_id = ?", revID, postID).First(&rev).Error
|
||||
if err != nil {
|
||||
return nil, ErrRevisionNotFound
|
||||
}
|
||||
return &rev, nil
|
||||
}
|
||||
|
||||
// Delete 软删除帖子及其评论(进入回收站);点赞/收藏保留以便恢复。仅管理员可删。
|
||||
func (s *PostService) Delete(userID, postID uint, isAdmin bool) error {
|
||||
if !isAdmin {
|
||||
|
||||
Reference in New Issue
Block a user