mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	fix: sql脚本问题修复等
This commit is contained in:
		@@ -10,6 +10,7 @@
 | 
				
			|||||||
            :default-expanded-keys="[state.selectTags]"
 | 
					            :default-expanded-keys="[state.selectTags]"
 | 
				
			||||||
            show-checkbox
 | 
					            show-checkbox
 | 
				
			||||||
            node-key="codePath"
 | 
					            node-key="codePath"
 | 
				
			||||||
 | 
					            :check-strictly="props.checkStrictly"
 | 
				
			||||||
            :props="{
 | 
					            :props="{
 | 
				
			||||||
                value: 'codePath',
 | 
					                value: 'codePath',
 | 
				
			||||||
                label: 'codePath',
 | 
					                label: 'codePath',
 | 
				
			||||||
@@ -47,6 +48,10 @@ const props = defineProps({
 | 
				
			|||||||
        type: Number,
 | 
					        type: Number,
 | 
				
			||||||
        default: TagResourceTypeEnum.Tag.value,
 | 
					        default: TagResourceTypeEnum.Tag.value,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    checkStrictly: {
 | 
				
			||||||
 | 
					        type: Boolean,
 | 
				
			||||||
 | 
					        default: false,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const state = reactive({
 | 
					const state = reactive({
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@
 | 
				
			|||||||
            <div ref="playerRef" id="rc-player"></div>
 | 
					            <div ref="playerRef" id="rc-player"></div>
 | 
				
			||||||
        </el-dialog>
 | 
					        </el-dialog>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <el-dialog :title="title" v-model="execCmdsDialogVisible" :close-on-click-modal="false" :destroy-on-close="true" width="500">
 | 
					        <el-dialog title="执行命令记录" v-model="execCmdsDialogVisible" :destroy-on-close="true" width="500">
 | 
				
			||||||
            <el-table :data="state.execCmds" max-height="480" stripe size="small">
 | 
					            <el-table :data="state.execCmds" max-height="480" stripe size="small">
 | 
				
			||||||
                <el-table-column prop="cmd" label="命令" show-overflow-tooltip min-width="150px"> </el-table-column>
 | 
					                <el-table-column prop="cmd" label="命令" show-overflow-tooltip min-width="150px"> </el-table-column>
 | 
				
			||||||
                <el-table-column prop="time" label="执行时间" min-width="80" show-overflow-tooltip>
 | 
					                <el-table-column prop="time" label="执行时间" min-width="80" show-overflow-tooltip>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -223,7 +223,8 @@ watchEffect(() => {
 | 
				
			|||||||
        state.form.tagCodePaths = redis.tags.map((t: any) => t.codePath);
 | 
					        state.form.tagCodePaths = redis.tags.map((t: any) => t.codePath);
 | 
				
			||||||
        convertDb(state.form.db);
 | 
					        convertDb(state.form.db);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        state.form = { db: '0' } as any;
 | 
					        state.form = { db: '0', tagCodePaths: [] } as any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        state.dbList = [0];
 | 
					        state.dbList = [0];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,8 +19,8 @@
 | 
				
			|||||||
            </el-tree>
 | 
					            </el-tree>
 | 
				
			||||||
            <template #footer>
 | 
					            <template #footer>
 | 
				
			||||||
                <div class="dialog-footer">
 | 
					                <div class="dialog-footer">
 | 
				
			||||||
                    <el-button @click="cancel">取 消</el-button>
 | 
					                    <el-button :loading="state.submiting" @click="cancel">取 消</el-button>
 | 
				
			||||||
                    <el-button type="primary" @click="btnOk">确 定</el-button>
 | 
					                    <el-button :loading="state.submiting" type="primary" @click="btnOk">确 定</el-button>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </template>
 | 
					            </template>
 | 
				
			||||||
        </el-dialog>
 | 
					        </el-dialog>
 | 
				
			||||||
@@ -66,6 +66,7 @@ const menuTree: any = ref(null);
 | 
				
			|||||||
const state = reactive({
 | 
					const state = reactive({
 | 
				
			||||||
    dialogVisible: false,
 | 
					    dialogVisible: false,
 | 
				
			||||||
    roleInfo: null as any,
 | 
					    roleInfo: null as any,
 | 
				
			||||||
 | 
					    submiting: false,
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { dialogVisible, roleInfo } = toRefs(state);
 | 
					const { dialogVisible, roleInfo } = toRefs(state);
 | 
				
			||||||
@@ -82,12 +83,17 @@ const btnOk = async () => {
 | 
				
			|||||||
    let menuIds = menuTree.value.getCheckedKeys();
 | 
					    let menuIds = menuTree.value.getCheckedKeys();
 | 
				
			||||||
    let halfMenuIds = menuTree.value.getHalfCheckedKeys();
 | 
					    let halfMenuIds = menuTree.value.getHalfCheckedKeys();
 | 
				
			||||||
    let resources = [].concat(menuIds, halfMenuIds).join(',');
 | 
					    let resources = [].concat(menuIds, halfMenuIds).join(',');
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        state.submiting = true;
 | 
				
			||||||
        await roleApi.saveResources.request({
 | 
					        await roleApi.saveResources.request({
 | 
				
			||||||
            id: props.role!.id,
 | 
					            id: props.role!.id,
 | 
				
			||||||
            resourceIds: resources,
 | 
					            resourceIds: resources,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        ElMessage.success('保存成功!');
 | 
					        ElMessage.success('保存成功!');
 | 
				
			||||||
        emit('cancel');
 | 
					        emit('cancel');
 | 
				
			||||||
 | 
					    } finally {
 | 
				
			||||||
 | 
					        state.submiting = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const cancel = () => {
 | 
					const cancel = () => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ require (
 | 
				
			|||||||
	github.com/gin-gonic/gin v1.9.1
 | 
						github.com/gin-gonic/gin v1.9.1
 | 
				
			||||||
	github.com/glebarez/sqlite v1.11.0
 | 
						github.com/glebarez/sqlite v1.11.0
 | 
				
			||||||
	github.com/go-gormigrate/gormigrate/v2 v2.1.0
 | 
						github.com/go-gormigrate/gormigrate/v2 v2.1.0
 | 
				
			||||||
	github.com/go-ldap/ldap/v3 v3.4.6
 | 
						github.com/go-ldap/ldap/v3 v3.4.8
 | 
				
			||||||
	github.com/go-playground/locales v0.14.1
 | 
						github.com/go-playground/locales v0.14.1
 | 
				
			||||||
	github.com/go-playground/universal-translator v0.18.1
 | 
						github.com/go-playground/universal-translator v0.18.1
 | 
				
			||||||
	github.com/go-playground/validator/v10 v10.14.0
 | 
						github.com/go-playground/validator/v10 v10.14.0
 | 
				
			||||||
@@ -21,20 +21,20 @@ require (
 | 
				
			|||||||
	github.com/kanzihuang/vitess/go/vt/sqlparser v0.0.0-20231018071450-ac8d9f0167e9
 | 
						github.com/kanzihuang/vitess/go/vt/sqlparser v0.0.0-20231018071450-ac8d9f0167e9
 | 
				
			||||||
	github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230712084735-068dc2aee82d
 | 
						github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230712084735-068dc2aee82d
 | 
				
			||||||
	github.com/may-fly/cast v1.6.1
 | 
						github.com/may-fly/cast v1.6.1
 | 
				
			||||||
	github.com/microsoft/go-mssqldb v1.7.0
 | 
						github.com/microsoft/go-mssqldb v1.7.1
 | 
				
			||||||
	github.com/mojocn/base64Captcha v1.3.6 // 验证码
 | 
						github.com/mojocn/base64Captcha v1.3.6 // 验证码
 | 
				
			||||||
	github.com/pkg/errors v0.9.1
 | 
						github.com/pkg/errors v0.9.1
 | 
				
			||||||
	github.com/pkg/sftp v1.13.6
 | 
						github.com/pkg/sftp v1.13.6
 | 
				
			||||||
	github.com/pquerna/otp v1.4.0
 | 
						github.com/pquerna/otp v1.4.0
 | 
				
			||||||
	github.com/redis/go-redis/v9 v9.5.1
 | 
						github.com/redis/go-redis/v9 v9.5.1
 | 
				
			||||||
	github.com/robfig/cron/v3 v3.0.1 // 定时任务
 | 
						github.com/robfig/cron/v3 v3.0.1 // 定时任务
 | 
				
			||||||
	github.com/sijms/go-ora/v2 v2.8.10
 | 
						github.com/sijms/go-ora/v2 v2.8.12
 | 
				
			||||||
	github.com/stretchr/testify v1.8.4
 | 
						github.com/stretchr/testify v1.8.4
 | 
				
			||||||
	github.com/veops/go-ansiterm v0.0.5
 | 
						github.com/veops/go-ansiterm v0.0.5
 | 
				
			||||||
	go.mongodb.org/mongo-driver v1.14.0 // mongo
 | 
						go.mongodb.org/mongo-driver v1.15.0 // mongo
 | 
				
			||||||
	golang.org/x/crypto v0.22.0 // ssh
 | 
						golang.org/x/crypto v0.22.0 // ssh
 | 
				
			||||||
	golang.org/x/oauth2 v0.18.0
 | 
						golang.org/x/oauth2 v0.19.0
 | 
				
			||||||
	golang.org/x/sync v0.6.0
 | 
						golang.org/x/sync v0.7.0
 | 
				
			||||||
	gopkg.in/natefinch/lumberjack.v2 v2.2.1
 | 
						gopkg.in/natefinch/lumberjack.v2 v2.2.1
 | 
				
			||||||
	gopkg.in/yaml.v3 v3.0.1
 | 
						gopkg.in/yaml.v3 v3.0.1
 | 
				
			||||||
	// gorm
 | 
						// gorm
 | 
				
			||||||
@@ -94,7 +94,6 @@ require (
 | 
				
			|||||||
	golang.org/x/net v0.22.0 // indirect
 | 
						golang.org/x/net v0.22.0 // indirect
 | 
				
			||||||
	golang.org/x/sys v0.19.0 // indirect
 | 
						golang.org/x/sys v0.19.0 // indirect
 | 
				
			||||||
	golang.org/x/text v0.14.0 // indirect
 | 
						golang.org/x/text v0.14.0 // indirect
 | 
				
			||||||
	google.golang.org/appengine v1.6.7 // indirect
 | 
					 | 
				
			||||||
	google.golang.org/genproto v0.0.0-20230131230820-1c016267d619 // indirect
 | 
						google.golang.org/genproto v0.0.0-20230131230820-1c016267d619 // indirect
 | 
				
			||||||
	google.golang.org/grpc v1.52.3 // indirect
 | 
						google.golang.org/grpc v1.52.3 // indirect
 | 
				
			||||||
	google.golang.org/protobuf v1.31.0 // indirect
 | 
						google.golang.org/protobuf v1.31.0 // indirect
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -136,9 +136,18 @@ func (app *instanceAppImpl) SaveDbInstance(ctx context.Context, instance *SaveDb
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 如果存在该库,则校验修改的库是否为该库
 | 
						// 如果存在该库,则校验修改的库是否为该库
 | 
				
			||||||
	if err == nil && oldInstance.Id != instanceEntity.Id {
 | 
						if err == nil {
 | 
				
			||||||
 | 
							if oldInstance.Id != instanceEntity.Id {
 | 
				
			||||||
			return 0, errorx.NewBiz("该数据库实例已存在")
 | 
								return 0, errorx.NewBiz("该数据库实例已存在")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							// 根据host等未查到旧数据,则需要根据id重新获取,因为后续需要使用到code
 | 
				
			||||||
 | 
							oldInstance, err = app.GetById(new(entity.DbInstance), instanceEntity.Id)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return 0, errorx.NewBiz("该数据库实例不存在")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return oldInstance.Id, app.Tx(ctx, func(ctx context.Context) error {
 | 
						return oldInstance.Id, app.Tx(ctx, func(ctx context.Context) error {
 | 
				
			||||||
		return app.UpdateById(ctx, instanceEntity)
 | 
							return app.UpdateById(ctx, instanceEntity)
 | 
				
			||||||
	}, func(ctx context.Context) error {
 | 
						}, func(ctx context.Context) error {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,7 @@ import (
 | 
				
			|||||||
	"mayfly-go/internal/machine/config"
 | 
						"mayfly-go/internal/machine/config"
 | 
				
			||||||
	"mayfly-go/internal/machine/domain/entity"
 | 
						"mayfly-go/internal/machine/domain/entity"
 | 
				
			||||||
	"mayfly-go/internal/machine/guac"
 | 
						"mayfly-go/internal/machine/guac"
 | 
				
			||||||
 | 
						"mayfly-go/internal/machine/mcm"
 | 
				
			||||||
	tagapp "mayfly-go/internal/tag/application"
 | 
						tagapp "mayfly-go/internal/tag/application"
 | 
				
			||||||
	tagentity "mayfly-go/internal/tag/domain/entity"
 | 
						tagentity "mayfly-go/internal/tag/domain/entity"
 | 
				
			||||||
	"mayfly-go/pkg/biz"
 | 
						"mayfly-go/pkg/biz"
 | 
				
			||||||
@@ -185,11 +186,11 @@ func (m *Machine) WsSSH(g *gin.Context) {
 | 
				
			|||||||
	// 权限校验
 | 
						// 权限校验
 | 
				
			||||||
	rc := req.NewCtxWithGin(g).WithRequiredPermission(req.NewPermission("machine:terminal"))
 | 
						rc := req.NewCtxWithGin(g).WithRequiredPermission(req.NewPermission("machine:terminal"))
 | 
				
			||||||
	if err = req.PermissionHandler(rc); err != nil {
 | 
						if err = req.PermissionHandler(rc); err != nil {
 | 
				
			||||||
		panic(errorx.NewBiz("\033[1;31m您没有权限操作该机器终端,请重新登录后再试~\033[0m"))
 | 
							panic(errorx.NewBiz(mcm.GetErrorContentRn("您没有权限操作该机器终端,请重新登录后再试~")))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cli, err := m.MachineApp.NewCli(GetMachineAc(rc))
 | 
						cli, err := m.MachineApp.NewCli(GetMachineAc(rc))
 | 
				
			||||||
	biz.ErrIsNilAppendErr(err, "获取客户端连接失败: %s")
 | 
						biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("获取客户端连接失败: %s"))
 | 
				
			||||||
	defer cli.Close()
 | 
						defer cli.Close()
 | 
				
			||||||
	biz.ErrIsNilAppendErr(m.TagApp.CanAccess(rc.GetLoginAccount().Id, cli.Info.TagPath...), "%s")
 | 
						biz.ErrIsNilAppendErr(m.TagApp.CanAccess(rc.GetLoginAccount().Id, cli.Info.TagPath...), "%s")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -202,7 +203,7 @@ func (m *Machine) WsSSH(g *gin.Context) {
 | 
				
			|||||||
	req.LogHandler(rc)
 | 
						req.LogHandler(rc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = m.MachineTermOpApp.TermConn(rc.MetaCtx, cli, wsConn, rows, cols)
 | 
						err = m.MachineTermOpApp.TermConn(rc.MetaCtx, cli, wsConn, rows, cols)
 | 
				
			||||||
	biz.ErrIsNilAppendErr(err, "\033[1;31m连接失败: %s\033[0m")
 | 
						biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("连接失败: %s"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *Machine) MachineTermOpRecords(rc *req.Ctx) {
 | 
					func (m *Machine) MachineTermOpRecords(rc *req.Ctx) {
 | 
				
			||||||
@@ -245,7 +246,7 @@ func (m *Machine) WsGuacamole(g *gin.Context) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	rc := req.NewCtxWithGin(g).WithRequiredPermission(req.NewPermission("machine:terminal"))
 | 
						rc := req.NewCtxWithGin(g).WithRequiredPermission(req.NewPermission("machine:terminal"))
 | 
				
			||||||
	if err = req.PermissionHandler(rc); err != nil {
 | 
						if err = req.PermissionHandler(rc); err != nil {
 | 
				
			||||||
		panic(errorx.NewBiz("\033[1;31m您没有权限操作该机器终端,请重新登录后再试~\033[0m"))
 | 
							panic(errorx.NewBiz(mcm.GetErrorContentRn("您没有权限操作该机器终端,请重新登录后再试~")))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ac := GetMachineAc(rc)
 | 
						ac := GetMachineAc(rc)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,6 +70,8 @@ type machineAppImpl struct {
 | 
				
			|||||||
	resourceAuthCertApp tagapp.ResourceAuthCert `inject:"ResourceAuthCertApp"`
 | 
						resourceAuthCertApp tagapp.ResourceAuthCert `inject:"ResourceAuthCertApp"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _ (Machine) = (*machineAppImpl)(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 注入MachineRepo
 | 
					// 注入MachineRepo
 | 
				
			||||||
func (m *machineAppImpl) InjectMachineRepo(repo repository.Machine) {
 | 
					func (m *machineAppImpl) InjectMachineRepo(repo repository.Machine) {
 | 
				
			||||||
	m.Repo = repo
 | 
						m.Repo = repo
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,8 @@ type GinF struct {
 | 
				
			|||||||
	ginCtx *gin.Context
 | 
						ginCtx *gin.Context
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var _ (F) = (*GinF)(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (gf *GinF) GetRequest() *http.Request {
 | 
					func (gf *GinF) GetRequest() *http.Request {
 | 
				
			||||||
	return gf.ginCtx.Request
 | 
						return gf.ginCtx.Request
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -36,7 +38,7 @@ func (gf *GinF) BindJSON(data any) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (gf *GinF) BindQuery(data any) error {
 | 
					func (gf *GinF) BindQuery(data any) error {
 | 
				
			||||||
	return gf.ginCtx.BindQuery(data)
 | 
						return gf.ginCtx.ShouldBindQuery(data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (gf *GinF) Query(qm string) string {
 | 
					func (gf *GinF) Query(qm string) string {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -493,7 +493,7 @@ CREATE TABLE `t_machine_term_op` (
 | 
				
			|||||||
  `machine_id` bigint NOT NULL COMMENT '机器id',
 | 
					  `machine_id` bigint NOT NULL COMMENT '机器id',
 | 
				
			||||||
  `username` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '登录用户名',
 | 
					  `username` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '登录用户名',
 | 
				
			||||||
  `record_file_path` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '终端回放文件路径',
 | 
					  `record_file_path` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '终端回放文件路径',
 | 
				
			||||||
  `exec_cmds` TEXT NULL COMMENT '执行的命令记录'
 | 
					  `exec_cmds` TEXT NULL COMMENT '执行的命令记录',
 | 
				
			||||||
  `creator_id` bigint unsigned DEFAULT NULL,
 | 
					  `creator_id` bigint unsigned DEFAULT NULL,
 | 
				
			||||||
  `creator` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
 | 
					  `creator` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
 | 
				
			||||||
  `create_time` datetime NOT NULL,
 | 
					  `create_time` datetime NOT NULL,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user