!88 feat: dbms表支持右键菜单:删除表、编辑表、新建表、复制表

* feat: 支持复制表
* feat: dbms表支持右键菜单:删除表、编辑表、新建表
This commit is contained in:
zongyangleo
2024-01-23 04:08:02 +00:00
committed by Coder慌
parent 3b77ab2727
commit 3fc86f0fae
16 changed files with 330 additions and 33 deletions

View File

@@ -462,6 +462,20 @@ func (d *Db) GetSchemas(rc *req.Ctx) {
rc.ResData = res
}
func (d *Db) CopyTable(rc *req.Ctx) {
form := &form.DbCopyTableForm{}
copy := ginx.BindJsonAndCopyTo[*dbi.DbCopyTable](rc.GinCtx, form, new(dbi.DbCopyTable))
conn, err := d.DbApp.GetDbConn(form.Id, form.Db)
biz.ErrIsNilAppendErr(err, "拷贝表失败: %s")
err = conn.GetDialect().CopyTable(copy)
if err != nil {
logx.Errorf("拷贝表失败: %s", err.Error())
}
biz.ErrIsNilAppendErr(err, "拷贝表失败: %s")
}
func getDbId(g *gin.Context) uint64 {
dbId, _ := strconv.Atoi(g.Param("dbId"))
biz.IsTrue(dbId > 0, "dbId错误")

View File

@@ -23,3 +23,11 @@ type DbSqlExecForm struct {
Sql string `binding:"required" json:"sql"` // 执行sql
Remark string `json:"remark"` // 执行备注
}
// 数据库复制表
type DbCopyTableForm struct {
Id uint64 `binding:"required" json:"id"`
Db string `binding:"required" json:"db" `
TableName string `binding:"required" json:"tableName"`
CopyData bool `binding:"required" json:"copyData"` // 是否复制数据
}