From 6e50172fd3bd7557fe25a46dd3bff69a70b2e33c Mon Sep 17 00:00:00 2001 From: engigu Date: Fri, 27 Feb 2026 23:19:50 +0800 Subject: [PATCH] feat: add resetpwd cmd -- fix init useless process --- cmd/resetpwd/resetpwd.go | 2 +- internal/bootstrap/bootstrap.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/resetpwd/resetpwd.go b/cmd/resetpwd/resetpwd.go index 03bb905..b731eb7 100644 --- a/cmd/resetpwd/resetpwd.go +++ b/cmd/resetpwd/resetpwd.go @@ -23,7 +23,7 @@ func Run(args []string) { } // 必须初始化环境与数据库才能修改密码 - bootstrap.New() + bootstrap.InitBasic() userService := services.NewUserService() adminUser := userService.GetUserByUsername("admin") diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index 38a2883..23fba9b 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -21,10 +21,16 @@ type App struct { } func New() *App { + app := InitBasic() + app.initRouter() + return app +} + +// InitBasic 初始化基础环境(配置和数据库),不启动后台服务和路由 +func InitBasic() *App { app := &App{} app.initConfig() app.initDatabase() - app.initRouter() return app }