main.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package main
  2. import (
  3. "baize-demo/project/gateway/api"
  4. DEATH "github.com/vrecan/death"
  5. "syscall"
  6. )
  7. // Version
  8. // curl -X GET "http://localhost:32000/gateway/api/version"
  9. // Configuration
  10. // curl -X POST -H "Content-Type: application/json" -d '{"serviceShortName": "example", "scope": "global", "group":"test", "value":"test-value"}' "http://localhost:32000/gateway/api/configuration/create"
  11. // curl -X GET "http://localhost:32000/gateway/api/configuration/values?serviceShortName=example&scope=global&group=test&pageNo=1&pageSize=1"
  12. // curl -X POST -H "Content-Type: application/json" -d '{"serviceShortName": "example", "scope": "global", "group":"test"}' "http://localhost:32000/gateway/api/configuration/delete"
  13. // curl -X GET "http://localhost:32000/gateway/api/configuration/registered/services"
  14. // Class
  15. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "studentNum": 10}' "http://localhost:32000/gateway/api/v1/example/class/create"
  16. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"1a6103829c7142d49a81106815b11319", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/example/class/update"
  17. // curl -X GET "http://localhost:32000/gateway/api/v1/example/class/query?name=test-new&pageNo=1&pageSize=1"
  18. // curl -X GET "http://localhost:32000/gateway/api/v1/example/class/get?id=1a6103829c7142d49a81106815b11319"
  19. // curl -X DELETE "http://localhost:32000/gateway/api/v1/example/class/delete?id=1a6103829c7142d49a81106815b11319"
  20. // Student
  21. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:32000/gateway/api/v1/example/student/create"
  22. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"bdd469c05e244b5b91b17295a8dd221f", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/example/student/update"
  23. // curl -X GET "http://localhost:32000/gateway/api/v1/example/student/query?name=test-new&pageNo=1&pageSize=1"
  24. // curl -X GET "http://localhost:32000/gateway/api/v1/example/student/get?id=bdd469c05e244b5b91b17295a8dd221f"
  25. // curl -X DELETE "http://localhost:32000/gateway/api/v1/example/student/delete?id=bdd469c05e244b5b91b17295a8dd221f"
  26. // Family
  27. // curl -X POST -H "Content-Type: application/json" -d '{"father":"father", "mother": "mother"}' "http://localhost:32000/gateway/api/v1/example/family/create"
  28. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"094cb5b08a244163b0ccf02d45c07025", "father":"new-father", "mother": "new-mother"}' "http://localhost:32000/gateway/api/v1/example/family/update"
  29. // curl -X GET "http://localhost:32000/gateway/api/v1/example/family/query?father=new-father&pageNo=0&pageSize=0"
  30. // curl -X GET "http://localhost:32000/gateway/api/v1/example/family/get?id=094cb5b08a244163b0ccf02d45c07025"
  31. // curl -X DELETE "http://localhost:32000/gateway/api/v1/example/family/delete?id=094cb5b08a244163b0ccf02d45c07025"
  32. // Identity
  33. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:32000/gateway/api/v1/example/identity/create"
  34. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"cc591981a91c412a9e20be5eec683121", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/example/identity/update"
  35. // curl -X GET "http://localhost:32000/gateway/api/v1/example/identity/query?name=test-new&pageNo=1&pageSize=1"
  36. // curl -X GET "http://localhost:32000/gateway/api/v1/example/identity/get?id=cc591981a91c412a9e20be5eec683121"
  37. // curl -X DELETE "http://localhost:32000/gateway/api/v1/example/identity/delete?id=cc591981a91c412a9e20be5eec683121"
  38. // Class-Student
  39. // curl -X POST -H "Content-Type: application/json" -d '{"id":"11d1ecf2795244af89d0b13c606f2396", "studentIds": ["4340e46e439e410fa3b0569e15354da6"]}' "http://localhost:31000/example/api/v1/example/class/student/update"
  40. // curl -X GET "http://localhost:31000/example/api/v1/example/class/student/query?id=11d1ecf2795244af89d0b13c606f2396"
  41. // Student-Class
  42. // curl -X POST -H "Content-Type: application/json" -d '{"id":"4340e46e439e410fa3b0569e15354da6", "classId": "11d1ecf2795244af89d0b13c606f2396"}' "http://localhost:31000/example/api/v1/example/student/class/update"
  43. // curl -X GET "http://localhost:31000/example/api/v1/example/student/class/query?id=4340e46e439e410fa3b0569e15354da6"
  44. // curl -X GET "http://localhost:31000/example/api/v1/example/student/class/queryWith?name=test"
  45. // Student-Family
  46. // curl -X POST -H "Content-Type: application/json" -d '{"id":"4340e46e439e410fa3b0569e15354da6", "familyId": "6d15704c1cac42788aa9866cc5d09649"}' "http://localhost:31000/example/api/v1/example/student/family/update"
  47. // curl -X GET "http://localhost:31000/example/api/v1/example/student/family/query?id=4340e46e439e410fa3b0569e15354da6"
  48. // curl -X GET "http://localhost:31000/example/api/v1/example/student/family/queryWith?name=test"
  49. // Family-Student
  50. // curl -X POST -H "Content-Type: application/json" -d '{"id":"6d15704c1cac42788aa9866cc5d09649", "studentId": "4340e46e439e410fa3b0569e15354da6"}' "http://localhost:31000/example/api/v1/example/family/student/update"
  51. // curl -X GET "http://localhost:31000/example/api/v1/example/family/student/query?id=6d15704c1cac42788aa9866cc5d09649"
  52. // curl -X GET "http://localhost:31000/example/api/v1/example/family/student/queryWith?father=father"
  53. // Student-Identity
  54. // curl -X POST -H "Content-Type: application/json" -d '{"id":"4340e46e439e410fa3b0569e15354da6", "identityIds": ["1988069accce47f58679d7a46ce605c3"]}' "http://localhost:31000/example/api/v1/example/student/identity/update"
  55. // curl -X GET "http://localhost:31000/example/api/v1/example/student/identity/query?id=4340e46e439e410fa3b0569e15354da6"
  56. // Identity-Student
  57. // curl -X POST -H "Content-Type: application/json" -d '{"id":"1988069accce47f58679d7a46ce605c3", "studentIds": ["4340e46e439e410fa3b0569e15354da6"]}' "http://localhost:31000/example/api/v1/example/identity/student/update"
  58. // curl -X GET "http://localhost:31000/example/api/v1/example/identity/student/query?id=1988069accce47f58679d7a46ce605c3"
  59. // Student-Hobby
  60. // curl -X POST -H "Content-Type: application/json" -d '{"id":"4340e46e439e410fa3b0569e15354da6", "hobbyIds": ["42b305bb292c4082a3e91a2967f11111"]}' "http://localhost:31000/example/api/v1/example/student/hobby/update"
  61. // curl -X GET "http://localhost:31000/example/api/v1/example/student/hobby/query?id=4340e46e439e410fa3b0569e15354da6"
  62. // Hobby-Student
  63. // curl -X POST -H "Content-Type: application/json" -d '{"id":"42b305bb292c4082a3e91a2967f11111", "studentIds": ["4340e46e439e410fa3b0569e15354da6"]}' "http://localhost:31000/example/api/v1/example/hobby/student/update"
  64. // curl -X GET "http://localhost:31000/example/api/v1/example/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
  65. // Sql Executor
  66. // curl -X POST -H 'Content-Type: application/json' -d '{"serviceShortName": "example", "sql": "SELECT * FROM test.sql_execute_logs", "executorId": "guest-00254b4a7102429db35e6edc8e"}' "http://localhost:32000/gateway/api/sql/execute"
  67. // curl -X GET "http://localhost:32000/gateway/api/sql/execute/log?serviceShortName=example&sql=SELECT&executorId=guest-00254b4a7102429db35e6edc8e&executorName=gue"
  68. // curl -X GET "http://localhost:32000/gateway/api/sql/execute/registered/services"
  69. func main() {
  70. api.NewGateway()
  71. defer api.DestroyGateway()
  72. go func() {
  73. if err := api.Start(); err != nil {
  74. panic(err)
  75. }
  76. }()
  77. defer func() {
  78. if err := api.Finish(); err != nil {
  79. panic(err)
  80. }
  81. }()
  82. death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  83. _ = death.WaitForDeath()
  84. }