main.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 '{"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?scope=global&group=test&pageNo=1&pageSize=1"
  12. // curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test"}' "http://localhost:32000/gateway/api/configuration/delete"
  13. // Class
  14. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "studentNum": 10}' "http://localhost:32000/gateway/api/v1/class/create"
  15. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"a58aec380ac243aea4e9a47bca4964e5", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/class/update"
  16. // curl -X GET "http://localhost:32000/gateway/api/v1/class/query?name=test-new&pageNo=1&pageSize=1"
  17. // curl -X GET "http://localhost:32000/gateway/api/v1/class/get?id=a58aec380ac243aea4e9a47bca4964e5"
  18. // curl -X DELETE "http://localhost:32000/gateway/api/v1/class/delete?id=a58aec380ac243aea4e9a47bca4964e5"
  19. // Student
  20. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:32000/gateway/api/v1/student/create"
  21. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"bdd469c05e244b5b91b17295a8dd221f", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/student/update"
  22. // curl -X GET "http://localhost:32000/gateway/api/v1/student/query?name=test-new&pageNo=1&pageSize=1"
  23. // curl -X GET "http://localhost:32000/gateway/api/v1/student/get?id=bdd469c05e244b5b91b17295a8dd221f"
  24. // curl -X DELETE "http://localhost:32000/gateway/api/v1/student/delete?id=bdd469c05e244b5b91b17295a8dd221f"
  25. // Family
  26. // curl -X POST -H "Content-Type: application/json" -d '{"father":"father", "mother": "mother"}' "http://localhost:32000/gateway/api/v1/family/create"
  27. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"094cb5b08a244163b0ccf02d45c07025", "father":"new-father", "mother": "new-mother"}' "http://localhost:32000/gateway/api/v1/family/update"
  28. // curl -X GET "http://localhost:32000/gateway/api/v1/family/query?father=new-father&pageNo=0&pageSize=0"
  29. // curl -X GET "http://localhost:32000/gateway/api/v1/family/get?id=094cb5b08a244163b0ccf02d45c07025"
  30. // curl -X DELETE "http://localhost:32000/gateway/api/v1/family/delete?id=094cb5b08a244163b0ccf02d45c07025"
  31. // Identity
  32. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:32000/gateway/api/v1/identity/create"
  33. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"cc591981a91c412a9e20be5eec683121", "name":"test-new"}' "http://localhost:32000/gateway/api/v1/identity/update"
  34. // curl -X GET "http://localhost:32000/gateway/api/v1/identity/query?name=test-new&pageNo=1&pageSize=1"
  35. // curl -X GET "http://localhost:32000/gateway/api/v1/identity/get?id=cc591981a91c412a9e20be5eec683121"
  36. // curl -X DELETE "http://localhost:32000/gateway/api/v1/identity/delete?id=cc591981a91c412a9e20be5eec683121"
  37. // Class-Student
  38. // curl -X POST -H "Content-Type: application/json" -d '{"id":"a38786c698904224a6fc36a23c2eec1e", "studentIds": ["00254b4a7102429db35e6edc8e47a764"]}' "http://localhost:31000/example/api/v1/class/student/update"
  39. // curl -X GET "http://localhost:31000/example/api/v1/class/student/query?id=a38786c698904224a6fc36a23c2eec1e"
  40. // Student-Class
  41. // curl -X POST -H "Content-Type: application/json" -d '{"id":"00254b4a7102429db35e6edc8e47a764", "classId": "a38786c698904224a6fc36a23c2eec1e"}' "http://localhost:31000/example/api/v1/student/class/update"
  42. // curl -X GET "http://localhost:31000/example/api/v1/student/class/query?id=00254b4a7102429db35e6edc8e47a764"
  43. // curl -X GET "http://localhost:31000/example/api/v1/student/class/queryWith?name=test"
  44. // Student-Family
  45. // curl -X POST -H "Content-Type: application/json" -d '{"id":"33d5538ee04843b59db1560b7ab65427", "familyId": "848d175d04e74e64a90cc9ccb4f4fcaf"}' "http://localhost:31000/example/api/v1/student/family/update"
  46. // curl -X GET "http://localhost:31000/example/api/v1/student/family/query?id=33d5538ee04843b59db1560b7ab65427"
  47. // curl -X GET "http://localhost:31000/example/api/v1/student/family/queryWith?name=test"
  48. // Family-Student
  49. // curl -X POST -H "Content-Type: application/json" -d '{"id":"848d175d04e74e64a90cc9ccb4f4fcaf", "studentId": "33d5538ee04843b59db1560b7ab65427"}' "http://localhost:31000/example/api/v1/family/student/update"
  50. // curl -X GET "http://localhost:31000/example/api/v1/family/student/query?id=848d175d04e74e64a90cc9ccb4f4fcaf"
  51. // curl -X GET "http://localhost:31000/example/api/v1/family/student/queryWith?father=father"
  52. // Student-Identity
  53. // curl -X POST -H "Content-Type: application/json" -d '{"id":"7880acb4f5df40a2b98055d15858f13d", "identityIds": ["58ab7e64e8ea46b5982aedca0d2fa5d0"]}' "http://localhost:31000/example/api/v1/student/identity/update"
  54. // curl -X GET "http://localhost:31000/example/api/v1/student/identity/query?id=7880acb4f5df40a2b98055d15858f13d"
  55. // Identity-Student
  56. // curl -X POST -H "Content-Type: application/json" -d '{"id":"58ab7e64e8ea46b5982aedca0d2fa5d0", "studentIds": ["7880acb4f5df40a2b98055d15858f13d"]}' "http://localhost:31000/example/api/v1/identity/student/update"
  57. // curl -X GET "http://localhost:31000/example/api/v1/identity/student/query?id=58ab7e64e8ea46b5982aedca0d2fa5d0"
  58. // Student-Hobby
  59. // curl -X POST -H "Content-Type: application/json" -d '{"id":"7880acb4f5df40a2b98055d15858f13d", "hobbyIds": ["42b305bb292c4082a3e91a2967f11111"]}' "http://localhost:31000/example/api/v1/student/hobby/update"
  60. // curl -X GET "http://localhost:31000/example/api/v1/student/hobby/query?id=7880acb4f5df40a2b98055d15858f13d"
  61. // Hobby-Student
  62. // curl -X POST -H "Content-Type: application/json" -d '{"id":"42b305bb292c4082a3e91a2967f11111", "studentIds": ["7880acb4f5df40a2b98055d15858f13d"]}' "http://localhost:31000/example/api/v1/hobby/student/update"
  63. // curl -X GET "http://localhost:31000/example/api/v1/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
  64. // Sql Executor
  65. // curl -X POST -H 'Content-Type: application/json' -d '{"urlPrefix": "example", "sql": "SELECT * FROM test.sql_execute_logs", "executorId": "guest-00254b4a7102429db35e6edc8e", "executorName": "test"}' "http://localhost:32000/gateway/api/sql/execute"
  66. // curl -X GET "http://localhost:32000/gateway/api/sql/execute/log?urlPrefix=example&sql=SELECT&executorId=guest-00254b4a7102429db35e6edc8e&executorName=te&startExecuteTime=2024-05-30%2012:03:45"
  67. func main() {
  68. api.NewGateway()
  69. defer api.DestroyGateway()
  70. go func() {
  71. if err := api.Start(); err != nil {
  72. panic(err)
  73. }
  74. }()
  75. defer func() {
  76. if err := api.Finish(); err != nil {
  77. panic(err)
  78. }
  79. }()
  80. death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  81. _ = death.WaitForDeath()
  82. }