2021-04-16 15:10:07 +08:00
|
|
|
package routers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"mayfly-go/base/ctx"
|
2021-06-07 17:22:07 +08:00
|
|
|
"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")
|
|
|
|
|
{
|
2021-05-08 18:00:33 +08:00
|
|
|
d := &apis.Db{DbApp: application.Db}
|
2021-04-16 15:10:07 +08:00
|
|
|
// 获取所有数据库列表
|
|
|
|
|
db.GET("", func(c *gin.Context) {
|
|
|
|
|
rc := ctx.NewReqCtxWithGin(c)
|
2021-05-08 18:00:33 +08:00
|
|
|
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("执行数据库查询语句"))
|
2021-05-08 18:00:33 +08:00
|
|
|
rc.Handle(d.SelectData)
|
2021-04-16 15:10:07 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
db.GET(":dbId/t-metadata", func(c *gin.Context) {
|
2021-05-08 18:00:33 +08:00
|
|
|
ctx.NewReqCtxWithGin(c).Handle(d.TableMA)
|
2021-04-16 15:10:07 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
db.GET(":dbId/c-metadata", func(c *gin.Context) {
|
2021-05-08 18:00:33 +08:00
|
|
|
ctx.NewReqCtxWithGin(c).Handle(d.ColumnMA)
|
2021-04-16 15:10:07 +08:00
|
|
|
})
|
|
|
|
|
db.GET(":dbId/hint-tables", func(c *gin.Context) {
|
2021-05-08 18:00:33 +08:00
|
|
|
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内容"))
|
2021-05-08 18:00:33 +08:00
|
|
|
rc.Handle(d.SaveSql)
|
2021-04-16 15:10:07 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
db.GET(":dbId/sql", func(c *gin.Context) {
|
2021-05-08 18:00:33 +08:00
|
|
|
ctx.NewReqCtxWithGin(c).Handle(d.GetSql)
|
2021-04-16 15:10:07 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|