route.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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-system-gateway/controller/v1"
  8. _ "property-system-gateway/docs"
  9. "property-system-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/upload", c.Upload)
  28. engine.POST("/api/v1/openim_upload", c.OpenimUpload)
  29. engine.PUT("/api/v1/user/reset_password", c.ResetPassword)
  30. engine.POST("/api/v1/user/login_by_phone", c.LoginByPhone)
  31. engine.GET("/api/v1/user/vcode", c.GetVcode)
  32. apiv1.PUT("/token_refresh", c.TokenRefresh)
  33. apiv1.Use(middleware.Jwt())
  34. statistic := apiv1.Group("/statistic")
  35. {
  36. statistic.GET("", c.Statistic)
  37. }
  38. material := apiv1.Group("/material")
  39. {
  40. material.GET("/info", c.MaterialInfo)
  41. material.GET("/list", c.MaterialList)
  42. }
  43. person := apiv1.Group("person")
  44. {
  45. person.GET("", c.PersonInfo)
  46. person.PUT("", c.PersonInfoUpdate)
  47. }
  48. service := apiv1.Group("/service")
  49. {
  50. vote := service.Group("/vote")
  51. {
  52. vote.POST("", c.VoteAdd)
  53. vote.PUT("", c.VoteUpdate)
  54. vote.DELETE("", c.VoteDel)
  55. vote.GET("", c.VoteList)
  56. vote.GET("/result", c.VoteResultList)
  57. vote.GET("/result/statistic", c.VoteResultStatistic)
  58. }
  59. event := service.Group("/event")
  60. {
  61. event.POST("", c.EventAdd)
  62. event.PUT("", c.EventUpdate)
  63. event.GET("", c.EventList)
  64. event.DELETE("", c.EventDel)
  65. sign := event.Group("/sign")
  66. {
  67. sign.GET("", c.EventSignList)
  68. sign.DELETE("", c.EventSignDel)
  69. }
  70. }
  71. announcement := service.Group("/announcement")
  72. {
  73. announcement.POST("", c.AnnouncementAdd)
  74. announcement.PUT("", c.AnnouncementUpdate)
  75. announcement.GET("", c.AnnouncementList)
  76. announcement.DELETE("", c.AnnouncementDel)
  77. }
  78. neighbor := service.Group("/neighbor")
  79. {
  80. neighbor.POST("/class", c.NeighborClassAdd)
  81. neighbor.PUT("/class", c.NeighborClassUpdate)
  82. neighbor.DELETE("/class", c.NeighborClassDel)
  83. neighbor.GET("/class", c.NeighborClassList)
  84. neighbor.DELETE("/article", c.NeighborArticleDel)
  85. neighbor.GET("/article", c.NeighborArticleList)
  86. neighbor.DELETE("/comment", c.NeighborCommentDel)
  87. neighbor.GET("/comment", c.NeighborCommentList)
  88. }
  89. }
  90. user := apiv1.Group("/user")
  91. {
  92. user.GET("/choose_user", c.ChooseUser)
  93. user.PUT("/change_password", c.ChangePassword)
  94. user.POST("/company_login", c.CompanyEnterGarden)
  95. user.GET("/permission_reget", c.PermissionReget)
  96. user.GET("/openim_token", c.OpenImToken)
  97. user.GET("/openim_user_info", c.OpenImUserInfo)
  98. user.GET("/openim_users_info", c.OpenImUsersInfo)
  99. user.PUT("/openim_user_face", c.OpenImUserSetFace)
  100. }
  101. gate := apiv1.Group("/gate")
  102. {
  103. gate.GET("", c.GateList)
  104. gate.PUT("/enable", c.GateEnable)
  105. gate.PUT("/set", c.GateSet)
  106. gate.GET("/record", c.GateRecordList)
  107. gate.GET("/visitor", c.GateVisitorList)
  108. unit := gate.Group("/unit")
  109. {
  110. unit.GET("", c.GateUnitList)
  111. unit.POST("", c.GateUnitAdd)
  112. }
  113. card := gate.Group("/card")
  114. {
  115. card.GET("/devices", c.GateCardCanBindDevices)
  116. card.GET("", c.GateCardList)
  117. card.POST("", c.GateCardAdd)
  118. card.PUT("", c.GateCardSync)
  119. card.DELETE("", c.GateCardDel)
  120. }
  121. pic := gate.Group("/pic")
  122. {
  123. pic.GET("", c.GateUserPicList)
  124. pic.PUT("/approve", c.GateUserPicApprove)
  125. pic.PUT("", c.GateUserPicSync)
  126. pic.DELETE("", c.GateUserPicDel)
  127. }
  128. command := gate.Group("/command")
  129. {
  130. command.POST("/open", c.GateOpen)
  131. command.POST("/restart", c.GateRestart)
  132. command.GET("", c.GateCommandList)
  133. }
  134. }
  135. garden := apiv1.Group("/garden")
  136. {
  137. garden.GET("", c.GardenInfo)
  138. garden.PUT("", c.GardenUpdate)
  139. keyInfo := garden.Group("/key_info")
  140. {
  141. keyInfo.PUT("", c.GardenKeyInfoChange)
  142. keyInfo.GET("", c.GardenKeyInfoChangeList)
  143. }
  144. }
  145. charge := apiv1.Group("/charge")
  146. {
  147. // 物业费套餐
  148. propertyPackage := charge.Group("/property_package")
  149. {
  150. propertyPackage.POST("", c.PropertyPackageAdd)
  151. propertyPackage.PUT("", c.PropertyPackageUpdate)
  152. propertyPackage.DELETE("", c.PropertyPackageDel)
  153. propertyPackage.GET("", c.PropertyPackageList)
  154. }
  155. // 费项配置
  156. conf := charge.Group("/conf")
  157. {
  158. conf.POST("", c.ChargeConfAdd)
  159. conf.PUT("", c.ChargeConfUpdate)
  160. conf.DELETE("", c.ChargeConfDel)
  161. conf.GET("", c.ChargeConfList)
  162. }
  163. // 抄表
  164. power := charge.Group("/power")
  165. {
  166. power.POST("/batch", c.PowerRecordBatchAdd)
  167. power.POST("", c.PowerRecordAdd)
  168. power.DELETE("", c.PowerRecordDel)
  169. power.GET("", c.PowerRecordList)
  170. power.GET("/template", c.ChargePowerTemplate)
  171. }
  172. // 绑定费用
  173. charge.PUT("/bind", c.ChargeBind)
  174. // 解绑费用
  175. charge.PUT("/unbind", c.ChargeUnbind)
  176. // 获取催缴信息
  177. charge.GET("/urge", c.ChargeUrgeInfo)
  178. charge.GET("/batch_urge", c.BatchUrge)
  179. // 催缴配置
  180. charge.PUT("/urge", c.ChargeUrgeSet)
  181. house := charge.Group("/house")
  182. {
  183. // 已绑定某费项的房屋列表
  184. house.GET("/binded_list", c.ChargeHouseBindedList)
  185. // 可以绑定某费项的房屋列表
  186. house.GET("/can_bind_list", c.ChargeHouseNotBindList)
  187. }
  188. space := charge.Group("/space")
  189. {
  190. // 已绑定某费项的车位列表
  191. space.GET("/binded_list", c.ChargeSpaceBindedList)
  192. // 可以绑定某费项的车位列表
  193. space.GET("/can_bind_list", c.ChargeSpaceNotBindList)
  194. }
  195. vehicle := charge.Group("/vehicle")
  196. {
  197. // 已绑定某费项的车辆列表
  198. vehicle.GET("/binded_list", c.ChargeVehicleBindedList)
  199. // 可以绑定某费项的车辆列表
  200. vehicle.GET("/can_bind_list", c.ChargeVehicleNotBindList)
  201. }
  202. objCharge := charge.Group("/obj_charge")
  203. {
  204. // 房屋收费房屋列表
  205. objCharge.GET("/house_list", c.ChargeHouseGroup)
  206. // 车位收费 车位列表
  207. objCharge.GET("/space_list", c.ChargeSpaceGroup)
  208. // 车辆收费车辆列表
  209. objCharge.GET("/vehicle_list", c.ChargeVehicleGroup)
  210. // 欠费缴费线下支付
  211. objCharge.PUT("/pay", c.ChargeBillPay)
  212. // 欠费缴费欠费项目列表
  213. objCharge.GET("/unpay_list", c.ChargeUnpayList)
  214. // 查看费用 费项列表
  215. objCharge.GET("/charge_list", c.ChargeList)
  216. // 对象下的某费项下的账单列表
  217. objCharge.GET("/bill_list", c.ChargeBillList)
  218. // 变更时间
  219. objCharge.PUT("/time", c.ChargeTimeSet)
  220. // 手动生成账单
  221. objCharge.PUT("/bill", c.ChargeGenerateBill)
  222. // 获取小票或收据信息
  223. objCharge.GET("/ticket", c.ChargeOrderTicket)
  224. // 物业或车位费预支付前获取金额信息
  225. objCharge.GET("/pre_pay_info", c.ChargePrePayInfo)
  226. // 物业或车位费预支付
  227. objCharge.PUT("/pre_pay", c.ChargePrePay)
  228. }
  229. unpayBill := charge.Group("/unpay_bill")
  230. {
  231. // 应收账单对象列表
  232. unpayBill.GET("/obj_list", c.ChargeBillObjList)
  233. // 对象下的账单列表
  234. unpayBill.GET("/obj_bill_list", c.ChargeObjBillList)
  235. // 作废账单
  236. unpayBill.PUT("/discard", c.ChargeDelBill)
  237. unpayBill.POST("/urge", c.ChargeUrge)
  238. }
  239. payedBill := charge.Group("/payed_bill")
  240. {
  241. // 已缴账单
  242. payedBill.GET("/list", c.ChargePayedBillList)
  243. }
  244. discardBill := charge.Group("/discard_bill")
  245. {
  246. // 作废账单列表
  247. discardBill.GET("/list", c.ChargeDelBillList)
  248. // 恢复账单
  249. discardBill.PUT("/recover", c.ChargeRecoverBill)
  250. }
  251. order := charge.Group("/order")
  252. {
  253. // 订单列表
  254. order.GET("/list", c.ChargeOrderList)
  255. // 订单详情
  256. order.GET("/info", c.ChargeOrderInfo)
  257. // 确认订单已支付
  258. order.PUT("/confirm", c.ChargeOrderPay)
  259. }
  260. }
  261. application := apiv1.Group("/application")
  262. {
  263. application.GET("", c.ApplicationList)
  264. }
  265. msgPackage := apiv1.Group("msg_package")
  266. {
  267. msgPackage.GET("", c.MsgPackageList)
  268. msgPackage.GET("/order", c.MsgPackageOrderList)
  269. msgPackage.POST("/order", c.MsgPackageOrderAdd)
  270. }
  271. order := apiv1.Group("/order")
  272. {
  273. order.POST("/application", c.ApplicationOrderAdd)
  274. order.GET("/application", c.GardenApplicationList)
  275. }
  276. systemUser := apiv1.Group("/system_user")
  277. {
  278. systemUser.POST("", c.UserAdd)
  279. systemUser.PUT("", c.UserUpdate)
  280. systemUser.DELETE("", c.UserDel)
  281. systemUser.GET("", c.UserList)
  282. }
  283. permission := apiv1.Group("/permission")
  284. {
  285. permission.GET("/all", c.AllPermission)
  286. permission.GET("/group_list", c.GroupList)
  287. permission.GET("/group_info", c.GroupInfo)
  288. permission.POST("/group", c.GroupAdd)
  289. permission.PUT("/group", c.GroupUpdate)
  290. permission.DELETE("/group", c.GroupDel)
  291. }
  292. household := apiv1.Group("/household")
  293. {
  294. household.GET("/list", c.HouseholdList)
  295. household.PUT("/approve", c.HouseholdApprove)
  296. household.GET("/user_list", c.HouseholdUserList)
  297. }
  298. park := apiv1.Group("/park")
  299. {
  300. park.POST("", c.ParkAdd)
  301. park.PUT("", c.ParkUpdate)
  302. park.DELETE("", c.ParkDel)
  303. park.GET("", c.ParkList)
  304. park.POST("/space", c.ParkSpaceAdd)
  305. park.PUT("/space", c.ParkSpaceUpdate)
  306. park.DELETE("/space", c.ParkSpaceDel)
  307. park.GET("/space", c.ParkSpaceList)
  308. }
  309. department := apiv1.Group("/department")
  310. {
  311. department.POST("", c.DepartmentAdd)
  312. department.PUT("", c.DepartmentUpdate)
  313. department.DELETE("", c.DepartmentDel)
  314. department.GET("", c.DepartmentList)
  315. }
  316. vehicle := apiv1.Group("/vehicle")
  317. {
  318. vehicle.POST("", c.VehicleAdd)
  319. vehicle.PUT("", c.VehicleUpdate)
  320. vehicle.DELETE("", c.VehicleDel)
  321. vehicle.GET("", c.VehicleList)
  322. vehicle.GET("/brand", c.VehicleBrandList)
  323. }
  324. buildings := apiv1.Group("/buildings")
  325. {
  326. manager := buildings.Group("/manager")
  327. {
  328. manager.GET("", c.BuildingManagerList)
  329. manager.POST("", c.BuildingAddManager)
  330. manager.DELETE("", c.BuildingDelManager)
  331. }
  332. buildings.POST("/building", c.BuildingAdd)
  333. buildings.PUT("/building", c.BuildingUpdate)
  334. buildings.GET("/building", c.BuildingList)
  335. buildings.DELETE("/building", c.BuildingDel)
  336. buildings.POST("/unit", c.UnitAdd)
  337. buildings.PUT("/unit", c.UnitUpdate)
  338. buildings.GET("/unit", c.UnitList)
  339. buildings.DELETE("/unit", c.UnitDel)
  340. buildings.POST("/house", c.HouseAdd)
  341. buildings.PUT("/house", c.HouseUpdate)
  342. buildings.GET("/house", c.HouseList)
  343. buildings.DELETE("/house", c.HouseDel)
  344. buildings.POST("/building/import", c.BuildingImport)
  345. buildings.POST("/unit/import", c.UnitImport)
  346. buildings.POST("/house/import", c.HouseImport)
  347. buildings.GET("/building/template", c.BuildingTemplate)
  348. buildings.GET("/unit/template", c.UnitTemplate)
  349. buildings.GET("/house/template", c.HouseTemplate)
  350. }
  351. systemMsg := apiv1.Group("/system_msg")
  352. {
  353. systemMsg.GET("/list", c.SystemMsgList)
  354. systemMsg.PUT("", c.SystemMsgReaded)
  355. }
  356. servicePhone := apiv1.Group("/service_phone")
  357. {
  358. class := servicePhone.Group("/class")
  359. {
  360. class.POST("", c.ServicePhoneClassAdd)
  361. class.PUT("", c.ServicePhoneClassUpdate)
  362. class.GET("", c.ServicePhoneClassList)
  363. class.DELETE("", c.ServicePhoneClassDel)
  364. }
  365. servicePhone.POST("", c.ServicePhoneAdd)
  366. servicePhone.PUT("", c.ServicePhoneUpdate)
  367. servicePhone.GET("", c.ServicePhoneList)
  368. servicePhone.DELETE("", c.ServicePhoneDel)
  369. }
  370. repair := apiv1.Group("/repair")
  371. {
  372. class := repair.Group("/class")
  373. {
  374. class.POST("", c.RepairClassAdd)
  375. class.PUT("", c.RepairClassUpdate)
  376. class.GET("", c.RepairClassList)
  377. class.DELETE("", c.RepairClassDel)
  378. }
  379. order := repair.Group("/order")
  380. {
  381. order.POST("", c.RepairOrderAdd)
  382. order.PUT("", c.RepairOrderUpdate)
  383. order.GET("", c.RepairOrderList)
  384. order.DELETE("", c.RepairOrderDel)
  385. order.GET("/info", c.RepairOrderInfo)
  386. order.PUT("/send", c.RepairOrderSend)
  387. order.PUT("/finish", c.RepairOrderFinish)
  388. order.PUT("/back", c.RepairOrderBack)
  389. order.PUT("/return_visit", c.RepairOrderReturnVisit)
  390. }
  391. }
  392. suggestion := apiv1.Group("/suggestion")
  393. {
  394. order := suggestion.Group("/order")
  395. {
  396. order.POST("", c.SuggestionOrderAdd)
  397. order.PUT("", c.SuggestionOrderUpdate)
  398. order.GET("", c.SuggestionOrderList)
  399. order.DELETE("", c.SuggestionOrderDel)
  400. order.GET("/info", c.SuggestionOrderInfo)
  401. order.PUT("/send", c.SuggestionOrderSend)
  402. order.PUT("/finish", c.SuggestionOrderFinish)
  403. order.PUT("/back", c.SuggestionOrderBack)
  404. order.PUT("/return_visit", c.SuggestionOrderReturnVisit)
  405. }
  406. }
  407. rent := apiv1.Group("/rent")
  408. {
  409. house := rent.Group("/house")
  410. {
  411. house.GET("", c.HouseRentList)
  412. house.POST("", c.HouseRentApply)
  413. house.PUT("", c.HouseRentUpdate)
  414. house.PUT("/approve", c.HouseRentApprove)
  415. house.PUT("/down", c.HouseRentDown)
  416. manager := house.Group("/manager")
  417. {
  418. manager.GET("", c.HouseRentManagerList)
  419. manager.POST("", c.HouseRentAddManager)
  420. manager.DELETE("", c.HouseRentDelManager)
  421. }
  422. appointment := house.Group("/appointment")
  423. {
  424. appointment.DELETE("", c.HouseRentAppointmentDel)
  425. appointment.GET("", c.HouseRentAppointmentList)
  426. appointment.PUT("", c.HouseRentAppointmentStatus)
  427. }
  428. }
  429. }
  430. }
  431. }