route.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. }
  46. device := apiv1.Group("/device")
  47. {
  48. device.POST("/docking", c.DeviceDocking)
  49. device.POST("", c.DeviceAdd)
  50. device.DELETE("", c.DeviceDel)
  51. device.GET("/type_list", c.DeviceTypeList)
  52. device.GET("/default_type_list", c.DeviceDefaultTypeList)
  53. device.GET("/list", c.DeviceList)
  54. device.GET("/can_del_list", c.DeviceCanDelList)
  55. device.GET("/vedio_list", c.DeviceVedioList)
  56. device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
  57. device.POST("/vedio", c.VedioAdd)
  58. device.POST("/vedio_channel", c.ChannelAdd)
  59. device.PUT("/vedio_channel", c.ChannelUpdate)
  60. device.GET("/del_job_list", c.DeviceDelJobList)
  61. }
  62. project := apiv1.Group("project")
  63. {
  64. project.GET("/list", c.ProjectList)
  65. }
  66. oplog := apiv1.Group("log")
  67. {
  68. oplog.GET("/list", c.LogList)
  69. }
  70. }
  71. }