main.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package main
  2. import (
  3. "baize-demo/project/server/application"
  4. DEATH "github.com/vrecan/death"
  5. "syscall"
  6. )
  7. // Version
  8. // curl -X GET "http://localhost:31000/example/api/version"
  9. // Configuration
  10. // curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test", "value":"test-value"}' "http://localhost:31000/example/api/configuration/create"
  11. // curl -X GET "http://localhost:31000/example/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:31000/example/api/configuration/delete"
  13. // Class
  14. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "studentNum": 10}' "http://localhost:31000/example/api/v1/class/create"
  15. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"5590090bf7604fb1b3a3b4b42722d924", "name":""}' "http://localhost:31000/example/api/v1/class/update"
  16. // curl -X GET "http://localhost:31000/example/api/v1/class/query?name=test-new&pageNo=1&pageSize=1"
  17. // curl -X GET "http://localhost:31000/example/api/v1/class/get?id=5590090bf7604fb1b3a3b4b42722d924"
  18. // curl -X DELETE "http://localhost:31000/example/api/v1/class/delete?id=5590090bf7604fb1b3a3b4b42722d924"
  19. // curl -X GET "http://localhost:31000/example/api/operateLog/query?resource=Class"
  20. // Student
  21. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:31000/example/api/v1/student/create"
  22. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"d9332801b46c4f0c99fdd381954313d6", "name":"test-new"}' "http://localhost:31000/example/api/v1/student/update"
  23. // curl -X GET "http://localhost:31000/example/api/v1/student/query?name=test-new&pageNo=1&pageSize=1"
  24. // curl -X POST -H "Content-Type: application/json" -d '{"pageNo":1, "pageSize":1, "rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\", \"value\": \"tes\"}"}' "http://localhost:31000/example/api/v1/student/advancedQuery"
  25. // 更复杂的高级查询 curl -X POST -H "Content-Type: application/json" -d '{"pageNo":1, "pageSize":1, "rule": "{\"logicalOperator\": \"or\", \"left\": {\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"eq\", \"value\": \"a\"}, \"right\": {\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\", \"value\": \"tes\"}}"}' "http://localhost:31000/example/api/v1/student/advancedQuery"
  26. // curl -X GET "http://localhost:31000/example/api/v1/student/get?id=d9332801b46c4f0c99fdd381954313d6"
  27. // curl -X DELETE "http://localhost:31000/example/api/v1/student/delete?id=d9332801b46c4f0c99fdd381954313d6
  28. // Family
  29. // curl -X POST -H "Content-Type: application/json" -d '{"father":"father", "mother": "mother"}' "http://localhost:31000/example/api/v1/family/create"
  30. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"85ffbfbef27b42879382b47718c7a99e", "father":"new-father", "mother": "new-mother"}' "http://localhost:31000/example/api/v1/family/update"
  31. // curl -X GET "http://localhost:31000/example/api/v1/family/query?father=new-father&pageNo=0&pageSize=0"
  32. // curl -X GET "http://localhost:31000/example/api/v1/family/get?id=85ffbfbef27b42879382b47718c7a99e"
  33. // curl -X DELETE "http://localhost:31000/example/api/v1/family/delete?id=85ffbfbef27b42879382b47718c7a99e"
  34. // Identity
  35. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:31000/example/api/v1/identity/create"
  36. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"6e12ee71397746b8920fa94e5f229366", "name":"test-new"}' "http://localhost:31000/example/api/v1/identity/update"
  37. // curl -X GET "http://localhost:31000/example/api/v1/identity/query?name=test-new&pageNo=1&pageSize=1"
  38. // curl -X GET "http://localhost:31000/example/api/v1/identity/get?id=6e12ee71397746b8920fa94e5f229366"
  39. // curl -X DELETE "http://localhost:31000/example/api/v1/identity/delete?id=6e12ee71397746b8920fa94e5f229366"
  40. // Class-Student
  41. // curl -X POST -H "Content-Type: application/json" -d '{"id":"fa08479ba7b54a3f8f06751fd2726b5d", "studentIds": ["323cb0a706a2470080fcf96268f630ee"]}' "http://localhost:31000/example/api/v1/class/student/update"
  42. // curl -X GET "http://localhost:31000/example/api/v1/class/student/query?id=fa08479ba7b54a3f8f06751fd2726b5d"
  43. // Student-Class
  44. // curl -X POST -H "Content-Type: application/json" -d '{"id":"323cb0a706a2470080fcf96268f630ee", "classId": "fa08479ba7b54a3f8f06751fd2726b5d"}' "http://localhost:31000/example/api/v1/student/class/update"
  45. // curl -X GET "http://localhost:31000/example/api/v1/student/class/query?id=323cb0a706a2470080fcf96268f630ee"
  46. // curl -X GET "http://localhost:31000/example/api/v1/student/class/queryWith?name=test"
  47. // Student-Family
  48. // curl -X POST -H "Content-Type: application/json" -d '{"id":"eec8c4def70d44e1ba234c089db40d17", "familyId": "f21a273d8b144616925e3931ec2e47b5"}' "http://localhost:31000/example/api/v1/student/family/update"
  49. // curl -X GET "http://localhost:31000/example/api/v1/student/family/query?id=eec8c4def70d44e1ba234c089db40d17"
  50. // curl -X GET "http://localhost:31000/example/api/v1/student/family/queryWith?name=test"
  51. // Family-Student
  52. // curl -X POST -H "Content-Type: application/json" -d '{"id":"f21a273d8b144616925e3931ec2e47b5", "studentId": "eec8c4def70d44e1ba234c089db40d17"}' "http://localhost:31000/example/api/v1/family/student/update"
  53. // curl -X GET "http://localhost:31000/example/api/v1/family/student/query?id=f21a273d8b144616925e3931ec2e47b5"
  54. // curl -X GET "http://localhost:31000/example/api/v1/family/student/queryWith?father=father"
  55. // Student-Identity
  56. // curl -X POST -H "Content-Type: application/json" -d '{"id":"eec8c4def70d44e1ba234c089db40d17", "identityIds": ["a36d5c24f5214e7fa4c3e92f2f73ec1f"]}' "http://localhost:31000/example/api/v1/student/identity/update"
  57. // curl -X GET "http://localhost:31000/example/api/v1/student/identity/query?id=eec8c4def70d44e1ba234c089db40d17"
  58. // Identity-Student
  59. // curl -X POST -H "Content-Type: application/json" -d '{"id":"a36d5c24f5214e7fa4c3e92f2f73ec1f", "studentIds": ["eec8c4def70d44e1ba234c089db40d17"]}' "http://localhost:31000/example/api/v1/identity/student/update"
  60. // curl -X GET "http://localhost:31000/example/api/v1/identity/student/query?id=a36d5c24f5214e7fa4c3e92f2f73ec1f"
  61. // Student-Hobby
  62. // curl -X POST -H "Content-Type: application/json" -d '{"id":"eec8c4def70d44e1ba234c089db40d17", "hobbyIds": ["42b305bb292c4082a3e91a2967f11111"]}' "http://localhost:31000/example/api/v1/student/hobby/update"
  63. // curl -X GET "http://localhost:31000/example/api/v1/student/hobby/query?id=eec8c4def70d44e1ba234c089db40d17"
  64. // Hobby-Student
  65. // curl -X POST -H "Content-Type: application/json" -d '{"id":"42b305bb292c4082a3e91a2967f11111", "studentIds": ["eec8c4def70d44e1ba234c089db40d17"]}' "http://localhost:31000/example/api/v1/hobby/student/update"
  66. // curl -X GET "http://localhost:31000/example/api/v1/hobby/student/query?id=42b305bb292c4082a3e91a2967f11111"
  67. // Sql Executor
  68. // curl -X POST -H 'Content-Type: application/json' -d '{"sql": "SELECT * FROM test.sql_execute_logs", "executorId": "guest-00254b4a7102429db35e6edc8e", "executorName": "test"}' "http://localhost:31000/example/api/sql/execute"
  69. // curl -X GET "http://localhost:31000/example/api/sql/execute/log?sql=SELECT&executorId=guest-00254b4a7102429db35e6edc8e&executorName=te&startExecuteTime=2024-05-30%2012:03:45"
  70. // Query Rule
  71. // curl -X GET "http://localhost:31000/example/api/queryRuleDefinition/get?domainName=Student"
  72. // curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student", "rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"eq\", \"value\": \"test\"}"}' "http://localhost:31000/example/api/queryRule/create"
  73. // curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student", "rule": "{\"fieldName\": \"Name\", \"fieldType\": \"string\", \"operator\": \"contains\"}"}' "http://localhost:31000/example/api/queryRule/create"
  74. // curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student"}' "http://localhost:31000/example/api/queryRule/query"
  75. // curl -X POST -H 'Content-Type: application/json' -d '{"scope": "global", "domainName": "Student"}' "http://localhost:31000/example/api/queryRule/enabled/get"
  76. // curl -X POST -H 'Content-Type: application/json' -d '{"id": "f696ca9174734349a39915e76217899c"}' "http://localhost:31000/example/api/queryRule/enable"
  77. // curl -X POST -H 'Content-Type: application/json' -d '{"id": "7011cde771a045a885872529ab77e79b"}' "http://localhost:31000/example/api/queryRule/disable"
  78. // curl -X DELETE "http://localhost:31000/example/api/queryRule/delete?id=7011cde771a045a885872529ab77e79b"
  79. // curl -X DELETE "http://localhost:31000/example/api/queryRule/delete?id=597ad3bbb97d4b7aa5196cd9366f07f2"
  80. func main() {
  81. application.NewApp()
  82. defer application.DestroyApp()
  83. go func() {
  84. err := application.Start()
  85. if err != nil {
  86. panic(err)
  87. }
  88. }()
  89. defer func() {
  90. err := application.Finish()
  91. if err != nil {
  92. panic(err)
  93. }
  94. }()
  95. death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  96. _ = death.WaitForDeath()
  97. }