route.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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-household-gateway/controller/v1"
  8. _ "property-household-gateway/docs"
  9. "property-household-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.GET("/warning", func(c *gin.Context) {
  22. //
  23. c.String(http.StatusOK, "微信版本过低,无法打开小程序,请下载新版微信")
  24. })
  25. //engine.Use(middleware.Session("smart-site-supplier"))
  26. // version 1
  27. apiv1 := engine.Group("/api/v1")
  28. {
  29. c := v1.NewController()
  30. engine.POST("/api/v1/user/login", c.Login)
  31. engine.POST("/api/v1/upload", c.Upload)
  32. engine.POST("/api/v1/openim_upload", c.OpenimUpload)
  33. engine.GET("/api/v1/gate/visitor/share", c.GateVisitorPage)
  34. apiv1.PUT("/token_refresh", c.TokenRefresh)
  35. apiv1.Use(middleware.Jwt())
  36. user := apiv1.Group("/user")
  37. {
  38. user.PUT("/real_name_auth", c.RealNameAuth)
  39. user.PUT("/nick_name", c.UserUpdateNickName)
  40. user.GET("/info", c.UserInfo)
  41. user.GET("/house", c.HouseholdHouses)
  42. user.GET("/space", c.HouseholdSpace)
  43. user.GET("/vehicle", c.HouseholdVehicle)
  44. user.GET("/openim_token", c.OpenImToken)
  45. user.GET("/openim_users_info", c.OpenImUsersInfo)
  46. }
  47. material := apiv1.Group("/material")
  48. {
  49. material.GET("/info", c.MaterialInfo)
  50. material.GET("/list", c.MaterialList)
  51. }
  52. service := apiv1.Group("/service")
  53. {
  54. vote := service.Group("/vote")
  55. {
  56. vote.GET("", c.VoteListForHousehold)
  57. vote.POST("/answer", c.VoteAddAnswer)
  58. vote.GET("/result/statistic", c.VoteResultStatistic)
  59. }
  60. event := service.Group("/event")
  61. {
  62. event.GET("", c.EventList)
  63. sign := event.Group("/sign")
  64. {
  65. sign.POST("", c.EventSignAdd)
  66. }
  67. }
  68. announcement := service.Group("/announcement")
  69. {
  70. announcement.GET("", c.AnnouncementList)
  71. announcement.PUT("/read_count", c.AnnouncementReadAdd)
  72. }
  73. neighbor := service.Group("/neighbor")
  74. {
  75. neighbor.GET("/class", c.NeighborClassList)
  76. neighbor.POST("/article", c.NeighborArticleAdd)
  77. neighbor.PUT("/article", c.NeighborArticleUpdate)
  78. neighbor.DELETE("/article", c.NeighborArticleDel)
  79. neighbor.GET("/article", c.NeighborArticleList)
  80. neighbor.POST("/comment", c.NeighborCommentAdd)
  81. neighbor.PUT("/comment", c.NeighborCommentUpdate)
  82. neighbor.DELETE("/comment", c.NeighborCommentDel)
  83. neighbor.GET("/comment", c.NeighborCommentList)
  84. neighbor.PUT("/like", c.NeighborLike)
  85. }
  86. }
  87. gate := apiv1.Group("/gate")
  88. {
  89. gate.GET("", c.GateList)
  90. gate.GET("/qcode", c.GateQcode)
  91. gate.GET("/qcode_visitor", c.GateQcodeVisitor)
  92. gate.GET("/visitor", c.GateVisitorList)
  93. gate.DELETE("/visitor", c.GateVisitorDel)
  94. gate.GET("/face", c.GateUserPicInfo)
  95. gate.POST("/face", c.GateUserPicAdd)
  96. gate.GET("/has_face_device", c.GateHasFace)
  97. }
  98. charge := apiv1.Group("/charge")
  99. {
  100. charge.PUT("/pay_test", c.ChargeWxPayTest)
  101. charge.PUT("/pay", c.ChargeBillPayByHousehold)
  102. charge.PUT("/pre_pay", c.ChargePrePayByHousehold)
  103. charge.GET("/months/property", c.ChargePropertyMonthInfo)
  104. charge.GET("/months/space", c.ChargeSpaceMonthInfo)
  105. charge.GET("/months/vehicle", c.ChargeVehicleMonthInfo)
  106. charge.GET("/bill_list", c.ChargeBillList)
  107. charge.GET("/charge_list", c.ChargeList)
  108. charge.GET("/unpay_list", c.ChargeUnpayList)
  109. charge.GET("/pre_pay_info", c.ChargePrePayInfo)
  110. charge.GET("/payed_bill_list", c.ChargePayedBillList)
  111. order := charge.Group("/order")
  112. {
  113. // 订单列表
  114. order.GET("/list", c.ChargeOrderList)
  115. // 订单详情
  116. order.GET("/info", c.ChargeOrderInfo)
  117. order.PUT("/cancel", c.ChargeOrderCancel)
  118. }
  119. }
  120. area := apiv1.Group("/area")
  121. {
  122. area.GET("/province_city_area", c.ProvinceCityArea)
  123. area.GET("/street_committee", c.StreetCommittee)
  124. area.GET("/city", c.City)
  125. }
  126. garden := apiv1.Group("/garden")
  127. {
  128. garden.GET("/info", c.GardenInfo)
  129. garden.GET("/list", c.GardenList)
  130. garden.GET("/building", c.BuildingList)
  131. garden.GET("/unit", c.UnitList)
  132. garden.GET("/house", c.HouseList)
  133. garden.GET("/buildings/manager", c.BuildingManagerList)
  134. }
  135. household := apiv1.Group("/household")
  136. {
  137. household.POST("/apply", c.HouseholdApply)
  138. household.GET("/house", c.HouseholdList)
  139. household.DELETE("/house", c.HouseholdDelHouse)
  140. }
  141. rent := apiv1.Group("/rent")
  142. {
  143. rent.GET("/garden_info", c.GardenHouseRentInfo)
  144. house := rent.Group("/house")
  145. {
  146. house.GET("", c.HouseRentList)
  147. house.POST("", c.HouseRentApply)
  148. house.PUT("", c.HouseRentUpdate)
  149. house.PUT("/down", c.HouseRentDown)
  150. manager := house.Group("/manager")
  151. {
  152. manager.GET("", c.HouseRentManagerList)
  153. }
  154. appointment := house.Group("/appointment")
  155. {
  156. appointment.POST("", c.HouseRentAppointmentAdd)
  157. appointment.GET("", c.HouseRentAppointmentList)
  158. appointment.DELETE("", c.HouseRentAppointmentDel)
  159. }
  160. }
  161. }
  162. servicePhone := apiv1.Group("/service_phone")
  163. {
  164. class := servicePhone.Group("/class")
  165. {
  166. class.GET("", c.ServicePhoneClassList)
  167. }
  168. servicePhone.GET("", c.ServicePhoneList)
  169. }
  170. repair := apiv1.Group("/repair")
  171. {
  172. class := repair.Group("/class")
  173. {
  174. class.GET("", c.RepairClassList)
  175. }
  176. order := repair.Group("/order")
  177. {
  178. order.POST("", c.RepairOrderAdd)
  179. order.PUT("", c.RepairOrderUpdate)
  180. order.GET("", c.RepairOrderList)
  181. order.GET("/info", c.RepairOrderInfo)
  182. order.PUT("/return_visit", c.RepairOrderReturnVisit)
  183. }
  184. }
  185. suggestion := apiv1.Group("/suggestion")
  186. {
  187. order := suggestion.Group("/order")
  188. {
  189. order.POST("", c.SuggestionOrderAdd)
  190. order.PUT("", c.SuggestionOrderUpdate)
  191. order.GET("", c.SuggestionOrderList)
  192. order.GET("/info", c.SuggestionOrderInfo)
  193. order.PUT("/return_visit", c.SuggestionOrderReturnVisit)
  194. }
  195. }
  196. }
  197. }