feat(post): implement share recording functionality
All checks were successful
Build Backend / build (push) Successful in 13m16s
Build Backend / build-docker (push) Successful in 1m4s

- Added RecordShare method in PostHandler to handle sharing posts and increment share count.
- Introduced IncrementShares method in PostRepository to update shares_count for published posts.
- Updated PostService to include RecordShare, ensuring cache invalidation for post details and lists.
- Integrated new share route in the router for handling share requests.
This commit is contained in:
lafay
2026-03-24 05:21:36 +08:00
parent 176cd20847
commit 15f0f1605e
4 changed files with 79 additions and 0 deletions

View File

@@ -220,6 +220,8 @@ func (r *Router) setupRoutes() {
// 浏览量记录(可选认证,允许游客浏览)
posts.POST("/:id/view", middleware.OptionalAuth(r.jwtService), r.postHandler.RecordView)
// 分享计数(可选认证;仅已发布帖子生效)
posts.POST("/:id/share", middleware.OptionalAuth(r.jwtService), r.postHandler.RecordShare)
// 点赞
posts.POST("/:id/like", authMiddleware, r.postHandler.Like)