40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package routes
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/qit-team/snow-core/http/middleware"
|
|
"qteam/app/http/controllers"
|
|
"qteam/app/http/controllers/backend"
|
|
"qteam/app/http/middlewares"
|
|
"qteam/app/http/trace"
|
|
"qteam/app/utils"
|
|
"qteam/config"
|
|
)
|
|
|
|
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())
|
|
}
|
|
}
|
|
//api := router.Group("/api")
|
|
{
|
|
//api.GET("/banner_list", controllers.GetBannerList)
|
|
}
|
|
|
|
v1 := router.Group("/admin/api/v1")
|
|
{
|
|
products := v1.Group("/product")
|
|
products.POST("/create", middlewares.ValidateRequest(), backend.ProductCreateHandler)
|
|
products.GET("/query", backend.ProductQueryHandler)
|
|
products.PUT("/update", middlewares.ValidateRequest(), backend.ProductUpdateHandler)
|
|
products.DELETE("/delete", backend.ProductDeleteHandler)
|
|
}
|
|
|
|
}
|