route.go 2.4 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-enterprise-management-gateway/controller/v1"
  8. _ "smart-enterprise-management-gateway/docs"
  9. "smart-enterprise-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-site-supplier"))
  22. // version 1
  23. apiv1 := engine.Group("/api/v1")
  24. {
  25. c := v1.NewController()
  26. apiv1.POST("/upload", c.Upload)
  27. apiv1.GET("/vcode", c.Vcode)
  28. apiv1.GET("/map", c.Map)
  29. apiv1.GET("/publicity", c.Publicity)
  30. apiv1.GET("/device_type_all", c.DeviceTypeAll)
  31. apiv1.GET("/user/mail", c.MailUpdate)
  32. engine.POST("/api/v1/user/register", c.Register)
  33. engine.POST("/api/v1/user/login", c.Login)
  34. engine.PUT("/api/v1/user/set_passwd", c.SetPasswd)
  35. engine.GET("/api/v1/user/status", c.CompanyApproveStatus)
  36. engine.GET("/api/v1/user/captcha_id", c.CaptchaId)
  37. engine.GET("/api/v1/project/district", c.ProjectDistrict)
  38. engine.GET("/api/v1/user/captcha_png/:captcha_id", c.CaptchaPng)
  39. apiv1.PUT("/token_refresh", c.TokenRefresh)
  40. apiv1.Use(middleware.Jwt())
  41. user := apiv1.Group("/user")
  42. {
  43. user.PUT("/change_passwd", c.ChangePasswd)
  44. user.PUT("/verify_mail", c.MailPrepare)
  45. user.PUT("/phone", c.PhoneUpdate)
  46. user.GET("/info", c.UserInfo)
  47. user.GET("/tmp_token", c.TmpToken)
  48. }
  49. project := apiv1.Group("/project")
  50. {
  51. project.PUT("/user", c.EnableProjectUser)
  52. project.POST("", c.ProjectAdd)
  53. project.PUT("", c.ProjectUpdate)
  54. project.GET("/user_list", c.ProjectUserList)
  55. project.GET("/list", c.ProjectList)
  56. project.PUT("/password", c.ProjectUserPasswordReset)
  57. project.GET("/info/:id", c.ProjectInfo)
  58. project.DELETE("/:id", c.ProjectDel)
  59. project.PUT("/finish/:id", c.ProjectFinish)
  60. }
  61. device := apiv1.Group("/device")
  62. {
  63. device.GET("/type_list", c.DeviceTypeList)
  64. device.GET("/list", c.DeviceList)
  65. device.GET("/vedio_list", c.DeviceVedioList)
  66. device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
  67. }
  68. oplog := apiv1.Group("log")
  69. {
  70. oplog.GET("/list", c.LogList)
  71. }
  72. }
  73. }