package connect import ( "net/http" "xg_dba/api" services "xg_dba/internal/services/connect" "github.com/gin-gonic/gin" ) // 获取连接信息 func SaveConnectInfo_controller(c *gin.Context) { connectInfo := api.ConnectInfoRequest{} if err := c.BindJSON(&connectInfo); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } //存储到本地 localPath := "./config/" + connectInfo.Ssh.Host + "/" + connectInfo.Ssh.Host + ".toml" if err := services.SetConnectInfo_service(connectInfo, localPath); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, connectInfo) }