feat(post): implement share recording functionality
- 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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user