route.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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-company-gateway/controller/v1"
  8. _ "property-company-gateway/docs"
  9. "property-company-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. engine.POST("/api/v1/company", c.CompanyRegister)
  28. engine.POST("/api/v1/upload", c.Upload)
  29. engine.POST("/api/v1/upload_wx", c.UploadWx)
  30. engine.PUT("/api/v1/user/reset_password", c.ResetPassword)
  31. engine.POST("/api/v1/user/login_by_phone", c.LoginByPhone)
  32. engine.GET("/api/v1/user/vcode", c.GetVcode)
  33. apiv1.PUT("/token_refresh", c.TokenRefresh)
  34. apiv1.Use(middleware.Jwt())
  35. statistic := apiv1.Group("/statistic")
  36. {
  37. statistic.GET("", c.CompanyStatistic)
  38. }
  39. user := apiv1.Group("/user")
  40. {
  41. user.PUT("/change_password", c.ChangePassword)
  42. }
  43. company := apiv1.Group("/company")
  44. {
  45. company.PUT("", c.CompanyUpdate)
  46. company.GET("", c.CompanyInfo)
  47. company.GET("/wx_account", c.CompanyWxAccountList)
  48. company.POST("/wx_account", c.CompanyWxAccountApply)
  49. company.GET("/wx_account_info", c.CompanyWxAccountApplyInfo)
  50. company.PUT("/garden_mch", c.GardenSetMch)
  51. company.PUT("/garden_paymode", c.GardenSetMchPayMode)
  52. company.GET("/garden_mch", c.CompanyMchGardenList)
  53. company.GET("/template", c.CompanyTemplate)
  54. }
  55. garden := apiv1.Group("/garden")
  56. {
  57. garden.POST("", c.CompanyAddGarden)
  58. garden.GET("", c.CompanyGardenList)
  59. garden.PUT("", c.CompanyGardenUpdate)
  60. garden.DELETE("", c.CompanyGardenDel)
  61. garden.GET("/entry", c.CompanyEnterGarden)
  62. garden.GET("/check", c.CompanyCanAddGarden)
  63. keyInfo := garden.Group("/key_info")
  64. {
  65. keyInfo.PUT("", c.GardenKeyInfoChange)
  66. keyInfo.GET("", c.GardenKeyInfoChangeList)
  67. }
  68. }
  69. companyUser := apiv1.Group("/company_user")
  70. {
  71. companyUser.POST("", c.CompanyUserAdd)
  72. companyUser.PUT("", c.CompanyUserUpdate)
  73. companyUser.DELETE("", c.CompanyUserDel)
  74. companyUser.GET("", c.CompanyUserList)
  75. }
  76. area := apiv1.Group("/area")
  77. {
  78. area.GET("/province_city_area", c.ProvinceCityArea)
  79. area.GET("/street_committee", c.StreetCommittee)
  80. }
  81. application := apiv1.Group("/application")
  82. {
  83. application.GET("", c.ApplicationList)
  84. }
  85. cpackage := apiv1.Group("/package")
  86. {
  87. cpackage.GET("", c.PackageList)
  88. }
  89. order := apiv1.Group("/order")
  90. {
  91. order.GET("/package", c.CompanyPackageList)
  92. order.POST("/package", c.PackageOrderAdd)
  93. order.POST("/renew", c.PackageOrderAddRenew)
  94. order.GET("/package_for_garden", c.CompanyPackageListForGarden)
  95. }
  96. }
  97. }