// 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-management-gateway/controller/v1" _ "property-management-gateway/docs" "property-management-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) apiv1.Use(middleware.Jwt()) apiv1.POST("/upload", c.Upload) apiv1.PUT("/token_refresh", c.TokenRefresh) user := apiv1.Group("/user") { user.PUT("/password", nil) } gate := apiv1.Group("/gate") { gate.GET("", c.GateList) gate.GET("/protocols", c.GateProtocols) gate.POST("/in", c.GateIn) gate.PUT("/out", c.GateOut) gate.PUT("/recovery", c.GateRecovery) gate.DELETE("", c.GateDel) gate.GET("/template", c.GateTemplate) gate.POST("/import", c.GateImport) } company := apiv1.Group("/company") { company.POST("/register", c.CompanyRegister) company.PUT("/approve", c.CompanyApprove) company.GET("/list", c.CompanyList) company.PUT("/free_garden", c.CompanyChangeFreeGarden) company.GET("/wx_account", c.CompanyWxAccountList) company.GET("/wx_account_info", c.CompanyWxAccountApplyInfo) company.GET("/package", c.CompanyPackage) } systemPermission := apiv1.Group("/system_permission") { systemPermission.POST("", c.SystemPermissionAdd) systemPermission.PUT("", c.SystemPermissionUpdate) systemPermission.DELETE("", c.SystemPermissionDel) systemPermission.GET("", c.SystemPermissionList) systemPermission.PUT("/enable", c.SystemPermissionEnable) } material := apiv1.Group("/material") { material.POST("", c.MaterialAdd) material.PUT("", c.MaterialUpdate) material.DELETE("", c.MaterialDel) material.GET("", c.MaterialList) material.PUT("/enable", c.MaterialEnable) } application := apiv1.Group("/application") { application.POST("", c.ApplicationAdd) application.PUT("", c.ApplicationUpdate) application.DELETE("", c.ApplicationDel) application.GET("", c.ApplicationList) application.PUT("/enable", c.ApplicationEnableSet) application.PUT("/permissions", c.ApplicationPermissionsSet) application.GET("/permissions", c.ApplicationPermissions) } cpackage := apiv1.Group("/package") { cpackage.POST("", c.PackageAdd) cpackage.PUT("", c.PackageUpdate) cpackage.DELETE("", c.PackageDel) cpackage.GET("", c.PackageList) cpackage.PUT("/enable", c.PackageEnableSet) cpackage.PUT("/application", c.PackageApplicationSet) cpackage.GET("/application", c.PackageApplicationList) cpackage.GET("/application_can_add", c.PackageApplicationCanAddList) } msgPackage := apiv1.Group("/msg_package") { msgPackage.POST("", c.MsgPackageAdd) msgPackage.PUT("", c.MsgPackageUpdate) msgPackage.DELETE("", c.MsgPackageDel) msgPackage.GET("", c.MsgPackageList) } order := apiv1.Group("/order") { order.PUT("/application", c.ApplicationOrderApprove) order.GET("/application", c.GardenApplicationList) order.PUT("/package", c.PackageOrderApprove) order.GET("/package", c.CompanyPackageList) order.POST("/package", c.PackageOrderAdd) order.POST("/renew", c.PackageOrderAddRenew) order.PUT("/application/amount", c.ApplicationOrderAmount) order.PUT("/package/amount", c.PackageOrderAmount) order.PUT("/msg_package", c.MsgPackageOrderApprove) order.GET("/msg_package", c.MsgPackageOrderList) } area := apiv1.Group("/area") { area.GET("/province_city_area", c.ProvinceCityArea) area.GET("/street_committee", c.StreetCommittee) } garden := apiv1.Group("/garden") { garden.GET("", c.GardenList) garden.PUT("/company", c.GardenChangeCompany) garden.PUT("", c.GardenApprove) keyInfo := garden.Group("/key_info") keyInfo.GET("", c.GardenKeyInfoChangeList) keyInfo.PUT("", c.GardenKeyInfoApprove) garden.PUT("/enable", c.GardenEnableSet) } wx := apiv1.Group("/wx") { wx.POST("/public/mini", c.WxPublicAddMini) } } }