route.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. "property-management-gateway/controller/v1"
  8. _ "property-management-gateway/docs"
  9. "property-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. engine.POST("/api/v1/user/login", c.Login)
  27. apiv1.Use(middleware.Jwt())
  28. apiv1.POST("/upload", c.Upload)
  29. apiv1.PUT("/token_refresh", c.TokenRefresh)
  30. user := apiv1.Group("/user")
  31. {
  32. user.PUT("/password", nil)
  33. }
  34. gate := apiv1.Group("/gate")
  35. {
  36. gate.GET("", c.GateList)
  37. gate.GET("/protocols", c.GateProtocols)
  38. gate.POST("/in", c.GateIn)
  39. gate.PUT("/out", c.GateOut)
  40. gate.PUT("/recovery", c.GateRecovery)
  41. gate.DELETE("", c.GateDel)
  42. gate.GET("/template", c.GateTemplate)
  43. gate.POST("/import", c.GateImport)
  44. }
  45. company := apiv1.Group("/company")
  46. {
  47. company.POST("/register", c.CompanyRegister)
  48. company.PUT("/approve", c.CompanyApprove)
  49. company.GET("/list", c.CompanyList)
  50. company.PUT("/free_garden", c.CompanyChangeFreeGarden)
  51. company.GET("/wx_account", c.CompanyWxAccountList)
  52. company.GET("/wx_account_info", c.CompanyWxAccountApplyInfo)
  53. company.GET("/package", c.CompanyPackage)
  54. }
  55. systemPermission := apiv1.Group("/system_permission")
  56. {
  57. systemPermission.POST("", c.SystemPermissionAdd)
  58. systemPermission.PUT("", c.SystemPermissionUpdate)
  59. systemPermission.DELETE("", c.SystemPermissionDel)
  60. systemPermission.GET("", c.SystemPermissionList)
  61. systemPermission.PUT("/enable", c.SystemPermissionEnable)
  62. }
  63. material := apiv1.Group("/material")
  64. {
  65. material.POST("", c.MaterialAdd)
  66. material.PUT("", c.MaterialUpdate)
  67. material.DELETE("", c.MaterialDel)
  68. material.GET("", c.MaterialList)
  69. material.PUT("/enable", c.MaterialEnable)
  70. }
  71. application := apiv1.Group("/application")
  72. {
  73. application.POST("", c.ApplicationAdd)
  74. application.PUT("", c.ApplicationUpdate)
  75. application.DELETE("", c.ApplicationDel)
  76. application.GET("", c.ApplicationList)
  77. application.PUT("/enable", c.ApplicationEnableSet)
  78. application.PUT("/permissions", c.ApplicationPermissionsSet)
  79. application.GET("/permissions", c.ApplicationPermissions)
  80. }
  81. cpackage := apiv1.Group("/package")
  82. {
  83. cpackage.POST("", c.PackageAdd)
  84. cpackage.PUT("", c.PackageUpdate)
  85. cpackage.DELETE("", c.PackageDel)
  86. cpackage.GET("", c.PackageList)
  87. cpackage.PUT("/enable", c.PackageEnableSet)
  88. cpackage.PUT("/application", c.PackageApplicationSet)
  89. cpackage.GET("/application", c.PackageApplicationList)
  90. cpackage.GET("/application_can_add", c.PackageApplicationCanAddList)
  91. }
  92. msgPackage := apiv1.Group("/msg_package")
  93. {
  94. msgPackage.POST("", c.MsgPackageAdd)
  95. msgPackage.PUT("", c.MsgPackageUpdate)
  96. msgPackage.DELETE("", c.MsgPackageDel)
  97. msgPackage.GET("", c.MsgPackageList)
  98. }
  99. order := apiv1.Group("/order")
  100. {
  101. order.PUT("/application", c.ApplicationOrderApprove)
  102. order.GET("/application", c.GardenApplicationList)
  103. order.PUT("/package", c.PackageOrderApprove)
  104. order.GET("/package", c.CompanyPackageList)
  105. order.POST("/package", c.PackageOrderAdd)
  106. order.POST("/renew", c.PackageOrderAddRenew)
  107. order.PUT("/application/amount", c.ApplicationOrderAmount)
  108. order.PUT("/package/amount", c.PackageOrderAmount)
  109. order.PUT("/msg_package", c.MsgPackageOrderApprove)
  110. order.GET("/msg_package", c.MsgPackageOrderList)
  111. }
  112. area := apiv1.Group("/area")
  113. {
  114. area.GET("/province_city_area", c.ProvinceCityArea)
  115. area.GET("/street_committee", c.StreetCommittee)
  116. }
  117. garden := apiv1.Group("/garden")
  118. {
  119. garden.GET("", c.GardenList)
  120. garden.PUT("/company", c.GardenChangeCompany)
  121. garden.PUT("", c.GardenApprove)
  122. keyInfo := garden.Group("/key_info")
  123. keyInfo.GET("", c.GardenKeyInfoChangeList)
  124. keyInfo.PUT("", c.GardenKeyInfoApprove)
  125. garden.PUT("/enable", c.GardenEnableSet)
  126. }
  127. wx := apiv1.Group("/wx")
  128. {
  129. wx.POST("/public/mini", c.WxPublicAddMini)
  130. }
  131. }
  132. }