mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-29 20:40:24 +08:00
refactor: pacakge version upgrade
This commit is contained in:
@@ -12,14 +12,17 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"@vueuse/core": "^12.7.0",
|
"@vueuse/core": "^12.7.0",
|
||||||
|
"@xterm/addon-fit": "^0.10.0",
|
||||||
|
"@xterm/addon-search": "^0.15.0",
|
||||||
|
"@xterm/addon-web-links": "^0.11.0",
|
||||||
|
"@xterm/xterm": "^5.5.0",
|
||||||
"asciinema-player": "^3.9.0",
|
"asciinema-player": "^3.9.0",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
"cropperjs": "^1.6.1",
|
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"echarts": "^5.6.0",
|
"echarts": "^5.6.0",
|
||||||
"element-plus": "^2.9.4",
|
"element-plus": "^2.9.5",
|
||||||
"js-base64": "^3.7.7",
|
"js-base64": "^3.7.7",
|
||||||
"jsencrypt": "^3.3.2",
|
"jsencrypt": "^3.3.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
@@ -39,11 +42,7 @@
|
|||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vue-i18n": "^11.1.1",
|
"vue-i18n": "^11.1.1",
|
||||||
"vue-router": "^4.5.0",
|
"vue-router": "^4.5.0",
|
||||||
"vuedraggable": "^4.1.0",
|
"vuedraggable": "^4.1.0"
|
||||||
"xterm": "^5.3.0",
|
|
||||||
"xterm-addon-fit": "^0.8.0",
|
|
||||||
"xterm-addon-search": "^0.13.0",
|
|
||||||
"xterm-addon-web-links": "^0.9.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
@@ -62,7 +61,7 @@
|
|||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"sass": "^1.85.0",
|
"sass": "^1.85.0",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"vite": "^6.1.1",
|
"vite": "^6.2.0",
|
||||||
"vite-plugin-progress": "0.0.7",
|
"vite-plugin-progress": "0.0.7",
|
||||||
"vue-eslint-parser": "^9.4.3"
|
"vue-eslint-parser": "^9.4.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-dialog title="更换头像" v-model="isShowDialog" width="769px">
|
|
||||||
<div class="cropper-warp">
|
|
||||||
<div class="cropper-warp-left">
|
|
||||||
<img :src="cropperImg" class="cropper-warp-left-img" />
|
|
||||||
</div>
|
|
||||||
<div class="cropper-warp-right">
|
|
||||||
<div class="cropper-warp-right-title">预览</div>
|
|
||||||
<div class="cropper-warp-right-item">
|
|
||||||
<div class="cropper-warp-right-value">
|
|
||||||
<img :src="cropperImgBase64" class="cropper-warp-right-value-img" />
|
|
||||||
</div>
|
|
||||||
<div class="cropper-warp-right-label">100 x 100</div>
|
|
||||||
</div>
|
|
||||||
<div class="cropper-warp-right-item">
|
|
||||||
<div class="cropper-warp-right-value">
|
|
||||||
<img :src="cropperImgBase64" class="cropper-warp-right-value-img cropper-size" />
|
|
||||||
</div>
|
|
||||||
<div class="cropper-warp-right-label">50 x 50</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="onCancel" size="small">取 消</el-button>
|
|
||||||
<el-button type="primary" @click="onSubmit" size="small">更 换</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { reactive, toRefs, nextTick } from 'vue';
|
|
||||||
import Cropper from 'cropperjs';
|
|
||||||
import 'cropperjs/dist/cropper.css';
|
|
||||||
export default {
|
|
||||||
name: 'cropperIndex',
|
|
||||||
setup() {
|
|
||||||
const state = reactive({
|
|
||||||
isShowDialog: false,
|
|
||||||
cropperImg: '',
|
|
||||||
cropperImgBase64: '',
|
|
||||||
});
|
|
||||||
// 打开弹窗
|
|
||||||
const openDialog = (imgs: any) => {
|
|
||||||
state.cropperImg = imgs;
|
|
||||||
state.isShowDialog = true;
|
|
||||||
nextTick(() => {
|
|
||||||
initCropper();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// 关闭弹窗
|
|
||||||
const closeDialog = () => {
|
|
||||||
state.isShowDialog = false;
|
|
||||||
};
|
|
||||||
// 取消
|
|
||||||
const onCancel = () => {
|
|
||||||
closeDialog();
|
|
||||||
};
|
|
||||||
// 新增
|
|
||||||
const onSubmit = () => {};
|
|
||||||
// 初始化cropperjs图片裁剪
|
|
||||||
const initCropper = () => {
|
|
||||||
const letImg: any = document.querySelector('.cropper-warp-left-img');
|
|
||||||
const cropper = new Cropper(letImg, {
|
|
||||||
viewMode: 1,
|
|
||||||
dragMode: 'none',
|
|
||||||
initialAspectRatio: 1,
|
|
||||||
aspectRatio: 1,
|
|
||||||
preview: '.before',
|
|
||||||
background: false,
|
|
||||||
autoCropArea: 0.6,
|
|
||||||
zoomOnWheel: false,
|
|
||||||
crop: () => {
|
|
||||||
state.cropperImgBase64 = cropper.getCroppedCanvas().toDataURL('image/jpeg');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
openDialog,
|
|
||||||
closeDialog,
|
|
||||||
onCancel,
|
|
||||||
onSubmit,
|
|
||||||
initCropper,
|
|
||||||
...toRefs(state),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.cropper-warp {
|
|
||||||
display: flex;
|
|
||||||
.cropper-warp-left {
|
|
||||||
position: relative;
|
|
||||||
display: inline-block;
|
|
||||||
height: 350px;
|
|
||||||
flex: 1;
|
|
||||||
border: 1px solid #ebeef5;
|
|
||||||
background: #fff;
|
|
||||||
overflow: hidden;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
cursor: move;
|
|
||||||
border-radius: 3px;
|
|
||||||
.cropper-warp-left-img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.cropper-warp-right {
|
|
||||||
width: 150px;
|
|
||||||
height: 350px;
|
|
||||||
.cropper-warp-right-title {
|
|
||||||
text-align: center;
|
|
||||||
height: 20px;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
.cropper-warp-right-item {
|
|
||||||
margin: 15px 0;
|
|
||||||
.cropper-warp-right-value {
|
|
||||||
display: flex;
|
|
||||||
.cropper-warp-right-value-img {
|
|
||||||
width: 100px;
|
|
||||||
height: 100px;
|
|
||||||
border-radius: 100%;
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
.cropper-size {
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.cropper-warp-right-label {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #666666;
|
|
||||||
height: 30px;
|
|
||||||
line-height: 30px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import 'xterm/css/xterm.css';
|
import '@xterm/xterm/css/xterm.css';
|
||||||
import { Terminal, ITheme } from 'xterm';
|
import { Terminal, ITheme } from '@xterm/xterm';
|
||||||
import { FitAddon } from 'xterm-addon-fit';
|
import { FitAddon } from '@xterm/addon-fit';
|
||||||
import { SearchAddon } from 'xterm-addon-search';
|
import { SearchAddon } from '@xterm/addon-search';
|
||||||
import { WebLinksAddon } from 'xterm-addon-web-links';
|
import { WebLinksAddon } from '@xterm/addon-web-links';
|
||||||
|
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useThemeConfig } from '@/store/themeConfig';
|
import { useThemeConfig } from '@/store/themeConfig';
|
||||||
@@ -238,7 +238,7 @@ const getTerminalTheme = () => {
|
|||||||
const terminalTheme = themeConfig.value.terminalTheme;
|
const terminalTheme = themeConfig.value.terminalTheme;
|
||||||
// 如果不是自定义主题,则返回内置主题
|
// 如果不是自定义主题,则返回内置主题
|
||||||
if (terminalTheme != 'custom') {
|
if (terminalTheme != 'custom') {
|
||||||
return themes[terminalTheme];
|
return (themes as any)[terminalTheme];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义主题
|
// 自定义主题
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, toRefs, nextTick, reactive } from 'vue';
|
import { ref, toRefs, nextTick, reactive } from 'vue';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { SearchAddon, ISearchOptions } from 'xterm-addon-search';
|
import { SearchAddon, ISearchOptions } from '@xterm/addon-search';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ const DefaultForm = {
|
|||||||
name: null,
|
name: null,
|
||||||
host: '',
|
host: '',
|
||||||
port: getDbDialect(DbType.mysql).getInfo().defaultPort,
|
port: getDbDialect(DbType.mysql).getInfo().defaultPort,
|
||||||
extra: '', // 连接需要的额外参数(json字符串)
|
extra: null, // 连接需要的额外参数(json字符串)
|
||||||
params: null,
|
params: null,
|
||||||
remark: '',
|
remark: '',
|
||||||
sshTunnelMachineId: null as any,
|
sshTunnelMachineId: null as any,
|
||||||
@@ -223,11 +223,7 @@ watchEffect(() => {
|
|||||||
if (dbInst) {
|
if (dbInst) {
|
||||||
state.form = { ...dbInst };
|
state.form = { ...dbInst };
|
||||||
state.form.tagCodePaths = dbInst.tags.map((t: any) => t.codePath) || [];
|
state.form.tagCodePaths = dbInst.tags.map((t: any) => t.codePath) || [];
|
||||||
try {
|
state.extra = dbInst.extra || {};
|
||||||
state.extra = JSON.parse(state.form.extra);
|
|
||||||
} catch (e) {
|
|
||||||
state.extra = {};
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
state.form = { ...DefaultForm };
|
state.form = { ...DefaultForm };
|
||||||
state.form.authCerts = [];
|
state.form.authCerts = [];
|
||||||
@@ -242,7 +238,7 @@ const getReqForm = async () => {
|
|||||||
reqForm.sshTunnelMachineId = -1;
|
reqForm.sshTunnelMachineId = -1;
|
||||||
}
|
}
|
||||||
if (Object.keys(state.extra).length > 0) {
|
if (Object.keys(state.extra).length > 0) {
|
||||||
reqForm.extra = JSON.stringify(state.extra);
|
reqForm.extra = state.extra;
|
||||||
}
|
}
|
||||||
return reqForm;
|
return reqForm;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,21 +18,21 @@ require (
|
|||||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/websocket v1.5.3
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20230712084735-068dc2aee82d
|
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20241220152942-06eb5c6e8230
|
||||||
github.com/may-fly/cast v1.7.1
|
github.com/may-fly/cast v1.7.1
|
||||||
github.com/microsoft/go-mssqldb v1.8.0
|
github.com/microsoft/go-mssqldb v1.8.0
|
||||||
github.com/mojocn/base64Captcha v1.3.8 // 验证码
|
github.com/mojocn/base64Captcha v1.3.8 // 验证码
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/pkg/sftp v1.13.7
|
github.com/pkg/sftp v1.13.7
|
||||||
github.com/pquerna/otp v1.4.0
|
github.com/pquerna/otp v1.4.0
|
||||||
github.com/redis/go-redis/v9 v9.7.0
|
github.com/redis/go-redis/v9 v9.7.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.23
|
github.com/sijms/go-ora/v2 v2.8.24
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.10.0
|
||||||
github.com/tidwall/gjson v1.18.0
|
github.com/tidwall/gjson v1.18.0
|
||||||
github.com/veops/go-ansiterm v0.0.5
|
github.com/veops/go-ansiterm v0.0.5
|
||||||
go.mongodb.org/mongo-driver v1.16.0 // mongo
|
go.mongodb.org/mongo-driver v1.16.0 // mongo
|
||||||
golang.org/x/crypto v0.33.0 // ssh
|
golang.org/x/crypto v0.35.0 // ssh
|
||||||
golang.org/x/oauth2 v0.26.0
|
golang.org/x/oauth2 v0.26.0
|
||||||
golang.org/x/sync v0.11.0
|
golang.org/x/sync v0.11.0
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
package form
|
package form
|
||||||
|
|
||||||
import tagentity "mayfly-go/internal/tag/domain/entity"
|
import (
|
||||||
|
tagentity "mayfly-go/internal/tag/domain/entity"
|
||||||
|
"mayfly-go/pkg/model"
|
||||||
|
)
|
||||||
|
|
||||||
type InstanceForm struct {
|
type InstanceForm struct {
|
||||||
|
model.ExtraData
|
||||||
|
|
||||||
Id uint64 `json:"id"`
|
Id uint64 `json:"id"`
|
||||||
Name string `binding:"required" json:"name"`
|
Name string `binding:"required" json:"name"`
|
||||||
Type string `binding:"required" json:"type"` // 类型,mysql oracle等
|
Type string `binding:"required" json:"type"` // 类型,mysql oracle等
|
||||||
Host string `binding:"required" json:"host"`
|
Host string `binding:"required" json:"host"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Extra string `json:"extra"`
|
|
||||||
Params string `json:"params"`
|
Params string `json:"params"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
SshTunnelMachineId int `json:"sshTunnelMachineId"`
|
SshTunnelMachineId int `json:"sshTunnelMachineId"`
|
||||||
@@ -18,11 +22,12 @@ type InstanceForm struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InstanceDbNamesForm struct {
|
type InstanceDbNamesForm struct {
|
||||||
|
model.ExtraData
|
||||||
|
|
||||||
Type string `binding:"required" json:"type"` // 类型,mysql oracle等
|
Type string `binding:"required" json:"type"` // 类型,mysql oracle等
|
||||||
Host string `binding:"required" json:"host"`
|
Host string `binding:"required" json:"host"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Params string `json:"params"`
|
Params string `json:"params"`
|
||||||
Extra string `json:"extra"`
|
|
||||||
SshTunnelMachineId int `json:"sshTunnelMachineId"`
|
SshTunnelMachineId int `json:"sshTunnelMachineId"`
|
||||||
AuthCert *tagentity.ResourceAuthCert `json:"authCert" binding:"required"` // 资产授权凭证信息
|
AuthCert *tagentity.ResourceAuthCert `json:"authCert" binding:"required"` // 资产授权凭证信息
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package vo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
tagentity "mayfly-go/internal/tag/domain/entity"
|
tagentity "mayfly-go/internal/tag/domain/entity"
|
||||||
|
"mayfly-go/pkg/model"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InstanceListVO struct {
|
type InstanceListVO struct {
|
||||||
|
model.ExtraData
|
||||||
tagentity.AuthCerts // 授权凭证信息
|
tagentity.AuthCerts // 授权凭证信息
|
||||||
tagentity.ResourceTags
|
tagentity.ResourceTags
|
||||||
|
|
||||||
@@ -16,7 +18,6 @@ type InstanceListVO struct {
|
|||||||
Port *int `json:"port"`
|
Port *int `json:"port"`
|
||||||
Type *string `json:"type"`
|
Type *string `json:"type"`
|
||||||
Params string `json:"params"`
|
Params string `json:"params"`
|
||||||
Extra string `json:"extra"`
|
|
||||||
Remark *string `json:"remark"`
|
Remark *string `json:"remark"`
|
||||||
CreateTime *time.Time `json:"createTime"`
|
CreateTime *time.Time `json:"createTime"`
|
||||||
Creator *string `json:"creator"`
|
Creator *string `json:"creator"`
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ func (app *instanceAppImpl) toDbInfoByAc(instance *entity.DbInstance, ac *tagent
|
|||||||
di.InstanceId = instance.Id
|
di.InstanceId = instance.Id
|
||||||
di.Database = database
|
di.Database = database
|
||||||
structx.Copy(di, instance)
|
structx.Copy(di, instance)
|
||||||
|
di.Extra = instance.Extra
|
||||||
|
|
||||||
di.Username = ac.Username
|
di.Username = ac.Username
|
||||||
di.Password = ac.Ciphertext
|
di.Password = ac.Ciphertext
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"mayfly-go/internal/machine/mcm"
|
"mayfly-go/internal/machine/mcm"
|
||||||
"mayfly-go/pkg/errorx"
|
"mayfly-go/pkg/errorx"
|
||||||
"mayfly-go/pkg/logx"
|
"mayfly-go/pkg/logx"
|
||||||
|
"mayfly-go/pkg/model"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,6 +21,8 @@ func (dbType DbType) Equal(typ string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DbInfo struct {
|
type DbInfo struct {
|
||||||
|
model.ExtraData // 连接需要的其他额外参数(json字符串),如oracle数据库需要指定sid等
|
||||||
|
|
||||||
InstanceId uint64 // 实例id
|
InstanceId uint64 // 实例id
|
||||||
Id uint64 // dbId
|
Id uint64 // dbId
|
||||||
Name string
|
Name string
|
||||||
@@ -27,7 +30,6 @@ type DbInfo struct {
|
|||||||
Type DbType // 类型,mysql postgres等
|
Type DbType // 类型,mysql postgres等
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
Extra string // 连接需要的其他额外参数(json字符串),如oracle数据库需要指定sid等
|
|
||||||
Network string
|
Network string
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"mayfly-go/internal/db/dbm/dbi"
|
"mayfly-go/internal/db/dbm/dbi"
|
||||||
"mayfly-go/pkg/utils/collx"
|
"mayfly-go/pkg/utils/collx"
|
||||||
"mayfly-go/pkg/utils/jsonx"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/may-fly/cast"
|
"github.com/may-fly/cast"
|
||||||
@@ -59,13 +58,9 @@ func (om *Meta) GetSqlDb(d *dbi.DbInfo) (*sql.DB, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 从extra获取sid或serviceName
|
// 从extra获取sid或serviceName
|
||||||
serviceName := ""
|
serviceName := d.GetExtraString("serviceName")
|
||||||
if d.Extra != "" {
|
if sid := d.GetExtraString("sid"); sid != "" {
|
||||||
extraMap := jsonx.ToMap(d.Extra)
|
urlOptions["SID"] = sid
|
||||||
serviceName = cast.ToString(extraMap["serviceName"])
|
|
||||||
if sid := cast.ToString(extraMap["sid"]); sid != "" {
|
|
||||||
urlOptions["SID"] = sid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
urlOptions["TIMEOUT"] = "1000"
|
urlOptions["TIMEOUT"] = "1000"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
// DbInstance 数据库实例信息
|
// DbInstance 数据库实例信息
|
||||||
type DbInstance struct {
|
type DbInstance struct {
|
||||||
model.Model
|
model.Model
|
||||||
|
model.ExtraData // 连接需要的其他额外参数(json字符串),如oracle数据库需要指定sid等
|
||||||
|
|
||||||
Code string `json:"code" gorm:"size:32;not null;"`
|
Code string `json:"code" gorm:"size:32;not null;"`
|
||||||
Name string `json:"name" gorm:"size:32;not null;"`
|
Name string `json:"name" gorm:"size:32;not null;"`
|
||||||
@@ -15,8 +16,7 @@ type DbInstance struct {
|
|||||||
Host string `json:"host" gorm:"size:255;not null;"`
|
Host string `json:"host" gorm:"size:255;not null;"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Network string `json:"network" gorm:"size:20;"`
|
Network string `json:"network" gorm:"size:20;"`
|
||||||
Extra *string `json:"extra" gorm:"size:1000;comment:连接需要的额外参数,如oracle数据库需要sid等"` // 连接需要的其他额外参数(json格式), 如oracle需要sid等
|
Params *string `json:"params" gorm:"size:255;comment:其他连接参数"` // 使用指针类型,可更新为零值(空字符串)
|
||||||
Params *string `json:"params" gorm:"size:255;comment:其他连接参数"` // 使用指针类型,可更新为零值(空字符串)
|
|
||||||
Remark *string `json:"remark" gorm:"size:255;"`
|
Remark *string `json:"remark" gorm:"size:255;"`
|
||||||
SshTunnelMachineId int `json:"sshTunnelMachineId"` // ssh隧道机器id
|
SshTunnelMachineId int `json:"sshTunnelMachineId"` // ssh隧道机器id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
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"
|
||||||
"mayfly-go/pkg/errorx"
|
|
||||||
"mayfly-go/pkg/global"
|
"mayfly-go/pkg/global"
|
||||||
"mayfly-go/pkg/logx"
|
"mayfly-go/pkg/logx"
|
||||||
"mayfly-go/pkg/model"
|
"mayfly-go/pkg/model"
|
||||||
@@ -69,8 +68,8 @@ func (m *Machine) ReqConfs() *req.Confs {
|
|||||||
req.NewGet(":machineId/term-recs", m.MachineTermOpRecords).RequiredPermission(saveMachineP),
|
req.NewGet(":machineId/term-recs", m.MachineTermOpRecords).RequiredPermission(saveMachineP),
|
||||||
|
|
||||||
// 终端操作
|
// 终端操作
|
||||||
req.NewGet("terminal/:ac", m.WsSSH),
|
req.NewGet("terminal/:ac", m.WsSSH).NoRes(),
|
||||||
req.NewGet("rdp/:ac", m.WsGuacamole),
|
req.NewGet("rdp/:ac", m.WsGuacamole).NoRes(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req.NewConfs("machines", reqs[:]...)
|
return req.NewConfs("machines", reqs[:]...)
|
||||||
@@ -248,9 +247,8 @@ func (m *Machine) WsSSH(rc *req.Ctx) {
|
|||||||
|
|
||||||
// 权限校验
|
// 权限校验
|
||||||
rc = rc.WithRequiredPermission(req.NewPermission("machine:terminal"))
|
rc = rc.WithRequiredPermission(req.NewPermission("machine:terminal"))
|
||||||
if err = req.PermissionHandler(rc); err != nil {
|
err = req.PermissionHandler(rc)
|
||||||
panic(errorx.NewBiz(mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~")))
|
biz.ErrIsNil(err, mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~"))
|
||||||
}
|
|
||||||
|
|
||||||
cli, err := m.machineApp.NewCli(GetMachineAc(rc))
|
cli, err := m.machineApp.NewCli(GetMachineAc(rc))
|
||||||
biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("connection error: %s"))
|
biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("connection error: %s"))
|
||||||
@@ -265,7 +263,6 @@ func (m *Machine) WsSSH(rc *req.Ctx) {
|
|||||||
// 记录系统操作日志
|
// 记录系统操作日志
|
||||||
rc.WithLog(req.NewLogSaveI(imsg.LogMachineTerminalOp))
|
rc.WithLog(req.NewLogSaveI(imsg.LogMachineTerminalOp))
|
||||||
rc.ReqParam = cli.Info
|
rc.ReqParam = cli.Info
|
||||||
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, mcm.GetErrorContentRn("connect fail: %s"))
|
biz.ErrIsNilAppendErr(err, mcm.GetErrorContentRn("connect fail: %s"))
|
||||||
@@ -305,9 +302,8 @@ func (m *Machine) WsGuacamole(rc *req.Ctx) {
|
|||||||
biz.ErrIsNil(err)
|
biz.ErrIsNil(err)
|
||||||
|
|
||||||
rc = rc.WithRequiredPermission(req.NewPermission("machine:terminal"))
|
rc = rc.WithRequiredPermission(req.NewPermission("machine:terminal"))
|
||||||
if err = req.PermissionHandler(rc); err != nil {
|
err = req.PermissionHandler(rc)
|
||||||
panic(errorx.NewBiz(mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~")))
|
biz.ErrIsNil(err, mcm.GetErrorContentRn("You do not have permission to operate the machine terminal, please log in again and try again ~"))
|
||||||
}
|
|
||||||
|
|
||||||
ac := GetMachineAc(rc)
|
ac := GetMachineAc(rc)
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type System struct {
|
|||||||
|
|
||||||
func (s *System) ReqConfs() *req.Confs {
|
func (s *System) ReqConfs() *req.Confs {
|
||||||
reqs := [...]*req.Conf{
|
reqs := [...]*req.Conf{
|
||||||
req.NewGet("", s.ConnectWs),
|
req.NewGet("", s.ConnectWs).NoRes(),
|
||||||
}
|
}
|
||||||
return req.NewConfs("sysmsg", reqs[:]...)
|
return req.NewConfs("sysmsg", reqs[:]...)
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,6 @@ func (s *System) ConnectWs(rc *req.Ctx) {
|
|||||||
biz.NotEmpty(clientId, "clientId cannot be empty")
|
biz.NotEmpty(clientId, "clientId cannot be empty")
|
||||||
|
|
||||||
// 权限校验
|
// 权限校验
|
||||||
// rc := req.NewCtxWithGin(g)
|
|
||||||
err = req.PermissionHandler(rc)
|
err = req.PermissionHandler(rc)
|
||||||
biz.ErrIsNil(err, "sys-websocket connect without permission")
|
biz.ErrIsNil(err, "sys-websocket connect without permission")
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func Init() []*gormigrate.Migration {
|
|||||||
|
|
||||||
new(machineentity.Machine),
|
new(machineentity.Machine),
|
||||||
new(machineentity.MachineFile),
|
new(machineentity.MachineFile),
|
||||||
new(machineentity.MachineMonitor),
|
new(machineentity.MachineTermOp),
|
||||||
new(machineentity.MachineScript),
|
new(machineentity.MachineScript),
|
||||||
new(machineentity.MachineCronJob),
|
new(machineentity.MachineCronJob),
|
||||||
new(machineentity.MachineCronJobExec),
|
new(machineentity.MachineCronJobExec),
|
||||||
|
|||||||
@@ -204,26 +204,38 @@ func GetIdByGenType(genType IdGenType) uint64 {
|
|||||||
type Map[K comparable, V any] map[K]V
|
type Map[K comparable, V any] map[K]V
|
||||||
|
|
||||||
func (m *Map[K, V]) Scan(value any) error {
|
func (m *Map[K, V]) Scan(value any) error {
|
||||||
return json.Unmarshal(value.([]byte), m)
|
if v, ok := value.([]byte); ok && len(v) > 0 {
|
||||||
|
return json.Unmarshal(v, m)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Map[K, V]) Value() (driver.Value, error) {
|
func (m Map[K, V]) Value() (driver.Value, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return json.Marshal(m)
|
return json.Marshal(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Slice[T int | string | Map[string, any]] []T
|
type Slice[T int | string | Map[string, any]] []T
|
||||||
|
|
||||||
func (s *Slice[T]) Scan(value any) error {
|
func (s *Slice[T]) Scan(value any) error {
|
||||||
return json.Unmarshal(value.([]byte), s)
|
if v, ok := value.([]byte); ok && len(v) > 0 {
|
||||||
|
return json.Unmarshal(v, s)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Slice[T]) Value() (driver.Value, error) {
|
func (s Slice[T]) Value() (driver.Value, error) {
|
||||||
|
if s == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return json.Marshal(s)
|
return json.Marshal(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 带有额外其他信息字段的结构体
|
// 带有额外其他信息字段的结构体
|
||||||
type ExtraData struct {
|
type ExtraData struct {
|
||||||
Extra Map[string, any] `json:"extra" gorm:"type:varchar(1000)"`
|
Extra Map[string, any] `json:"extra" gorm:"type:varchar(2000)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetExtraValue 设置额外信息字段值
|
// SetExtraValue 设置额外信息字段值
|
||||||
|
|||||||
Reference in New Issue
Block a user