mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package router
 | 
						|
 | 
						|
import (
 | 
						|
	"mayfly-go/internal/db/api"
 | 
						|
	"mayfly-go/internal/db/application"
 | 
						|
	msgapp "mayfly-go/internal/msg/application"
 | 
						|
	tagapp "mayfly-go/internal/tag/application"
 | 
						|
	"mayfly-go/pkg/req"
 | 
						|
 | 
						|
	"github.com/gin-gonic/gin"
 | 
						|
)
 | 
						|
 | 
						|
func InitDbRouter(router *gin.RouterGroup) {
 | 
						|
	db := router.Group("dbs")
 | 
						|
 | 
						|
	d := &api.Db{
 | 
						|
		InstanceApp:  application.GetInstanceApp(),
 | 
						|
		DbApp:        application.GetDbApp(),
 | 
						|
		DbSqlExecApp: application.GetDbSqlExecApp(),
 | 
						|
		MsgApp:       msgapp.GetMsgApp(),
 | 
						|
		TagApp:       tagapp.GetTagTreeApp(),
 | 
						|
	}
 | 
						|
 | 
						|
	reqs := [...]*req.Conf{
 | 
						|
		// 获取数据库列表
 | 
						|
		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.GetCreateTableDdl),
 | 
						|
 | 
						|
		req.NewGet(":dbId/pg/schemas", d.GetPgsqlSchemas),
 | 
						|
 | 
						|
		req.NewPost(":dbId/exec-sql", d.ExecSql).Log(req.NewLog("db-执行Sql")),
 | 
						|
 | 
						|
		req.NewPost(":dbId/exec-sql/cancel/:execId", d.CancelExecSql).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.BatchSetGroup(db, reqs[:])
 | 
						|
 | 
						|
}
 |