main.go 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/configuration/create"
  11. // curl -X GET "http://localhost:31000/example/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/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":"ed3f9cffdcfe4984ac72425b447b7ce6", "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=ed3f9cffdcfe4984ac72425b447b7ce6"
  18. // curl -X DELETE "http://localhost:31000/example/v1/class/ed3f9cffdcfe4984ac72425b447b7ce6/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. // curl -X GET "http://localhost:31000/example/v1/student/family/queryWith?id=fc3e96926aac46268ae783c4ad675d43"
  35. // Family-Student
  36. // curl -X POST -H "Content-Type: application/json" -d '{"id":"ed86bbb59a80429eb654d7f9f13ff116", "studentId": "fc3e96926aac46268ae783c4ad675d43"}' "http://localhost:31000/example/v1/family/student/update"
  37. // curl -X GET "http://localhost:31000/example/v1/family/student/query?id=ed86bbb59a80429eb654d7f9f13ff116"
  38. // curl -X GET "http://localhost:31000/example/v1/family/student/queryWith?id=ed86bbb59a80429eb654d7f9f13ff116"
  39. func main() {
  40. application.NewApp()
  41. defer application.DestroyApp()
  42. go func() {
  43. err := application.Start()
  44. if err != nil {
  45. panic(err)
  46. }
  47. }()
  48. defer func() {
  49. err := application.Finish()
  50. if err != nil {
  51. panic(err)
  52. }
  53. }()
  54. death := DEATH.NewDeath(syscall.SIGINT, syscall.SIGTERM)
  55. _ = death.WaitForDeath()
  56. }