// 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-household-gateway/controller/v1" _ "property-household-gateway/docs" "property-household-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.GET("/warning", func(c *gin.Context) { // c.String(http.StatusOK, "微信版本过低,无法打开小程序,请下载新版微信") }) //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.GET("/api/v1/gate/visitor/share", c.GateVisitorPage) apiv1.PUT("/token_refresh", c.TokenRefresh) apiv1.Use(middleware.Jwt()) user := apiv1.Group("/user") { user.PUT("/real_name_auth", c.RealNameAuth) user.PUT("/nick_name", c.UserUpdateNickName) user.GET("/info", c.UserInfo) user.GET("/house", c.HouseholdHouses) user.GET("/space", c.HouseholdSpace) user.GET("/vehicle", c.HouseholdVehicle) user.GET("/openim_token", c.OpenImToken) user.GET("/openim_users_info", c.OpenImUsersInfo) } material := apiv1.Group("/material") { material.GET("/info", c.MaterialInfo) material.GET("/list", c.MaterialList) } service := apiv1.Group("/service") { vote := service.Group("/vote") { vote.GET("", c.VoteListForHousehold) vote.POST("/answer", c.VoteAddAnswer) vote.GET("/result/statistic", c.VoteResultStatistic) } event := service.Group("/event") { event.GET("", c.EventList) sign := event.Group("/sign") { sign.POST("", c.EventSignAdd) } } announcement := service.Group("/announcement") { announcement.GET("", c.AnnouncementList) announcement.PUT("/read_count", c.AnnouncementReadAdd) } neighbor := service.Group("/neighbor") { neighbor.GET("/class", c.NeighborClassList) neighbor.POST("/article", c.NeighborArticleAdd) neighbor.PUT("/article", c.NeighborArticleUpdate) neighbor.DELETE("/article", c.NeighborArticleDel) neighbor.GET("/article", c.NeighborArticleList) neighbor.POST("/comment", c.NeighborCommentAdd) neighbor.PUT("/comment", c.NeighborCommentUpdate) neighbor.DELETE("/comment", c.NeighborCommentDel) neighbor.GET("/comment", c.NeighborCommentList) neighbor.PUT("/like", c.NeighborLike) } } gate := apiv1.Group("/gate") { gate.GET("", c.GateList) gate.GET("/qcode", c.GateQcode) gate.GET("/qcode_visitor", c.GateQcodeVisitor) gate.GET("/visitor", c.GateVisitorList) gate.DELETE("/visitor", c.GateVisitorDel) gate.GET("/face", c.GateUserPicInfo) gate.POST("/face", c.GateUserPicAdd) gate.GET("/has_face_device", c.GateHasFace) } charge := apiv1.Group("/charge") { charge.PUT("/pay_test", c.ChargeWxPayTest) charge.PUT("/pay", c.ChargeBillPayByHousehold) charge.PUT("/pre_pay", c.ChargePrePayByHousehold) charge.GET("/months/property", c.ChargePropertyMonthInfo) charge.GET("/months/space", c.ChargeSpaceMonthInfo) charge.GET("/months/vehicle", c.ChargeVehicleMonthInfo) charge.GET("/bill_list", c.ChargeBillList) charge.GET("/charge_list", c.ChargeList) charge.GET("/unpay_list", c.ChargeUnpayList) charge.GET("/pre_pay_info", c.ChargePrePayInfo) charge.GET("/payed_bill_list", c.ChargePayedBillList) order := charge.Group("/order") { // 订单列表 order.GET("/list", c.ChargeOrderList) // 订单详情 order.GET("/info", c.ChargeOrderInfo) order.PUT("/cancel", c.ChargeOrderCancel) } } area := apiv1.Group("/area") { area.GET("/province_city_area", c.ProvinceCityArea) area.GET("/street_committee", c.StreetCommittee) area.GET("/city", c.City) } garden := apiv1.Group("/garden") { garden.GET("/info", c.GardenInfo) garden.GET("/list", c.GardenList) garden.GET("/building", c.BuildingList) garden.GET("/unit", c.UnitList) garden.GET("/house", c.HouseList) garden.GET("/buildings/manager", c.BuildingManagerList) } household := apiv1.Group("/household") { household.POST("/apply", c.HouseholdApply) household.GET("/house", c.HouseholdList) household.DELETE("/house", c.HouseholdDelHouse) } rent := apiv1.Group("/rent") { rent.GET("/garden_info", c.GardenHouseRentInfo) house := rent.Group("/house") { house.GET("", c.HouseRentList) house.POST("", c.HouseRentApply) house.PUT("", c.HouseRentUpdate) house.PUT("/down", c.HouseRentDown) manager := house.Group("/manager") { manager.GET("", c.HouseRentManagerList) } appointment := house.Group("/appointment") { appointment.POST("", c.HouseRentAppointmentAdd) appointment.GET("", c.HouseRentAppointmentList) appointment.DELETE("", c.HouseRentAppointmentDel) } } } servicePhone := apiv1.Group("/service_phone") { class := servicePhone.Group("/class") { class.GET("", c.ServicePhoneClassList) } servicePhone.GET("", c.ServicePhoneList) } repair := apiv1.Group("/repair") { class := repair.Group("/class") { class.GET("", c.RepairClassList) } order := repair.Group("/order") { order.POST("", c.RepairOrderAdd) order.PUT("", c.RepairOrderUpdate) order.GET("", c.RepairOrderList) order.GET("/info", c.RepairOrderInfo) 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.GET("/info", c.SuggestionOrderInfo) order.PUT("/return_visit", c.SuggestionOrderReturnVisit) } } } }