mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-04-24 05:05:20 +08:00
refactor: 包名变更ctx -> req
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"mayfly-go/internal/db/application"
|
||||
sysapp "mayfly-go/internal/sys/application"
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -21,94 +21,94 @@ func InitDbRouter(router *gin.RouterGroup) {
|
||||
}
|
||||
// 获取所有数据库列表
|
||||
db.GET("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.Dbs)
|
||||
req.NewCtxWithGin(c).Handle(d.Dbs)
|
||||
})
|
||||
|
||||
saveDb := ctx.NewLogInfo("db-保存数据库信息").WithSave(true)
|
||||
saveDb := req.NewLogInfo("db-保存数据库信息").WithSave(true)
|
||||
db.POST("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(saveDb).
|
||||
Handle(d.Save)
|
||||
})
|
||||
|
||||
// 获取数据库实例的所有数据库名
|
||||
db.POST("databases", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
Handle(d.GetDatabaseNames)
|
||||
})
|
||||
|
||||
db.GET(":dbId/pwd", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.GetDbPwd)
|
||||
req.NewCtxWithGin(c).Handle(d.GetDbPwd)
|
||||
})
|
||||
|
||||
deleteDb := ctx.NewLogInfo("db-删除数据库信息").WithSave(true)
|
||||
deleteDb := req.NewLogInfo("db-删除数据库信息").WithSave(true)
|
||||
db.DELETE(":dbId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).
|
||||
req.NewCtxWithGin(c).
|
||||
WithLog(deleteDb).
|
||||
Handle(d.DeleteDb)
|
||||
})
|
||||
|
||||
db.GET(":dbId/t-infos", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.TableInfos)
|
||||
req.NewCtxWithGin(c).Handle(d.TableInfos)
|
||||
})
|
||||
|
||||
db.GET(":dbId/t-index", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.TableIndex)
|
||||
req.NewCtxWithGin(c).Handle(d.TableIndex)
|
||||
})
|
||||
|
||||
db.GET(":dbId/t-create-ddl", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.GetCreateTableDdl)
|
||||
req.NewCtxWithGin(c).Handle(d.GetCreateTableDdl)
|
||||
})
|
||||
|
||||
execSqlLog := ctx.NewLogInfo("db-执行Sql")
|
||||
execSqlLog := req.NewLogInfo("db-执行Sql")
|
||||
db.POST(":dbId/exec-sql", func(g *gin.Context) {
|
||||
rc := ctx.NewReqCtxWithGin(g).WithLog(execSqlLog)
|
||||
rc := req.NewCtxWithGin(g).WithLog(execSqlLog)
|
||||
rc.Handle(d.ExecSql)
|
||||
})
|
||||
|
||||
execSqlFileLog := ctx.NewLogInfo("db-执行Sql文件").WithSave(true)
|
||||
execSqlFileLog := req.NewLogInfo("db-执行Sql文件").WithSave(true)
|
||||
db.POST(":dbId/exec-sql-file", func(g *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(g).
|
||||
req.NewCtxWithGin(g).
|
||||
WithLog(execSqlFileLog).
|
||||
Handle(d.ExecSqlFile)
|
||||
})
|
||||
|
||||
dumpLog := ctx.NewLogInfo("db-导出sql文件").WithSave(true)
|
||||
dumpLog := req.NewLogInfo("db-导出sql文件").WithSave(true)
|
||||
db.GET(":dbId/dump", func(g *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(g).
|
||||
req.NewCtxWithGin(g).
|
||||
WithLog(dumpLog).
|
||||
Handle(d.DumpSql)
|
||||
})
|
||||
|
||||
db.GET(":dbId/t-metadata", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.TableMA)
|
||||
req.NewCtxWithGin(c).Handle(d.TableMA)
|
||||
})
|
||||
|
||||
db.GET(":dbId/c-metadata", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.ColumnMA)
|
||||
req.NewCtxWithGin(c).Handle(d.ColumnMA)
|
||||
})
|
||||
|
||||
db.GET(":dbId/hint-tables", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.HintTables)
|
||||
req.NewCtxWithGin(c).Handle(d.HintTables)
|
||||
})
|
||||
|
||||
/** db sql相关接口 */
|
||||
|
||||
db.POST(":dbId/sql", func(c *gin.Context) {
|
||||
rc := ctx.NewReqCtxWithGin(c)
|
||||
rc := req.NewCtxWithGin(c)
|
||||
rc.Handle(d.SaveSql)
|
||||
})
|
||||
|
||||
db.GET(":dbId/sql", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.GetSql)
|
||||
req.NewCtxWithGin(c).Handle(d.GetSql)
|
||||
})
|
||||
|
||||
db.DELETE(":dbId/sql", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.DeleteSql)
|
||||
req.NewCtxWithGin(c).Handle(d.DeleteSql)
|
||||
})
|
||||
|
||||
db.GET(":dbId/sql-names", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).Handle(d.GetSqlNames)
|
||||
req.NewCtxWithGin(c).Handle(d.GetSqlNames)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package router
|
||||
import (
|
||||
"mayfly-go/internal/db/api"
|
||||
"mayfly-go/internal/db/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -16,7 +16,7 @@ func InitDbSqlExecRouter(router *gin.RouterGroup) {
|
||||
}
|
||||
// 获取所有数据库sql执行记录列表
|
||||
db.GET("", func(c *gin.Context) {
|
||||
rc := ctx.NewReqCtxWithGin(c)
|
||||
rc := req.NewCtxWithGin(c)
|
||||
rc.Handle(d.DbSqlExecs)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user