route.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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-site-management-gateway/controller/v1"
  8. _ "smart-site-management-gateway/docs"
  9. "smart-site-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("/user/mail", c.MailUpdate)
  29. engine.POST("/api/v1/user/login_front", c.LoginFront)
  30. engine.GET("/api/v1/user/captcha_id", c.CaptchaId)
  31. engine.GET("/api/v1/user/captcha_png/:captcha_id", c.CaptchaPng)
  32. engine.GET("/api/v1/camera/ping", c.VedioPing)
  33. apiv1.PUT("/token_refresh", c.TokenRefresh)
  34. apiv1.Use(middleware.Jwt())
  35. user := apiv1.Group("/user")
  36. {
  37. user.PUT("/change_passwd", c.ChangePasswd)
  38. user.GET("/permission", c.UserPermission)
  39. user.PUT("/verify_mail", c.MailPrepare)
  40. user.PUT("/phone", c.PhoneUpdate)
  41. user.GET("/info", c.UserInfo)
  42. }
  43. project := apiv1.Group("/project")
  44. {
  45. project.GET("/fields", c.ProjectInfoForChange)
  46. project.PUT("", c.ProjectChange)
  47. project.PUT("/device_approve", c.DeviceApprove)
  48. project.GET("/change_job_list", c.ProjectChangeInfoList)
  49. project.DELETE("/progress/:id", c.ProjectProgressDel)
  50. project.GET("/progress_list", c.ProjectProgress)
  51. project.GET("/info", c.ProjectInfo)
  52. project.GET("/device_statistics", c.ProjectDeviceStatistics)
  53. project.POST("/progress", c.ProjectProgressAdd)
  54. project.PUT("/progress", c.ProjectProgressSet)
  55. project.PUT("/pic", c.ProjectSetPic)
  56. project.PUT("/name_location", c.ProjectUpdate)
  57. }
  58. device := apiv1.Group("/device")
  59. {
  60. device.GET("/list", c.DeviceList)
  61. //device.GET("/camera", c.DeviceCamera)
  62. device.GET("/apply_list", c.DeviceApplyList)
  63. device.GET("/vedio_list", c.DeviceVedioList)
  64. device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
  65. device.GET("/vedio_channel_unbind", c.DeviceVedioChannelUnbindList)
  66. device.GET("/vedio_channel", c.DeviceVideoChannel)
  67. device.PUT("/vedio_channel", c.ChannelUpdate)
  68. }
  69. vehicle := apiv1.Group("/vehicle")
  70. {
  71. vehicle.GET("/list", c.VehicleList)
  72. }
  73. staff := apiv1.Group("/staff")
  74. {
  75. staff.GET("/last", c.LatestStaffData)
  76. staff.GET("/type_statistics", c.StaffTypeStatistics)
  77. staff.GET("/work_type_statistics", c.StaffWorkTypeStatistics)
  78. staff.GET("/company_statistics", c.LaborCompanyStatistics)
  79. staff.GET("/list", c.StaffList)
  80. staff.GET("/attendance", c.StaffAttendance)
  81. }
  82. dust := apiv1.Group("/dust")
  83. {
  84. dust.GET("/last", c.LatestDustMonitorData)
  85. dust.GET("/history", c.DustMonitorHistory)
  86. dust.GET("/list", c.DustList)
  87. dust.GET("/aqi", c.DustAqi)
  88. }
  89. tower := apiv1.Group("/iot")
  90. {
  91. tower.GET("/tower_last", c.LatestTowerMonitorData)
  92. tower.GET("/tower_history", c.TowerMonitorHistory)
  93. tower.GET("/list", c.IotList)
  94. tower.GET("/type_list", c.IotTypeList)
  95. tower.GET("/last", c.IotLast)
  96. }
  97. alarm := apiv1.Group("/alarm")
  98. {
  99. alarm.GET("/list", c.AlarmList)
  100. alarm.POST("/rule", c.AlarmRuleAdd)
  101. alarm.GET("/rule_list", c.AlarmRuleList)
  102. alarm.DELETE("/rule_delete/:id", c.AlarmRuleDelete)
  103. alarm.PUT("/rule_on_off", c.AlarmRuleOnOff)
  104. alarm.PUT("/rule", c.AlarmRuleUpdate)
  105. alarm.POST("/contact", c.AlarmContactAdd)
  106. alarm.PUT("/contact", c.AlarmContactUpdate)
  107. alarm.GET("/contact_list", c.AlarmContactList)
  108. alarm.DELETE("/contact_delete/:id", c.AlarmContactDelete)
  109. }
  110. camera := apiv1.Group("/camera")
  111. {
  112. camera.PUT("/bind_device", c.DeviceBindCamera)
  113. camera.PUT("/unbind_device", c.DeviceUnbindCamera)
  114. camera.GET("/real_play", c.RealPlay)
  115. camera.GET("/ptz", c.Ptz)
  116. }
  117. oplog := apiv1.Group("log")
  118. {
  119. oplog.GET("/list", c.LogList)
  120. }
  121. }
  122. }