This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"go.ipao.vip/gen/field"
|
||||
"quyun/v2/app/middlewares"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
@@ -54,13 +55,19 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
r.log.Debugf("Registering route: Get /posts/:id/play -> posts.Play")
|
||||
router.Get("/posts/:id/play"[len(r.Path()):], DataFunc2(
|
||||
r.posts.Play,
|
||||
PathParam[int64]("id"),
|
||||
func(ctx fiber.Ctx) (*models.Post, error) {
|
||||
v := fiber.Params[int](ctx, "id")
|
||||
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
|
||||
},
|
||||
Local[*models.User]("user"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /posts/:id/show -> posts.Show")
|
||||
router.Get("/posts/:id/show"[len(r.Path()):], DataFunc2(
|
||||
r.posts.Show,
|
||||
PathParam[int64]("id"),
|
||||
func(ctx fiber.Ctx) (*models.Post, error) {
|
||||
v := fiber.Params[int](ctx, "id")
|
||||
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
|
||||
},
|
||||
Local[*models.User]("user"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /posts/mine -> posts.Mine")
|
||||
@@ -73,7 +80,10 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
r.log.Debugf("Registering route: Post /posts/:id/buy -> posts.Buy")
|
||||
router.Post("/posts/:id/buy"[len(r.Path()):], DataFunc2(
|
||||
r.posts.Buy,
|
||||
PathParam[int64]("id"),
|
||||
func(ctx fiber.Ctx) (*models.Post, error) {
|
||||
v := fiber.Params[int](ctx, "id")
|
||||
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
|
||||
},
|
||||
Local[*models.User]("user"),
|
||||
))
|
||||
// Register routes for controller: users
|
||||
|
||||
Reference in New Issue
Block a user