zhangqian
2023-10-13 5f815df137f6edaaaddf869097b7e2718324acc6
router/index.go
@@ -3,6 +3,8 @@
import (
   "aps_crm/conf"
   _ "aps_crm/docs"
   "aps_crm/middleware"
   "fmt"
   "github.com/gin-contrib/cors"
   "github.com/gin-gonic/gin"
   swaggerFiles "github.com/swaggo/files"
@@ -25,8 +27,8 @@
   IsVisitRouter
   SolveRateRouter
   TimelyRateRouter
   BaseRouter
   UserRouter
   //BaseRouter
   //UserRouter
   JwtRouter
   CountryRouter
   ProvinceRouter
@@ -70,6 +72,8 @@
   DepartmentRouter
   SatisfactionRouter
   AssignRouter
   CollectionProjectionRouter
   ContactInformationRouter
}
func InitRouter() *gin.Engine {
@@ -83,26 +87,35 @@
   Router.Use(cors.Default())
   Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
   //获取所有路由 //todo
   Router.GET("getRouters", func(c *gin.Context) {
      routers := Router.Routes()
      for _, v := range routers {
         fmt.Printf("\"%v\" : 1,\n", v.Path)
      }
   })
   routerGroup := new(Group)
   PublicGroup := Router.Group("api")
   {
      // 健康监测
      PublicGroup.GET("/health", func(c *gin.Context) {
         c.JSON(http.StatusOK, "ok")
      })
   }
   {
      routerGroup.InitBaseRouter(PublicGroup)  // 注册基础功能路由 不做鉴权
      routerGroup.InitImageRouter(PublicGroup) // 图像功能路由
   }
   //{
   //   routerGroup.InitBaseRouter(PublicGroup)  // 注册基础功能路由 不做鉴权
   //   routerGroup.InitImageRouter(PublicGroup) // 图像功能路由
   //}
   PrivateGroup := Router.Group("api")
   //PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
   //PrivateGroup.Use(middleware.JWTAuth())
   PrivateGroup.Use(middleware.JWTAuth2())
   //PrivateGroup.Use(middleware.CasbinHandler())
   {
      routerGroup.InitJwtRouter(PrivateGroup)                  // jwt相关路由
      routerGroup.InitUserRouter(PrivateGroup)                 // 注册用户路由
      routerGroup.InitJwtRouter(PrivateGroup) // jwt相关路由
      //routerGroup.InitUserRouter(PrivateGroup)                 // 注册用户路由
      routerGroup.InitCountryRouter(PrivateGroup)              // 注册country路由
      routerGroup.InitProvinceRouter(PrivateGroup)             // 注册province路由
      routerGroup.InitCityRouter(PrivateGroup)                 // 注册city路由
@@ -169,6 +182,15 @@
      InitServiceCollectionPlanRouter(PrivateGroup)
      InitReceiptRouter(PrivateGroup)
      InitBankAccountRouter(PrivateGroup)
      InitPaymentTypeRouter(PrivateGroup)
      InitFileRouter(PrivateGroup)
      InitInvoiceRouter(PrivateGroup)
      InitInvoiceStatusRouter(PrivateGroup)
      InitInvoiceTypeRouter(PrivateGroup)
      InitCourierCompanyRouter(PrivateGroup)
      InitProductRouter(PrivateGroup)
      routerGroup.InitCollectionProjectionRouter(PrivateGroup)
      routerGroup.InitContactInformationRouter(PrivateGroup)
   }
   return Router
}