feat: fix gen routes
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"regexp"
|
||||||
|
|
||||||
"git.ipao.vip/rogeecn/atomctl/pkg/ast/route"
|
"git.ipao.vip/rogeecn/atomctl/pkg/ast/route"
|
||||||
"git.ipao.vip/rogeecn/atomctl/pkg/utils/gomod"
|
"git.ipao.vip/rogeecn/atomctl/pkg/utils/gomod"
|
||||||
@@ -51,11 +51,13 @@ func commandGenRouteE(cmd *cobra.Command, args []string) error {
|
|||||||
log.Fatal("modules dir not exist, ", modulePath)
|
log.Fatal("modules dir not exist, ", modulePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controllerPattern := regexp.MustCompile(`controller(_?\w+)?\.go`)
|
||||||
err = filepath.WalkDir(modulePath, func(path string, d fs.DirEntry, err error) error {
|
err = filepath.WalkDir(modulePath, func(path string, d fs.DirEntry, err error) error {
|
||||||
if d.IsDir() {
|
if d.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !strings.HasSuffix(path, "controller.go") {
|
|
||||||
|
if !controllerPattern.MatchString(d.Name()) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ func Body[T any](name string) func(fiber.Ctx) (*T, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryParam[T fiber.GenericType](key string) func(fiber.Ctx) (T, error) {
|
||||||
|
return func(ctx fiber.Ctx) (T, error) {
|
||||||
|
v := fiber.Query[T](ctx, key)
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Query[T any](name string) func(fiber.Ctx) (*T, error) {
|
func Query[T any](name string) func(fiber.Ctx) (*T, error) {
|
||||||
return func(ctx fiber.Ctx) (*T, error) {
|
return func(ctx fiber.Ctx) (*T, error) {
|
||||||
p := new(T)
|
p := new(T)
|
||||||
|
|||||||
Reference in New Issue
Block a user