route.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package route
  4. import (
  5. "net/http"
  6. "github.com/gin-gonic/gin"
  7. "smart-supplier-management-gateway/controller/v1"
  8. _ "smart-supplier-management-gateway/docs"
  9. "smart-supplier-management-gateway/route/middleware"
  10. )
  11. func SetupRoute(engine *gin.Engine) {
  12. // 404页面
  13. engine.NoRoute(func(c *gin.Context) {
  14. c.String(http.StatusNotFound, "Not Found")
  15. })
  16. // 服务健康检查
  17. engine.GET("/ping", func(c *gin.Context) {
  18. // TODO 心跳检查
  19. c.String(http.StatusOK, "pong")
  20. })
  21. //engine.Use(middleware.Session("smart-supplier"))
  22. // version 1
  23. apiv1 := engine.Group("/api/v1")
  24. {
  25. c := v1.NewController()
  26. apiv1.POST("/upload", c.Upload)
  27. apiv1.GET("/publicity", c.Publicity)
  28. apiv1.GET("/device_type_all", c.DeviceTypeAll)
  29. apiv1.GET("/vcode", c.Vcode)
  30. apiv1.GET("/user/mail", c.MailUpdate)
  31. engine.POST("/api/v1/user/register", c.Register)
  32. engine.POST("/api/v1/user/login", c.Login)
  33. engine.PUT("/api/v1/user/set_passwd", c.SetPasswd)
  34. engine.GET("/api/v1/user/status", c.ProviderApproveStatus)
  35. engine.GET("/api/v1/user/captcha_id", c.CaptchaId)
  36. engine.GET("/api/v1/user/captcha_png/:captcha_id", c.CaptchaPng)
  37. apiv1.PUT("/token_refresh", c.TokenRefresh)
  38. apiv1.Use(middleware.Jwt())
  39. user := apiv1.Group("/user")
  40. {
  41. user.PUT("/change_passwd", c.ChangePasswd)
  42. user.PUT("/verify_mail", c.MailPrepare)
  43. user.PUT("/phone", c.PhoneUpdate)
  44. user.GET("/info", c.UserInfo)
  45. user.GET("/provider_info", c.ProviderInfo)
  46. }
  47. device := apiv1.Group("/device")
  48. {
  49. device.POST("/type", c.DeviceTypeAdd)
  50. device.POST("/type_testing", c.DeviceTypeTestingAdd)
  51. device.POST("/dust", c.DeviceDustAdd)
  52. device.DELETE("", c.DeviceDel)
  53. device.GET("/type_list", c.DeviceTypeList)
  54. device.GET("/default_type_list", c.DeviceDefaultTypeList)
  55. device.GET("/dust_list", c.DeviceDustList)
  56. device.GET("/can_del_list", c.DeviceCanDelList)
  57. device.GET("/vedio_list", c.DeviceVedioList)
  58. device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
  59. device.POST("/vedio", c.VedioAdd)
  60. device.POST("/vedio_channel", c.ChannelAdd)
  61. device.PUT("/vedio_channel", c.ChannelUpdate)
  62. device.GET("/del_job_list", c.DeviceDelJobList)
  63. device.POST("/attendance", c.DeviceAttendanceAdd)
  64. device.GET("/attendance_list", c.DeviceAttendanceList)
  65. }
  66. project := apiv1.Group("project")
  67. {
  68. project.GET("/list", c.ProjectList)
  69. }
  70. oplog := apiv1.Group("log")
  71. {
  72. oplog.GET("/list", c.LogList)
  73. }
  74. }
  75. }