add like functionality with Like model, implement like/unlike methods, and update Post and Comment models to track like counts

This commit is contained in:
2025-07-22 22:45:55 +08:00
parent cbe73121f2
commit 562b9bd17f
15 changed files with 216 additions and 33 deletions

View File

@ -9,12 +9,11 @@ import (
// post 文章API路由
func registerPostRoutes(group *route.RouterGroup) {
postGroup := group.Group("/post").Use(middleware.UseAuth())
postGroupWithoutAuth := group.Group("/post")
postGroup := group.Group("/post").Use(middleware.UseAuth(true))
postGroupWithoutAuth := group.Group("/post").Use(middleware.UseAuth(false))
{
postGroupWithoutAuth.GET("/p/:id", v1.Post.Get)
postGroupWithoutAuth.GET("/list", v1.Post.List)
postGroup.POST("/p", v1.Post.Create)
postGroup.PUT("/p", v1.Post.Update)
postGroup.DELETE("/p", v1.Post.Delete)