feat: add team registration execution API endpoint

This commit is contained in:
2026-02-01 06:53:54 +08:00
parent e19df67829
commit 64d2be116c

View File

@@ -421,32 +421,50 @@ func findTeamRegExecutable() string {
names = []string{"team-reg", "team-reg.exe"} names = []string{"team-reg", "team-reg.exe"}
} }
// 可能的路径 // 获取当前工作目录
paths := []string{ cwd, _ := os.Getwd()
".", // 当前目录
"..", // 上级目录
"../", // 项目根目录
filepath.Join("..", ".."), // 更上级
}
// 获取可执行文件所在目录 // 获取可执行文件所在目录
execDir, err := os.Executable() execPath, _ := os.Executable()
if err == nil { execDir := filepath.Dir(execPath)
execDir = filepath.Dir(execDir)
paths = append(paths, execDir, filepath.Join(execDir, "..")) // 可能的路径(按优先级排序)
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 _, basePath := range paths {
for _, name := range names { for _, name := range names {
fullPath := filepath.Join(basePath, name) fullPath := filepath.Join(basePath, name)
if absPath, err := filepath.Abs(fullPath); err == nil { if absPath, err := filepath.Abs(fullPath); err == nil {
if _, err := os.Stat(absPath); err == nil { if _, err := os.Stat(absPath); err == nil {
logger.Info(fmt.Sprintf("[TeamReg] 找到文件: %s", absPath), "", "team-reg")
return absPath 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 "" return ""
} }