feat: phone validate

This commit is contained in:
2025-12-20 12:56:06 +08:00
parent 22e288bf98
commit dbeb0a5733
19 changed files with 397 additions and 89 deletions

View File

@@ -5,12 +5,11 @@
package http
import (
"go.ipao.vip/gen/field"
"quyun/v2/app/middlewares"
"quyun/v2/app/requests"
"quyun/v2/database/models"
"go.ipao.vip/gen/field"
"github.com/gofiber/fiber/v3"
log "github.com/sirupsen/logrus"
_ "go.ipao.vip/atom"
@@ -21,11 +20,12 @@ import (
// Routes implements the HttpRoute contract and provides route registration
// for all controllers in the http module.
//
// @provider contracts.HttpRoute atom.GroupRoutes
// @provider contracts.HttpRoute atom.GroupRoutes
type Routes struct {
log *log.Entry `inject:"false"`
middlewares *middlewares.Middlewares
// Controller instances
auth *auth
posts *posts
users *users
}
@@ -45,6 +45,17 @@ func (r *Routes) Name() string {
// Register registers all HTTP routes with the provided fiber router.
// Each route is registered with its corresponding controller action and parameter bindings.
func (r *Routes) Register(router fiber.Router) {
// Register routes for controller: auth
r.log.Debugf("Registering route: Post /v1/auth/phone -> auth.Phone")
router.Post("/v1/auth/phone"[len(r.Path()):], Func1(
r.auth.Phone,
Body[PhoneValidationForm]("form"),
))
r.log.Debugf("Registering route: Post /v1/auth/validate -> auth.Validate")
router.Post("/v1/auth/validate"[len(r.Path()):], DataFunc1(
r.auth.Validate,
Body[PhoneValidationForm]("body"),
))
// Register routes for controller: posts
r.log.Debugf("Registering route: Get /v1/posts -> posts.List")
router.Get("/v1/posts"[len(r.Path()):], DataFunc3(
@@ -78,14 +89,6 @@ func (r *Routes) Register(router fiber.Router) {
Query[ListQuery]("query"),
Local[*models.User]("user"),
))
r.log.Debugf("Registering route: Post /v1/auth/phone -> posts.Phone")
router.Post("/v1/auth/phone"[len(r.Path()):], Func0(
r.posts.Phone,
))
r.log.Debugf("Registering route: Post /v1/auth/validate -> posts.Validate")
router.Post("/v1/auth/validate"[len(r.Path()):], Func0(
r.posts.Validate,
))
r.log.Debugf("Registering route: Post /v1/posts/:id/buy -> posts.Buy")
router.Post("/v1/posts/:id/buy"[len(r.Path()):], DataFunc2(
r.posts.Buy,