main.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package main
  2. import (
  3. "git.sxidc.com/go-framework/baize/examples/examples/project/application"
  4. DEATH "github.com/vrecan/death"
  5. "syscall"
  6. )
  7. // Version
  8. // curl -X GET "http://localhost:31000/example/version"
  9. // Configuration
  10. // curl -X POST -H "Content-Type: application/json" -d '{"scope": "global", "group":"test", "value":"test-value"}' "http://localhost:31000/example/v1/configuration/create"
  11. // curl -X GET "http://localhost:31000/example/v1/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/v1/configuration/delete"
  13. // Class
  14. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test", "studentNum": 10}' "http://localhost:31000/example/v1/class/create"
  15. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"3ca731da91cc42c9b9f413c1b493133d", "name":"test-new"}' "http://localhost:31000/example/v1/class/update"
  16. // curl -X GET "http://localhost:31000/example/v1/class/query?name=test-new&pageNo=1&pageSize=1"
  17. // curl -X GET "http://localhost:31000/example/v1/class/get?id=3ca731da91cc42c9b9f413c1b493133d"
  18. // curl -X DELETE "http://localhost:31000/example/v1/class/3ca731da91cc42c9b9f413c1b493133d/delete"
  19. // Student
  20. // curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' "http://localhost:31000/example/v1/student/create"
  21. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"6e12ee71397746b8920fa94e5f229366", "name":"test-new"}' "http://localhost:31000/example/v1/student/update"
  22. // curl -X GET "http://localhost:31000/example/v1/student/query?name=test-new&pageNo=1&pageSize=1"
  23. // curl -X GET "http://localhost:31000/example/v1/student/get?id=6e12ee71397746b8920fa94e5f229366"
  24. // curl -X DELETE "http://localhost:31000/example/v1/student/6e12ee71397746b8920fa94e5f229366/delete"
  25. // Family
  26. // curl -X POST -H "Content-Type: application/json" -d '{"father":"father", "mother": "mother"}' "http://localhost:31000/example/v1/family/create"
  27. // curl -X PUT -H "Content-Type: application/json" -d '{"id":"8a3af91da12c4a3eb040ffb535693f1a", "father":"new-father", "mother": "new-mother"}' "http://localhost:31000/example/v1/family/update"
  28. // curl -X GET "http://localhost:31000/example/v1/family/query?father=new-father&pageNo=0&pageSize=0"
  29. // curl -X GET "http://localhost:31000/example/v1/family/get?id=8a3af91da12c4a3eb040ffb535693f1a"
  30. // curl -X DELETE "http://localhost:31000/example/v1/family/8a3af91da12c4a3eb040ffb535693f1a/delete"
  31. // Student-Family
  32. // curl -X POST -H "Content-Type: application/json" -d '{"id":"fc3e96926aac46268ae783c4ad675d43", "familyId": "ed86bbb59a80429eb654d7f9f13ff116"}' "http://localhost:31000/example/v1/student/family/update"
  33. // curl -X GET "http://localhost:31000/example/v1/student/family/query?id=fc3e96926aac46268ae783c4ad675d43"
  34. // Family-Student
  35. // curl -X POST -H "Content-Type: application/json" -d '{"id":"ed86bbb59a80429eb654d7f9f13ff116", "studentId": "fc3e96926aac46268ae783c4ad675d43"}' "http://localhost:31000/example/v1/family/student/update"
  36. // curl -X GET "http://localhost:31000/example/v1/family/student/query?id=ed86bbb59a80429eb654d7f9f13ff116"
  37. func main() {
  38. application.NewApp()
  39. defer application.DestroyApp()
  40. go func() {
  41. err := application.Start()
  42. if err != nil {
  43. panic(err)
  44. }
  45. }()
  46. defer func() {
  47. err := application.Finish()
  48. if err != nil {
  49. panic(err)
  50. }
  51. }()
  52. death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  53. _ = death.WaitForDeath()
  54. }