12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package init_serve
- import (
- "github.com/gin-gonic/gin"
- "github.com/swaggo/gin-swagger"
- "github.com/swaggo/gin-swagger/swaggerFiles"
- _ "hongze/fms_api/docs"
- "hongze/fms_api/global"
- "hongze/fms_api/middleware"
- "hongze/fms_api/routers"
- )
- // InitRouter 初始化路由
- func InitRouter() (r *gin.Engine) {
- //设置
- gin.SetMode(global.CONFIG.Serve.RunMode)
- // 1.创建路由
- r = gin.Default()
- r.Use(middleware.Cors())
- //r.Use(gin.Recovery())
- r.Use(middleware.Recover())
- // 公共的中间件
- r.Use(middleware.Common())
- //swagger界面访问地址 http://localhost:8390/swagger/index.html
- r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
- rBase := r.Group("api/")
- //系统相关路由
- systemGroup := rBase.Group("system/")
- resourceGroup := rBase.Group("resource/")
- routers.InitSystem(systemGroup)
- routers.InitAuth(rBase)
- routers.InitResource(resourceGroup)
- // CRM系统相关路由
- crmGroup := rBase.Group("crm/")
- routers.InitCrm(crmGroup)
- // 合同相关路由
- contractGroup := rBase.Group("contract/")
- routers.InitContract(contractGroup)
- // 统计相关路由
- censusGroup := rBase.Group("census/")
- routers.InitCensus(censusGroup)
- // 统计报告
- routers.InitStatistic(rBase)
- return
- }
|