2024-07-12 18:11:21 +08:00
|
|
|
package routes
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 配置路由
|
|
|
|
*/
|
|
|
|
import (
|
|
|
|
"com.snow.auto_monitor/app/http/controllers"
|
|
|
|
"com.snow.auto_monitor/app/http/middlewares"
|
|
|
|
"com.snow.auto_monitor/app/http/trace"
|
|
|
|
"com.snow.auto_monitor/app/utils/metric"
|
|
|
|
"com.snow.auto_monitor/config"
|
|
|
|
|
2024-08-07 13:46:10 +08:00
|
|
|
devCon "com.snow.auto_monitor/app/http/controllers/device"
|
2024-08-21 10:18:34 +08:00
|
|
|
dingCon "com.snow.auto_monitor/app/http/controllers/dingding"
|
2024-07-12 18:11:21 +08:00
|
|
|
merCon "com.snow.auto_monitor/app/http/controllers/merchant"
|
|
|
|
ordersCon "com.snow.auto_monitor/app/http/controllers/orders"
|
|
|
|
proCon "com.snow.auto_monitor/app/http/controllers/product"
|
|
|
|
transCon "com.snow.auto_monitor/app/http/controllers/transfersys"
|
|
|
|
wlCon "com.snow.auto_monitor/app/http/controllers/whitelist"
|
|
|
|
zlCon "com.snow.auto_monitor/app/http/controllers/zhiliansys"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/qit-team/snow-core/http/middleware"
|
|
|
|
"github.com/qit-team/snow-core/log/logger"
|
|
|
|
ginSwagger "github.com/swaggo/gin-swagger"
|
|
|
|
"github.com/swaggo/gin-swagger/swaggerFiles"
|
|
|
|
)
|
|
|
|
|
|
|
|
// api路由配置
|
|
|
|
func RegisterRoute(router *gin.Engine) {
|
|
|
|
//middleware: 服务错误处理 => 生成请求id => access log
|
2024-07-18 16:37:12 +08:00
|
|
|
router.Use(middlewares.ServerRecovery(), middleware.GenRequestId,
|
2024-08-21 10:18:34 +08:00
|
|
|
middleware.GenContextKit, middleware.AccessLog(), //middlewares.VerifyIp(),
|
2024-07-18 16:37:12 +08:00
|
|
|
middlewares.Cors())
|
2024-07-12 18:11:21 +08:00
|
|
|
|
|
|
|
if config.GetConf().PrometheusCollectEnable && config.IsEnvEqual(config.ProdEnv) {
|
|
|
|
router.Use(middlewares.CollectMetric())
|
|
|
|
metric.Init(metric.EnableRuntime(), metric.EnableProcess())
|
|
|
|
metricHandler := metric.Handler()
|
|
|
|
router.GET("/metrics", func(ctx *gin.Context) {
|
|
|
|
metricHandler.ServeHTTP(ctx.Writer, ctx.Request)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(config.GetConf().SkyWalkingOapServer) > 0 && config.IsEnvEqual(config.ProdEnv) {
|
|
|
|
err := trace.InitTracer(config.GetConf().ServiceName, config.GetConf().SkyWalkingOapServer)
|
|
|
|
if err != nil {
|
|
|
|
logger.Error(nil, "InitTracer", err.Error())
|
|
|
|
} else {
|
|
|
|
router.Use(middlewares.Trace())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
router.NoRoute(controllers.Error404)
|
|
|
|
router.GET("/hello", controllers.HandleHello)
|
|
|
|
router.POST("/test", controllers.HandleTest)
|
|
|
|
router.POST("/test_validator", controllers.HandleTestValidator)
|
|
|
|
|
|
|
|
//api版本
|
|
|
|
v1 := router.Group("/v1")
|
|
|
|
{
|
|
|
|
v1.GET("/banner_list", controllers.GetBannerList)
|
|
|
|
}
|
|
|
|
|
|
|
|
merchant := router.Group("/merchant")
|
|
|
|
{
|
|
|
|
merchant.POST("/get_by_id", merCon.GetById)
|
|
|
|
merchant.POST("/search", merCon.Search)
|
|
|
|
merchant.POST("/create", merCon.Create)
|
|
|
|
// merchant.POST("/update", merCon.Update)
|
|
|
|
// merchant.POST("/delete", merCon.Delete)
|
|
|
|
}
|
|
|
|
|
|
|
|
orders := router.Group("/orders")
|
2024-07-18 17:43:46 +08:00
|
|
|
// orders.Use(middlewares.VerifyHtmlIp())
|
2024-07-12 18:11:21 +08:00
|
|
|
{
|
|
|
|
orders.POST("/get_by_id", ordersCon.GetById)
|
|
|
|
orders.POST("/search", ordersCon.Search)
|
2024-07-26 15:09:57 +08:00
|
|
|
orders.POST("/cancel", ordersCon.Cancel)
|
2024-07-12 18:11:21 +08:00
|
|
|
// orders.POST("/create", ordersCon.Create)
|
|
|
|
// orders.POST("/update", ordersCon.Update)
|
|
|
|
// orders.POST("/delete", ordersCon.Delete)
|
|
|
|
}
|
|
|
|
|
|
|
|
product := router.Group("/product")
|
2024-07-18 17:43:46 +08:00
|
|
|
// product.Use(middlewares.VerifyHtmlIp())
|
2024-07-12 18:11:21 +08:00
|
|
|
{
|
|
|
|
product.POST("/get_by_id", proCon.GetById)
|
|
|
|
product.POST("/search", proCon.Search)
|
|
|
|
product.POST("/create", proCon.Create)
|
2024-07-18 15:05:52 +08:00
|
|
|
product.POST("/update", proCon.Update)
|
|
|
|
product.POST("/delete", proCon.Delete)
|
2024-07-12 18:11:21 +08:00
|
|
|
}
|
|
|
|
|
2024-08-07 13:46:10 +08:00
|
|
|
device := router.Group("/device")
|
|
|
|
// product.Use(middlewares.VerifyHtmlIp())
|
|
|
|
{
|
|
|
|
device.POST("/get_by_id", devCon.GetById)
|
2024-08-07 15:31:24 +08:00
|
|
|
device.POST("/search", devCon.Search)
|
2024-08-07 13:46:10 +08:00
|
|
|
device.POST("/create", devCon.Create)
|
|
|
|
device.POST("/update", devCon.Update)
|
|
|
|
device.POST("/delete", devCon.Delete)
|
|
|
|
}
|
|
|
|
|
2024-07-12 18:11:21 +08:00
|
|
|
whitelist := router.Group("/whitelist")
|
2024-07-18 18:22:22 +08:00
|
|
|
whitelist.Use(middlewares.VerifyHtmlIp())
|
2024-07-12 18:11:21 +08:00
|
|
|
{
|
|
|
|
whitelist.POST("/get_by_id", wlCon.GetById)
|
|
|
|
whitelist.POST("/search", wlCon.Search)
|
|
|
|
whitelist.POST("/create", wlCon.Create)
|
2024-07-18 15:05:52 +08:00
|
|
|
whitelist.POST("/update", wlCon.Update)
|
|
|
|
whitelist.POST("/delete", wlCon.Delete)
|
2024-07-12 18:11:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
zhilian := router.Group("/zhilian")
|
2024-07-29 16:36:41 +08:00
|
|
|
// zhilian.Use(middlewares.VerifySign())
|
2024-07-12 18:11:21 +08:00
|
|
|
zhilian.Use(middlewares.RequestLog())
|
|
|
|
{
|
|
|
|
zhilian.POST("/recharge/order", zlCon.CreateOrder)
|
|
|
|
zhilian.POST("/recharge/query", zlCon.GetByOutTradeNo)
|
|
|
|
}
|
|
|
|
|
|
|
|
transfersys := router.Group("/transfersys")
|
|
|
|
transfersys.Use(middlewares.RequestLog())
|
|
|
|
{
|
|
|
|
transfersys.GET("/recharge/get_order", transCon.GetOrder)
|
|
|
|
transfersys.POST("/recharge/finish", transCon.FinishOrder)
|
2024-08-15 09:13:51 +08:00
|
|
|
transfersys.POST("/recharge/set_order_mobile", transCon.SetOrderMobile)
|
2024-07-12 18:11:21 +08:00
|
|
|
}
|
|
|
|
|
2024-07-18 17:05:46 +08:00
|
|
|
temp := router.Group("temp")
|
2024-07-18 17:43:46 +08:00
|
|
|
// temp.Use(middlewares.VerifyHtmlIp())
|
2024-07-18 17:05:46 +08:00
|
|
|
temp.Use(middlewares.RequestLog())
|
|
|
|
{
|
|
|
|
temp.POST("/recharge/order", zlCon.CreateOrder)
|
2024-08-21 10:18:34 +08:00
|
|
|
temp.POST("/ding/send", dingCon.DingSend)
|
2024-07-18 17:05:46 +08:00
|
|
|
}
|
|
|
|
|
2024-07-12 18:11:21 +08:00
|
|
|
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
|
|
|
}
|