// 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-company-gateway/controller/v1" _ "property-company-gateway/docs" "property-company-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/company", c.CompanyRegister) engine.POST("/api/v1/upload", c.Upload) engine.POST("/api/v1/upload_wx", c.UploadWx) 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.CompanyStatistic) } user := apiv1.Group("/user") { user.PUT("/change_password", c.ChangePassword) } company := apiv1.Group("/company") { company.PUT("", c.CompanyUpdate) company.GET("", c.CompanyInfo) company.GET("/wx_account", c.CompanyWxAccountList) company.POST("/wx_account", c.CompanyWxAccountApply) company.GET("/wx_account_info", c.CompanyWxAccountApplyInfo) company.PUT("/garden_mch", c.GardenSetMch) company.PUT("/garden_paymode", c.GardenSetMchPayMode) company.GET("/garden_mch", c.CompanyMchGardenList) company.GET("/template", c.CompanyTemplate) } garden := apiv1.Group("/garden") { garden.POST("", c.CompanyAddGarden) garden.GET("", c.CompanyGardenList) garden.PUT("", c.CompanyGardenUpdate) garden.DELETE("", c.CompanyGardenDel) garden.GET("/entry", c.CompanyEnterGarden) garden.GET("/check", c.CompanyCanAddGarden) keyInfo := garden.Group("/key_info") { keyInfo.PUT("", c.GardenKeyInfoChange) keyInfo.GET("", c.GardenKeyInfoChangeList) } } companyUser := apiv1.Group("/company_user") { companyUser.POST("", c.CompanyUserAdd) companyUser.PUT("", c.CompanyUserUpdate) companyUser.DELETE("", c.CompanyUserDel) companyUser.GET("", c.CompanyUserList) } area := apiv1.Group("/area") { area.GET("/province_city_area", c.ProvinceCityArea) area.GET("/street_committee", c.StreetCommittee) } application := apiv1.Group("/application") { application.GET("", c.ApplicationList) } cpackage := apiv1.Group("/package") { cpackage.GET("", c.PackageList) } order := apiv1.Group("/order") { order.GET("/package", c.CompanyPackageList) order.POST("/package", c.PackageOrderAdd) order.POST("/renew", c.PackageOrderAddRenew) order.GET("/package_for_garden", c.CompanyPackageListForGarden) } } }