// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package route import ( "net/http" "github.com/gin-gonic/gin" "property-system-gateway/controller/v1" _ "property-system-gateway/docs" "property-system-gateway/route/middleware" ) func SetupRoute(engine *gin.Engine) { // 404页面 engine.NoRoute(func(c *gin.Context) { c.String(http.StatusNotFound, "Not Found") }) // 服务健康检查 engine.GET("/ping", func(c *gin.Context) { // TODO 心跳检查 c.String(http.StatusOK, "pong") }) //engine.Use(middleware.Session("smart-site-supplier")) // version 1 apiv1 := engine.Group("/api/v1") { c := v1.NewController() engine.POST("/api/v1/user/login", c.Login) engine.POST("/api/v1/upload", c.Upload) engine.POST("/api/v1/openim_upload", c.OpenimUpload) engine.PUT("/api/v1/user/reset_password", c.ResetPassword) engine.POST("/api/v1/user/login_by_phone", c.LoginByPhone) engine.GET("/api/v1/user/vcode", c.GetVcode) apiv1.PUT("/token_refresh", c.TokenRefresh) apiv1.Use(middleware.Jwt()) statistic := apiv1.Group("/statistic") { statistic.GET("", c.Statistic) } material := apiv1.Group("/material") { material.GET("/info", c.MaterialInfo) material.GET("/list", c.MaterialList) } person := apiv1.Group("person") { person.GET("", c.PersonInfo) person.PUT("", c.PersonInfoUpdate) } service := apiv1.Group("/service") { vote := service.Group("/vote") { vote.POST("", c.VoteAdd) vote.PUT("", c.VoteUpdate) vote.DELETE("", c.VoteDel) vote.GET("", c.VoteList) vote.GET("/result", c.VoteResultList) vote.GET("/result/statistic", c.VoteResultStatistic) } event := service.Group("/event") { event.POST("", c.EventAdd) event.PUT("", c.EventUpdate) event.GET("", c.EventList) event.DELETE("", c.EventDel) sign := event.Group("/sign") { sign.GET("", c.EventSignList) sign.DELETE("", c.EventSignDel) } } announcement := service.Group("/announcement") { announcement.POST("", c.AnnouncementAdd) announcement.PUT("", c.AnnouncementUpdate) announcement.GET("", c.AnnouncementList) announcement.DELETE("", c.AnnouncementDel) } neighbor := service.Group("/neighbor") { neighbor.POST("/class", c.NeighborClassAdd) neighbor.PUT("/class", c.NeighborClassUpdate) neighbor.DELETE("/class", c.NeighborClassDel) neighbor.GET("/class", c.NeighborClassList) neighbor.DELETE("/article", c.NeighborArticleDel) neighbor.GET("/article", c.NeighborArticleList) neighbor.DELETE("/comment", c.NeighborCommentDel) neighbor.GET("/comment", c.NeighborCommentList) } } user := apiv1.Group("/user") { user.GET("/choose_user", c.ChooseUser) user.PUT("/change_password", c.ChangePassword) user.POST("/company_login", c.CompanyEnterGarden) user.GET("/permission_reget", c.PermissionReget) user.GET("/openim_token", c.OpenImToken) user.GET("/openim_user_info", c.OpenImUserInfo) user.GET("/openim_users_info", c.OpenImUsersInfo) user.PUT("/openim_user_face", c.OpenImUserSetFace) } gate := apiv1.Group("/gate") { gate.GET("", c.GateList) gate.PUT("/enable", c.GateEnable) gate.PUT("/set", c.GateSet) gate.GET("/record", c.GateRecordList) gate.GET("/visitor", c.GateVisitorList) unit := gate.Group("/unit") { unit.GET("", c.GateUnitList) unit.POST("", c.GateUnitAdd) } card := gate.Group("/card") { card.GET("/devices", c.GateCardCanBindDevices) card.GET("", c.GateCardList) card.POST("", c.GateCardAdd) card.PUT("", c.GateCardSync) card.DELETE("", c.GateCardDel) } pic := gate.Group("/pic") { pic.GET("", c.GateUserPicList) pic.PUT("/approve", c.GateUserPicApprove) pic.PUT("", c.GateUserPicSync) pic.DELETE("", c.GateUserPicDel) } command := gate.Group("/command") { command.POST("/open", c.GateOpen) command.POST("/restart", c.GateRestart) command.GET("", c.GateCommandList) } } garden := apiv1.Group("/garden") { garden.GET("", c.GardenInfo) garden.PUT("", c.GardenUpdate) keyInfo := garden.Group("/key_info") { keyInfo.PUT("", c.GardenKeyInfoChange) keyInfo.GET("", c.GardenKeyInfoChangeList) } } charge := apiv1.Group("/charge") { // 物业费套餐 propertyPackage := charge.Group("/property_package") { propertyPackage.POST("", c.PropertyPackageAdd) propertyPackage.PUT("", c.PropertyPackageUpdate) propertyPackage.DELETE("", c.PropertyPackageDel) propertyPackage.GET("", c.PropertyPackageList) } // 费项配置 conf := charge.Group("/conf") { conf.POST("", c.ChargeConfAdd) conf.PUT("", c.ChargeConfUpdate) conf.DELETE("", c.ChargeConfDel) conf.GET("", c.ChargeConfList) } // 抄表 power := charge.Group("/power") { power.POST("/batch", c.PowerRecordBatchAdd) power.POST("", c.PowerRecordAdd) power.DELETE("", c.PowerRecordDel) power.GET("", c.PowerRecordList) power.GET("/template", c.ChargePowerTemplate) } // 绑定费用 charge.PUT("/bind", c.ChargeBind) // 解绑费用 charge.PUT("/unbind", c.ChargeUnbind) // 获取催缴信息 charge.GET("/urge", c.ChargeUrgeInfo) charge.GET("/batch_urge", c.BatchUrge) // 催缴配置 charge.PUT("/urge", c.ChargeUrgeSet) house := charge.Group("/house") { // 已绑定某费项的房屋列表 house.GET("/binded_list", c.ChargeHouseBindedList) // 可以绑定某费项的房屋列表 house.GET("/can_bind_list", c.ChargeHouseNotBindList) } space := charge.Group("/space") { // 已绑定某费项的车位列表 space.GET("/binded_list", c.ChargeSpaceBindedList) // 可以绑定某费项的车位列表 space.GET("/can_bind_list", c.ChargeSpaceNotBindList) } vehicle := charge.Group("/vehicle") { // 已绑定某费项的车辆列表 vehicle.GET("/binded_list", c.ChargeVehicleBindedList) // 可以绑定某费项的车辆列表 vehicle.GET("/can_bind_list", c.ChargeVehicleNotBindList) } objCharge := charge.Group("/obj_charge") { // 房屋收费房屋列表 objCharge.GET("/house_list", c.ChargeHouseGroup) // 车位收费 车位列表 objCharge.GET("/space_list", c.ChargeSpaceGroup) // 车辆收费车辆列表 objCharge.GET("/vehicle_list", c.ChargeVehicleGroup) // 欠费缴费线下支付 objCharge.PUT("/pay", c.ChargeBillPay) // 欠费缴费欠费项目列表 objCharge.GET("/unpay_list", c.ChargeUnpayList) // 查看费用 费项列表 objCharge.GET("/charge_list", c.ChargeList) // 对象下的某费项下的账单列表 objCharge.GET("/bill_list", c.ChargeBillList) // 变更时间 objCharge.PUT("/time", c.ChargeTimeSet) // 手动生成账单 objCharge.PUT("/bill", c.ChargeGenerateBill) // 获取小票或收据信息 objCharge.GET("/ticket", c.ChargeOrderTicket) // 物业或车位费预支付前获取金额信息 objCharge.GET("/pre_pay_info", c.ChargePrePayInfo) // 物业或车位费预支付 objCharge.PUT("/pre_pay", c.ChargePrePay) } unpayBill := charge.Group("/unpay_bill") { // 应收账单对象列表 unpayBill.GET("/obj_list", c.ChargeBillObjList) // 对象下的账单列表 unpayBill.GET("/obj_bill_list", c.ChargeObjBillList) // 作废账单 unpayBill.PUT("/discard", c.ChargeDelBill) unpayBill.POST("/urge", c.ChargeUrge) } payedBill := charge.Group("/payed_bill") { // 已缴账单 payedBill.GET("/list", c.ChargePayedBillList) } discardBill := charge.Group("/discard_bill") { // 作废账单列表 discardBill.GET("/list", c.ChargeDelBillList) // 恢复账单 discardBill.PUT("/recover", c.ChargeRecoverBill) } order := charge.Group("/order") { // 订单列表 order.GET("/list", c.ChargeOrderList) // 订单详情 order.GET("/info", c.ChargeOrderInfo) // 确认订单已支付 order.PUT("/confirm", c.ChargeOrderPay) } } application := apiv1.Group("/application") { application.GET("", c.ApplicationList) } msgPackage := apiv1.Group("msg_package") { msgPackage.GET("", c.MsgPackageList) msgPackage.GET("/order", c.MsgPackageOrderList) msgPackage.POST("/order", c.MsgPackageOrderAdd) } order := apiv1.Group("/order") { order.POST("/application", c.ApplicationOrderAdd) order.GET("/application", c.GardenApplicationList) } systemUser := apiv1.Group("/system_user") { systemUser.POST("", c.UserAdd) systemUser.PUT("", c.UserUpdate) systemUser.DELETE("", c.UserDel) systemUser.GET("", c.UserList) } permission := apiv1.Group("/permission") { permission.GET("/all", c.AllPermission) permission.GET("/group_list", c.GroupList) permission.GET("/group_info", c.GroupInfo) permission.POST("/group", c.GroupAdd) permission.PUT("/group", c.GroupUpdate) permission.DELETE("/group", c.GroupDel) } household := apiv1.Group("/household") { household.GET("/list", c.HouseholdList) household.PUT("/approve", c.HouseholdApprove) household.GET("/user_list", c.HouseholdUserList) } park := apiv1.Group("/park") { park.POST("", c.ParkAdd) park.PUT("", c.ParkUpdate) park.DELETE("", c.ParkDel) park.GET("", c.ParkList) park.POST("/space", c.ParkSpaceAdd) park.PUT("/space", c.ParkSpaceUpdate) park.DELETE("/space", c.ParkSpaceDel) park.GET("/space", c.ParkSpaceList) } department := apiv1.Group("/department") { department.POST("", c.DepartmentAdd) department.PUT("", c.DepartmentUpdate) department.DELETE("", c.DepartmentDel) department.GET("", c.DepartmentList) } vehicle := apiv1.Group("/vehicle") { vehicle.POST("", c.VehicleAdd) vehicle.PUT("", c.VehicleUpdate) vehicle.DELETE("", c.VehicleDel) vehicle.GET("", c.VehicleList) vehicle.GET("/brand", c.VehicleBrandList) } buildings := apiv1.Group("/buildings") { manager := buildings.Group("/manager") { manager.GET("", c.BuildingManagerList) manager.POST("", c.BuildingAddManager) manager.DELETE("", c.BuildingDelManager) } buildings.POST("/building", c.BuildingAdd) buildings.PUT("/building", c.BuildingUpdate) buildings.GET("/building", c.BuildingList) buildings.DELETE("/building", c.BuildingDel) buildings.POST("/unit", c.UnitAdd) buildings.PUT("/unit", c.UnitUpdate) buildings.GET("/unit", c.UnitList) buildings.DELETE("/unit", c.UnitDel) buildings.POST("/house", c.HouseAdd) buildings.PUT("/house", c.HouseUpdate) buildings.GET("/house", c.HouseList) buildings.DELETE("/house", c.HouseDel) buildings.POST("/building/import", c.BuildingImport) buildings.POST("/unit/import", c.UnitImport) buildings.POST("/house/import", c.HouseImport) buildings.GET("/building/template", c.BuildingTemplate) buildings.GET("/unit/template", c.UnitTemplate) buildings.GET("/house/template", c.HouseTemplate) } systemMsg := apiv1.Group("/system_msg") { systemMsg.GET("/list", c.SystemMsgList) systemMsg.PUT("", c.SystemMsgReaded) } servicePhone := apiv1.Group("/service_phone") { class := servicePhone.Group("/class") { class.POST("", c.ServicePhoneClassAdd) class.PUT("", c.ServicePhoneClassUpdate) class.GET("", c.ServicePhoneClassList) class.DELETE("", c.ServicePhoneClassDel) } servicePhone.POST("", c.ServicePhoneAdd) servicePhone.PUT("", c.ServicePhoneUpdate) servicePhone.GET("", c.ServicePhoneList) servicePhone.DELETE("", c.ServicePhoneDel) } repair := apiv1.Group("/repair") { class := repair.Group("/class") { class.POST("", c.RepairClassAdd) class.PUT("", c.RepairClassUpdate) class.GET("", c.RepairClassList) class.DELETE("", c.RepairClassDel) } order := repair.Group("/order") { order.POST("", c.RepairOrderAdd) order.PUT("", c.RepairOrderUpdate) order.GET("", c.RepairOrderList) order.DELETE("", c.RepairOrderDel) order.GET("/info", c.RepairOrderInfo) order.PUT("/send", c.RepairOrderSend) order.PUT("/finish", c.RepairOrderFinish) order.PUT("/back", c.RepairOrderBack) order.PUT("/return_visit", c.RepairOrderReturnVisit) } } suggestion := apiv1.Group("/suggestion") { order := suggestion.Group("/order") { order.POST("", c.SuggestionOrderAdd) order.PUT("", c.SuggestionOrderUpdate) order.GET("", c.SuggestionOrderList) order.DELETE("", c.SuggestionOrderDel) order.GET("/info", c.SuggestionOrderInfo) order.PUT("/send", c.SuggestionOrderSend) order.PUT("/finish", c.SuggestionOrderFinish) order.PUT("/back", c.SuggestionOrderBack) order.PUT("/return_visit", c.SuggestionOrderReturnVisit) } } rent := apiv1.Group("/rent") { house := rent.Group("/house") { house.GET("", c.HouseRentList) house.POST("", c.HouseRentApply) house.PUT("", c.HouseRentUpdate) house.PUT("/approve", c.HouseRentApprove) house.PUT("/down", c.HouseRentDown) manager := house.Group("/manager") { manager.GET("", c.HouseRentManagerList) manager.POST("", c.HouseRentAddManager) manager.DELETE("", c.HouseRentDelManager) } appointment := house.Group("/appointment") { appointment.DELETE("", c.HouseRentAppointmentDel) appointment.GET("", c.HouseRentAppointmentList) appointment.PUT("", c.HouseRentAppointmentStatus) } } } } }