package routes import ( "cron_admin/app/http/controllers" "cron_admin/app/http/controllers/backend" "cron_admin/app/http/middlewares" "cron_admin/app/http/trace" "cron_admin/app/utils" "cron_admin/config" "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/http/middleware" ) func RegisterAdminRoute(router *gin.Engine) { router.Use(middlewares.ServerRecovery(), middleware.GenRequestId, middleware.GenContextKit, middleware.AccessLog()) router.NoRoute(controllers.Error404) if len(config.GetConf().SkyWalkingOapServer) > 0 && config.IsEnvEqual(config.ProdEnv) { err := trace.InitTracer(config.GetConf().ServiceName, config.GetConf().SkyWalkingOapServer) if err != nil { utils.Log(nil, "InitTracer", err.Error()) } else { router.Use(middlewares.Trace()) } } adminApi := router.Group("/admin/api", middlewares.ValidateRequest()) { oauth := adminApi.Group("/oauth") { v1 := oauth.Group("/v1") { //用户管理 user := v1.Group("/user") { user.POST("/list", backend.UserList) user.POST("/add", backend.UserAdd) user.POST("/edit", backend.UserEdit) user.POST("/del", backend.UserDel) } //数据库管理 sql := v1.Group("/sql") { sql.POST("/list", backend.DbList) sql.POST("/add", backend.DbAdd) sql.POST("/edit", backend.DbEdit) sql.DELETE("/del", backend.DbDel) } //任务 cmd := v1.Group("/cmd") { cmd.GET("/query", backend.Empty) cmd.GET("/info", backend.Empty) cmd.PUT("/update", backend.Empty) cmd.DELETE("/delete", backend.Empty) } //消息管理 mes := v1.Group("/channel") { mes.POST("/list", backend.ReportChannelList) mes.POST("/create", backend.ReportChannelCreate) mes.DELETE("/delete", backend.ReportChannelDelete) mes.PUT("/update", backend.ReportChannelUpdate) } //日志 log := v1.Group("/log") { //任务日志 cmdLog := log.Group("/cmd") { cmdLog.POST("/list", backend.CronFuncLogsList) } //消息日志 mesLog := log.Group("/mes") { mesLog.GET("/list", backend.Empty) } } } } } }