代码拉取完成,页面将自动刷新
同步操作将从 pixel/gin-vue-admin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package initialize
import (
swaggerFiles "github.com/swaggo/files"
"net/http"
"gitee.com/g-qs/gin-vue-admin/server/docs"
"gitee.com/g-qs/gin-vue-admin/server/global"
"gitee.com/g-qs/gin-vue-admin/server/middleware"
"gitee.com/g-qs/gin-vue-admin/server/router"
"github.com/gin-gonic/gin"
ginSwagger "github.com/swaggo/gin-swagger"
"os"
)
type justFilesFilesystem struct {
fs http.FileSystem
}
func (fs justFilesFilesystem) Open(name string) (http.File, error) {
f, err := fs.fs.Open(name)
if err != nil {
return nil, err
}
stat, err := f.Stat()
if stat.IsDir() {
return nil, os.ErrPermission
}
return f, nil
}
// 初始化总路由
func Routers() *gin.Engine {
Router := gin.New()
Router.Use(gin.Recovery())
if gin.Mode() == gin.DebugMode {
Router.Use(gin.Logger())
}
InstallPlugin(Router) // 安装插件
systemRouter := router.RouterGroupApp.System
exampleRouter := router.RouterGroupApp.Example
// 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
// VUE_APP_BASE_API = /
// VUE_APP_BASE_PATH = http://localhost
// 然后执行打包命令 npm run build。在打开下面3行注释
// Router.Static("/favicon.ico", "./dist/favicon.ico")
// Router.Static("/assets", "./dist/assets") // dist里面的静态资源
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
userRouter := router.RouterGroupApp.User
indexRouter := router.RouterGroupApp.Index
HealthRouter := router.RouterGroupApp.Health
AssessRouter := router.RouterGroupApp.Assess
diseaseRouter := router.RouterGroupApp.Disease
bodyRouter := router.RouterGroupApp.Body
cancerRouter := router.RouterGroupApp.Cancer
dateRouter := router.RouterGroupApp.Catering
adminRouter := router.RouterGroupApp.Admin
Router.StaticFS(global.GVA_CONFIG.Local.StorePath, justFilesFilesystem{http.Dir(global.GVA_CONFIG.Local.StorePath)}) // Router.Use(middleware.LoadTls()) // 如果需要使用https 请打开此中间件 然后前往 core/server.go 将启动模式 更变为 Router.RunTLS("端口","你的cre/pem文件","你的key文件")
// 跨域,如需跨域可以打开下面的注释
// Router.Use(middleware.Cors()) // 直接放行全部跨域请求
// Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
//global.GVA_LOG.Info("use middleware cors")
docs.SwaggerInfo.BasePath = global.GVA_CONFIG.System.RouterPrefix
Router.GET(global.GVA_CONFIG.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
global.GVA_LOG.Info("register swagger handler")
// 方便统一添加路由组前缀 多服务器上线使用
PublicGroup := Router.Group(global.GVA_CONFIG.System.RouterPrefix)
{
// 健康监测
PublicGroup.GET("/health", func(c *gin.Context) {
c.JSON(http.StatusOK, "ok")
})
}
{
systemRouter.InitBaseRouter(PublicGroup)
systemRouter.InitInitRouter(PublicGroup)
}
{
userRouter.InitBaseRouter(PublicGroup)
}
PrivateGroup := Router.Group(global.GVA_CONFIG.System.RouterPrefix)
PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
{
systemRouter.InitApiRouter(PrivateGroup, PublicGroup)
systemRouter.InitJwtRouter(PrivateGroup)
systemRouter.InitUserRouter(PrivateGroup)
systemRouter.InitMenuRouter(PrivateGroup)
systemRouter.InitSystemRouter(PrivateGroup)
systemRouter.InitCasbinRouter(PrivateGroup)
systemRouter.InitAutoCodeRouter(PrivateGroup)
systemRouter.InitAuthorityRouter(PrivateGroup)
systemRouter.InitSysDictionaryRouter(PrivateGroup)
systemRouter.InitAutoCodeHistoryRouter(PrivateGroup)
systemRouter.InitSysOperationRecordRouter(PrivateGroup)
systemRouter.InitSysDictionaryDetailRouter(PrivateGroup)
systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup)
systemRouter.InitSysExportTemplateRouter(PrivateGroup) // 导出模板
exampleRouter.InitCustomerRouter(PrivateGroup)
exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup)
}
{
userRouter.InitUserRouter(PrivateGroup, PublicGroup)
userRouter.InitUserBindManageRouter(PrivateGroup)
indexRouter.InitIndexRouter(PrivateGroup)
HealthRouter.InitCircleRouter(PrivateGroup)
AssessRouter.InitAssessRouter(PrivateGroup)
diseaseRouter.InitDiseaseRouter(PrivateGroup)
bodyRouter.InitBodyRouter(PrivateGroup)
cancerRouter.InitCancerRouter(PrivateGroup)
}
{
structureRouter := router.RouterGroupApp.Structure
structureRouter.InitServiceStationArticleRouter(PrivateGroup, PublicGroup)
}
{
configRouter := router.RouterGroupApp.Config
configRouter.InitConfigRouter(PrivateGroup)
}
{
topicRouter := router.RouterGroupApp.Topic
topicRouter.InitTopicRouter(PrivateGroup)
}
{
hierarchyRouter := router.RouterGroupApp.Hierarchy
hierarchyRouter.InitLevelOneRouter(PrivateGroup)
hierarchyRouter.InitLevelTwoRouter(PrivateGroup, PublicGroup)
hierarchyRouter.InitLevelThreeRouter(PrivateGroup)
hierarchyRouter.InitFdArticleGraphicRouter(PrivateGroup, PublicGroup)
hierarchyRouter.InitFdArticleAudioRouter(PrivateGroup, PublicGroup)
hierarchyRouter.InitFdArticleVideoRouter(PrivateGroup, PublicGroup)
hierarchyRouter.InitFdArticleLearnRouter(PrivateGroup, PublicGroup)
hierarchyRouter.InitFdArticleRouter(PrivateGroup, PublicGroup)
hierarchyRouter.InitCommentRouter(PrivateGroup, PublicGroup)
}
{
feedbackRouter := router.RouterGroupApp.Feedback
feedbackRouter.InitFeedbackRouter(PrivateGroup, PublicGroup)
}
{
healthRouter := router.RouterGroupApp.Health
healthRouter.InitPhysiqueRouter(PrivateGroup, PublicGroup)
healthRouter.InitDiseaseRouter(PrivateGroup, PublicGroup)
healthRouter.InitShipuRouter(PrivateGroup, PublicGroup)
healthRouter.InitFdEfficacyRouter(PrivateGroup)
healthRouter.InitFdJqRouter(PrivateGroup)
healthRouter.InitHealthQAndARouter(PrivateGroup)
healthRouter.InitHealthQuestionRouter(PrivateGroup)
}
{
dateRouter.InitDateRouter(PrivateGroup, PublicGroup)
}
{
cateringRouter := router.RouterGroupApp.Catering
cateringRouter.InitFoodRouter(PrivateGroup)
}
{
publicRouter := router.RouterGroupApp.Public
publicRouter.InitOnlineServiceRouter(PrivateGroup)
publicRouter.InitMessageRouter(PrivateGroup, PublicGroup)
}
{
adminRouter.InitAdminUserRouter(PrivateGroup)
adminRouter.InitDataAnalysisRouter(PrivateGroup)
}
{
managerRouter := router.RouterGroupApp.Manager
managerRouter.InitFdHealthManagerRouter(PrivateGroup, PublicGroup)
managerRouter.InitFdHealthManagerRegisterRouter(PrivateGroup)
managerRouter.InitFdHealthManagerAuditRouter(PrivateGroup)
managerRouter.InitMessageRemindRouter(PrivateGroup)
managerRouter.InitTargetPlanRouter(PrivateGroup)
}
{
dashboardRouter := router.RouterGroupApp.Dashboard
dashboardRouter.InitBordRouter(PrivateGroup)
}
global.GVA_LOG.Info("router register success")
return Router
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。