mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
* fix: 代码合并 * feat:支持数据库版本兼容,目前兼容了oracle11g部分特性 * fix: 修改数据同步bug,数据sql里指定修改字段别,导致未正确记录修改字段值 * feat: 数据库迁移支持定时迁移和迁移到sql文件
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package router
|
|
|
|
import (
|
|
"mayfly-go/internal/db/api"
|
|
"mayfly-go/pkg/biz"
|
|
"mayfly-go/pkg/ioc"
|
|
"mayfly-go/pkg/req"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func InitDbRouter(router *gin.RouterGroup) {
|
|
db := router.Group("dbs")
|
|
|
|
d := new(api.Db)
|
|
biz.ErrIsNil(ioc.Inject(d))
|
|
|
|
dashbord := new(api.Dashbord)
|
|
biz.ErrIsNil(ioc.Inject(dashbord))
|
|
|
|
reqs := [...]*req.Conf{
|
|
req.NewGet("dashbord", dashbord.Dashbord),
|
|
|
|
// 获取数据库列表
|
|
req.NewGet("", d.Dbs),
|
|
|
|
req.NewPost("", d.Save).Log(req.NewLogSave("db-保存数据库信息")),
|
|
|
|
req.NewDelete(":dbId", d.DeleteDb).Log(req.NewLogSave("db-删除数据库信息")),
|
|
|
|
req.NewGet(":dbId/t-create-ddl", d.GetTableDDL),
|
|
|
|
req.NewGet(":dbId/version", d.GetVersion),
|
|
|
|
req.NewGet(":dbId/pg/schemas", d.GetSchemas),
|
|
|
|
req.NewPost(":dbId/exec-sql", d.ExecSql).Log(req.NewLog("db-执行Sql")),
|
|
|
|
req.NewPost(":dbId/exec-sql-file", d.ExecSqlFile).Log(req.NewLogSave("db-执行Sql文件")),
|
|
|
|
req.NewGet(":dbId/dump", d.DumpSql).Log(req.NewLogSave("db-导出sql文件")).NoRes(),
|
|
|
|
req.NewGet(":dbId/t-infos", d.TableInfos),
|
|
|
|
req.NewGet(":dbId/t-index", d.TableIndex),
|
|
|
|
req.NewGet(":dbId/c-metadata", d.ColumnMA),
|
|
|
|
req.NewGet(":dbId/hint-tables", d.HintTables),
|
|
|
|
req.NewPost(":dbId/copy-table", d.CopyTable),
|
|
}
|
|
|
|
req.BatchSetGroup(db, reqs[:])
|
|
|
|
}
|