Files
mayfly-go/server/devops/routers/db.go

47 lines
1.1 KiB
Go
Raw Normal View History

2021-04-16 15:10:07 +08:00
package routers
import (
"mayfly-go/base/ctx"
"mayfly-go/server/devops/apis"
"mayfly-go/server/devops/application"
2021-04-16 15:10:07 +08:00
"github.com/gin-gonic/gin"
)
func InitDbRouter(router *gin.RouterGroup) {
db := router.Group("dbs")
{
d := &apis.Db{DbApp: application.Db}
2021-04-16 15:10:07 +08:00
// 获取所有数据库列表
db.GET("", func(c *gin.Context) {
rc := ctx.NewReqCtxWithGin(c)
rc.Handle(d.Dbs)
2021-04-16 15:10:07 +08:00
})
// db.GET(":dbId/select", controllers.SelectData)
db.GET(":dbId/select", func(g *gin.Context) {
rc := ctx.NewReqCtxWithGin(g).WithLog(ctx.NewLogInfo("执行数据库查询语句"))
rc.Handle(d.SelectData)
2021-04-16 15:10:07 +08:00
})
db.GET(":dbId/t-metadata", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(d.TableMA)
2021-04-16 15:10:07 +08:00
})
db.GET(":dbId/c-metadata", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(d.ColumnMA)
2021-04-16 15:10:07 +08:00
})
db.GET(":dbId/hint-tables", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(d.HintTables)
2021-04-16 15:10:07 +08:00
})
db.POST(":dbId/sql", func(c *gin.Context) {
rc := ctx.NewReqCtxWithGin(c).WithLog(ctx.NewLogInfo("保存sql内容"))
rc.Handle(d.SaveSql)
2021-04-16 15:10:07 +08:00
})
db.GET(":dbId/sql", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).Handle(d.GetSql)
2021-04-16 15:10:07 +08:00
})
}
}