package route import ( "key_performance_indicators/apirouter" "key_performance_indicators/identification/interceptor" "github.com/gin-gonic/gin" ) // 初始化主路由 func InitialRouter() *gin.Engine { var router = gin.Default() //app默认相应 appLoadRouterGroup := router.Group("") { // 跨域设置 // router.Use(middleware.CrossDomainRequest()) // 如需跨域可以打开 //app默认相应 appLoadRouterGroup.GET("/", func(c *gin.Context) { c.JSON(0, "通讯成功!") }) appLoadRouterGroup.POST("/", func(c *gin.Context) { c.JSON(0, "通讯成功!") }) //实验路由 shiyanApi := apirouter.RouterGroupEntry.ShiyanApi { shiyanApi.RouterGroup(appLoadRouterGroup) } //OAuth 2.0 授权 oAuthEmpowerApi := apirouter.RouterGroupEntry.EmpowerRouter { oAuthEmpowerApi.RouterGroup(appLoadRouterGroup) } //登录验证 loginVerifyApi := apirouter.RouterGroupEntry.VerifyLogin { loginVerifyApi.RouterGroup(appLoadRouterGroup) } // 自定义测试 // mytestapi := apirouter.RouterGroupEntry.MyTest // { // mytestapi.RouterGroup(appLoadRouterGroup) // } //企业微信回调 wechaturlApi := apirouter.RouterGroupEntry.WechatRouter { wechaturlApi.RouterGroup(appLoadRouterGroup) } } //验证身份接口 鉴权Url(主要应用端使用) VerifyIdentity := router.Group("") VerifyIdentity.Use(interceptor.AuthenticateUser()).Use(interceptor.VerifyUrl()) { //v1版本接口 //荣誉墙 version1HonorsApi := apirouter.RouterGroupEntry.HonorsSouteRouter version1HonorsApi.RouterGroup(VerifyIdentity) //岗位考核 postRouterApi := apirouter.RouterGroupEntry.PostRouter postRouterApi.RouterGroupPc(VerifyIdentity) //pc端 // postRouterApi.RouterGroupWeb(VerifyIdentity) //web端 //部门考核 departmentRouterApi := apirouter.RouterGroupEntry.DepartmentRouter departmentRouterApi.RouterGroupPc(VerifyIdentity) //pc端 // departmentRouterApi.RouterGroupWeb(VerifyIdentity) //web端 // 图文信息 bookimgRouterApi := apirouter.RouterGroupEntry.BookImg bookimgRouterApi.RouterGroup(VerifyIdentity) } //验证身份接口 无需鉴权Url(主要web端使用) VerifyIdentityWeb := router.Group("") VerifyIdentityWeb.Use(interceptor.AuthenticateUser()) { //岗位考核 postRouterApiWeb := apirouter.RouterGroupEntry.PostRouter postRouterApiWeb.RouterGroupWeb(VerifyIdentityWeb) //web端 //部门考核 departmentRouterApiWeb := apirouter.RouterGroupEntry.DepartmentRouter departmentRouterApiWeb.RouterGroupWeb(VerifyIdentityWeb) //web端 //系统权限设置 systemPowerPcApi := apirouter.RouterGroupEntry.SystemPowerRouter systemPowerPcApi.RouterGroupPc(VerifyIdentityWeb) //web端 //系统授权 systemAuthorizingApi := apirouter.RouterGroupEntry.Empowerouter systemAuthorizingApi.RouterGroup(VerifyIdentityWeb) //系统授权 //工作流 workFlowApiRouter := apirouter.RouterGroupEntry.WorkFlowRouter workFlowApiRouter.RouterGroup(VerifyIdentityWeb) //工作流 systemApproval := apirouter.RouterGroupEntry.ExamineSystemApp systemApproval.RouterGroup(VerifyIdentityWeb) //系统内审批 } //Token身份验证 VerifyIdentityToken := router.Group("") VerifyIdentityToken.Use(interceptor.IdentificationToken()) { } return router }