feat: 添加点赞和收藏功能,优化内容详情视图和评论交互

This commit is contained in:
2026-01-07 14:43:52 +08:00
parent f355b26920
commit 1298192157
6 changed files with 316 additions and 57 deletions

View File

@@ -99,6 +99,16 @@ func (r *Routes) Register(router fiber.Router) {
Body[dto.UploadPartForm]("form"),
))
// Register routes for controller: Content
r.log.Debugf("Registering route: Delete /v1/contents/:id/favorite -> content.RemoveFavorite")
router.Delete("/v1/contents/:id/favorite"[len(r.Path()):], Func1(
r.content.RemoveFavorite,
PathParam[string]("id"),
))
r.log.Debugf("Registering route: Delete /v1/contents/:id/like -> content.RemoveLike")
router.Delete("/v1/contents/:id/like"[len(r.Path()):], Func1(
r.content.RemoveLike,
PathParam[string]("id"),
))
r.log.Debugf("Registering route: Get /v1/contents -> content.List")
router.Get("/v1/contents"[len(r.Path()):], DataFunc1(
r.content.List,
@@ -130,6 +140,16 @@ func (r *Routes) Register(router fiber.Router) {
PathParam[string]("id"),
Body[dto.CommentCreateForm]("form"),
))
r.log.Debugf("Registering route: Post /v1/contents/:id/favorite -> content.AddFavorite")
router.Post("/v1/contents/:id/favorite"[len(r.Path()):], Func1(
r.content.AddFavorite,
PathParam[string]("id"),
))
r.log.Debugf("Registering route: Post /v1/contents/:id/like -> content.AddLike")
router.Post("/v1/contents/:id/like"[len(r.Path()):], Func1(
r.content.AddLike,
PathParam[string]("id"),
))
// Register routes for controller: Creator
r.log.Debugf("Registering route: Delete /v1/creator/contents/:id -> creator.DeleteContent")
router.Delete("/v1/creator/contents/:id"[len(r.Path()):], Func2(