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 }