From 64d2be116c8d1aca95d2c580df72e1923ebc1069 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Sun, 1 Feb 2026 06:53:54 +0800 Subject: [PATCH] feat: add team registration execution API endpoint --- backend/internal/api/team_reg_exec.go | 40 +++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/backend/internal/api/team_reg_exec.go b/backend/internal/api/team_reg_exec.go index bda7089..5727472 100644 --- a/backend/internal/api/team_reg_exec.go +++ b/backend/internal/api/team_reg_exec.go @@ -421,32 +421,50 @@ func findTeamRegExecutable() string { names = []string{"team-reg", "team-reg.exe"} } - // 可能的路径 - paths := []string{ - ".", // 当前目录 - "..", // 上级目录 - "../", // 项目根目录 - filepath.Join("..", ".."), // 更上级 - } + // 获取当前工作目录 + cwd, _ := os.Getwd() // 获取可执行文件所在目录 - execDir, err := os.Executable() - if err == nil { - execDir = filepath.Dir(execDir) - paths = append(paths, execDir, filepath.Join(execDir, "..")) + execPath, _ := os.Executable() + execDir := filepath.Dir(execPath) + + // 可能的路径(按优先级排序) + paths := []string{ + cwd, // 当前工作目录 + filepath.Join(cwd, "backend"), // cwd/backend + execDir, // 可执行文件所在目录 + filepath.Join(execDir, ".."), // 可执行文件上级目录 + ".", // 相对当前目录 + "backend", // 相对 backend 目录 + "..", // 上级目录 + filepath.Join("..", "backend"), // ../backend + filepath.Join("..", ".."), // 更上级 + filepath.Join("..", "..", "backend"), // ../../backend } + // 记录搜索过程 + logger.Info(fmt.Sprintf("[TeamReg] 当前工作目录: %s", cwd), "", "team-reg") + logger.Info(fmt.Sprintf("[TeamReg] 可执行文件目录: %s", execDir), "", "team-reg") + for _, basePath := range paths { for _, name := range names { fullPath := filepath.Join(basePath, name) if absPath, err := filepath.Abs(fullPath); err == nil { if _, err := os.Stat(absPath); err == nil { + logger.Info(fmt.Sprintf("[TeamReg] 找到文件: %s", absPath), "", "team-reg") return absPath } } } } + // 未找到,输出所有搜索过的路径 + logger.Error("[TeamReg] team-reg 可执行文件未找到,已搜索以下路径:", "", "team-reg") + for _, basePath := range paths { + absPath, _ := filepath.Abs(basePath) + logger.Error(fmt.Sprintf(" - %s", absPath), "", "team-reg") + } + return "" }