api.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package api
  2. /* ----------- 连接返回信息------------------ */
  3. // 服务器和数据库连接信息
  4. type ConnectInfoRequest struct {
  5. // Id string `json:"id" toml:"id"`
  6. Ssh SshInfo `json:"ssh_info"`
  7. Db DbInfo `json:"db_info"`
  8. }
  9. // 返回服务器和数据库连接信息
  10. type ConnectInfoResopnse struct {
  11. BaseFileName string `json:"base_filename" toml:"base_filename"`
  12. ConnInfo map[string]ConnectInfo `json:"conn_info"`
  13. }
  14. type ConnectInfo struct {
  15. Ssh SshInfo `json:"ssh_info"`
  16. Db DbInfo `json:"db_info"`
  17. }
  18. type SshInfo struct {
  19. Username string `json:"username" toml:"ssh_username"`
  20. Password string `json:"password" toml:"ssh_password"`
  21. Host string `json:"host" toml:"ssh_ip"`
  22. Port string `json:"port" toml:"ssh_port"`
  23. }
  24. type DbInfo struct {
  25. User string `json:"user" toml:"db_user"`
  26. Password string `json:"password" toml:"db_password"`
  27. Database string `json:"database" toml:"db_database"`
  28. Port string `json:"port" toml:"db_port"`
  29. }
  30. func SetConnectInfo(sshName, sshpw, sship, sshport, dbname, dbuser, dbpw, dbport string) ConnectInfo {
  31. return ConnectInfo{
  32. Ssh: SshInfo{
  33. Username: sshName,
  34. Password: sshpw,
  35. Host: sship,
  36. Port: sshport,
  37. },
  38. Db: DbInfo{
  39. User: dbuser,
  40. Password: dbpw,
  41. Database: dbname,
  42. Port: dbport,
  43. },
  44. }
  45. }
  46. /* ----------- 服务器信息------------------ */
  47. type ServerInfoRequest struct {
  48. BaseFileName string `json:"base_filename" toml:"base_filename"`
  49. Username string `json:"username" toml:"ssh_username"`
  50. Password string `json:"password" toml:"ssh_password"`
  51. Host string `json:"host" toml:"ssh_ip"`
  52. Port string `json:"port" toml:"ssh_port"`
  53. }