route.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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-government-management-gateway/controller/v1"
  8. _ "smart-government-management-gateway/docs"
  9. "smart-government-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("/map", c.Map)
  28. apiv1.GET("/publicity", c.Publicity)
  29. apiv1.GET("/device_type_all", c.DeviceTypeAll)
  30. apiv1.GET("/user/mail", c.MailUpdate)
  31. apiv1.GET("/area_code_limit", c.AreaCodeLimit)
  32. engine.POST("/api/v1/user/login", c.Login)
  33. apiv1.GET("/vcode", c.GetVcode)
  34. engine.PUT("/api/v1/user/set_passwd", c.SetPasswd)
  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.GET("/tmp_token", c.TmpToken)
  43. user.PUT("/verify_mail", c.MailPrepare)
  44. user.PUT("/phone", c.PhoneUpdate)
  45. user.GET("/info", c.UserInfo)
  46. }
  47. task := apiv1.Group("/task")
  48. {
  49. task.GET("/list", c.TaskList)
  50. task.POST("", c.TaskAdd)
  51. task.PUT("", c.TaskApprove)
  52. task.GET("/info/:id", c.TaskInfo)
  53. }
  54. device := apiv1.Group("/device")
  55. {
  56. device.GET("/type_list", c.DeviceTypeList)
  57. device.GET("/dust_list", c.DeviceDustList)
  58. device.GET("/attendance_list", c.DeviceAttendanceList)
  59. device.PUT("/type_approve", c.DeviceTypeApprove)
  60. device.PUT("/del_approve", c.DeviceDelApprove)
  61. device.GET("/del_job_list", c.DeviceDelJobList)
  62. device.GET("/vedio_list", c.DeviceVedioList)
  63. device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
  64. device.GET("/statistic", c.DeviceStatistic)
  65. device.GET("/type_statistic", c.DeviceTypeStatistic)
  66. device.GET("/tested_type_info/:id", c.DeviceTestedTypeInfo)
  67. }
  68. provider := apiv1.Group("/provider")
  69. {
  70. provider.GET("/list", c.ProviderList)
  71. provider.GET("/apply_list", c.ProviderApplyList)
  72. provider.PUT("/approve", c.ProviderApprove)
  73. }
  74. company := apiv1.Group("/company")
  75. {
  76. company.GET("/list", c.CompanyList)
  77. company.PUT("/approve", c.CompanyApprove)
  78. company.GET("/apply_list", c.CompanyApplyList)
  79. company.GET("/statistic", c.CompanyStatistic)
  80. }
  81. project := apiv1.Group("/project")
  82. {
  83. project.GET("/list", c.ProjectList)
  84. project.GET("/info/:id", c.ProjectInfo)
  85. project.GET("/change_job_list", c.ProjectChangeInfoList)
  86. //project.PUT("/approve", c.ProjectAddApprove)
  87. project.PUT("/change_approve", c.ProjectChangeApprove)
  88. project.GET("/statistic", c.ProjectStatistic)
  89. project.GET("/type_statistic", c.ProjectTypeStatistic)
  90. }
  91. staff := apiv1.Group("/staff")
  92. {
  93. staff.GET("/statistic", c.StaffStatistic)
  94. staff.GET("/type_statistic", c.StaffStatisticNew)
  95. }
  96. oplog := apiv1.Group("log")
  97. {
  98. oplog.GET("/list", c.LogList)
  99. }
  100. alarm := apiv1.Group("/alarm")
  101. {
  102. alarm.GET("/list", c.AlarmList)
  103. alarm.PUT("", c.AlarmHandle)
  104. alarm.GET("/statistic", c.AlarmStatistic)
  105. }
  106. dust := apiv1.Group("/dust")
  107. {
  108. dust.GET("/last", c.LatestDustMonitorData)
  109. dust.GET("/aqi", c.DustAqi)
  110. }
  111. }
  112. }