mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8f3671ffb | ||
|
|
ac62767a18 | ||
|
|
2db4c20dd3 | ||
|
|
cfb7fd5b29 | ||
|
|
22c401f9d8 | ||
|
|
be00b90c1d | ||
|
|
fb3f89c594 | ||
|
|
e7a66378ea |
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
### 介绍
|
||||
基于DDD分层实现的web版 **linux(终端 文件 脚本 进程)、数据库(mysql postgres)、redis(单机 哨兵 集群)、mongo统一管理操作平台**
|
||||
web版 **linux(终端[终端回放] 文件 脚本 进程)、数据库(mysql postgres)、redis(单机 哨兵 集群)、mongo统一管理操作平台**
|
||||
|
||||
|
||||
### 开发语言与主要框架
|
||||
|
||||
@@ -95,6 +95,10 @@ function buildWindows() {
|
||||
build "$1/mayfly-go-windows" "windows" "amd64" $2
|
||||
}
|
||||
|
||||
function buildMac() {
|
||||
build "$1/mayfly-go-mac" "darwin" "amd64" $2
|
||||
}
|
||||
|
||||
function runBuild() {
|
||||
# 构建结果的目的路径
|
||||
read -p "请输入构建产物输出目录: " toPath
|
||||
@@ -107,7 +111,7 @@ function runBuild() {
|
||||
toPath=`pwd`
|
||||
|
||||
read -p "是否构建前端[0|其他->否 1->是 2->构建并拷贝至server/static/static]: " runBuildWeb
|
||||
read -p "请选择构建版本[0|其他->全部 1->linux-amd64 2->linux-arm64 3->windows]: " buildType
|
||||
read -p "请选择构建版本[0|其他->全部 1->linux-amd64 2->linux-arm64 3->windows 4->mac]: " buildType
|
||||
|
||||
|
||||
if [ "${runBuildWeb}" == "1" ] || [ "${runBuildWeb}" == "2" ] ; then
|
||||
@@ -124,10 +128,14 @@ function runBuild() {
|
||||
"3")
|
||||
buildWindows ${toPath} ${runBuildWeb}
|
||||
;;
|
||||
"4")
|
||||
buildMac ${toPath} ${runBuildWeb}
|
||||
;;
|
||||
*)
|
||||
buildLinuxAmd64 ${toPath} ${runBuildWeb}
|
||||
buildLinuxArm64 ${toPath} ${runBuildWeb}
|
||||
buildWindows ${toPath} ${runBuildWeb}
|
||||
buildMac ${toPath} ${runBuildWeb}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
5123
mayfly_go_web/package-lock.json
generated
5123
mayfly_go_web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -8,12 +8,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.0.9",
|
||||
"asciinema-player": "^3.0.1",
|
||||
"axios": "^0.27.2",
|
||||
"codemirror": "^5.65.5",
|
||||
"countup.js": "^2.0.7",
|
||||
"cropperjs": "^1.5.11",
|
||||
"echarts": "^5.3.3",
|
||||
"element-plus": "^2.2.15",
|
||||
"element-plus": "^2.2.17",
|
||||
"jsencrypt": "^3.2.1",
|
||||
"jsoneditor": "^9.9.0",
|
||||
"lodash": "^4.17.21",
|
||||
@@ -22,12 +23,12 @@
|
||||
"screenfull": "^6.0.2",
|
||||
"sortablejs": "^1.13.0",
|
||||
"sql-formatter": "^9.2.0",
|
||||
"vue": "^3.2.37",
|
||||
"vue": "^3.2.39",
|
||||
"vue-clipboard3": "^1.0.1",
|
||||
"vue-router": "^4.1.2",
|
||||
"vue-router": "^4.1.5",
|
||||
"vuex": "^4.0.2",
|
||||
"xterm": "^4.19.0",
|
||||
"xterm-addon-fit": "^0.5.0"
|
||||
"xterm": "^5.0.0",
|
||||
"xterm-addon-fit": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.178",
|
||||
@@ -38,7 +39,6 @@
|
||||
"@typescript-eslint/parser": "^4.23.0",
|
||||
"@vitejs/plugin-vue": "^2.3.3",
|
||||
"@vue/compiler-sfc": "^3.0.11",
|
||||
"asciinema-player": "^3.0.1",
|
||||
"dotenv": "^10.0.0",
|
||||
"eslint": "^8.5.0",
|
||||
"eslint-plugin-vue": "^8.2.0",
|
||||
|
||||
@@ -14,7 +14,7 @@ body,
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: Microsoft YaHei, Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, SimSun, sans-serif;
|
||||
font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
|
||||
font-weight: 450;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/* Popover 弹出框(图标选择器)
|
||||
------------------------------- */
|
||||
.icon-selector-popper {
|
||||
padding: 0 !important;
|
||||
.icon-selector-warp {
|
||||
.icon-selector-warp-title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding: 0 15px;
|
||||
}
|
||||
.icon-selector-warp-row {
|
||||
max-height: 260px;
|
||||
overflow-y: auto;
|
||||
padding: 15px 15px 5px;
|
||||
border-top: 1px solid #ebeef5;
|
||||
.ele-col:nth-last-child(1),
|
||||
.ele-col:nth-last-child(2) {
|
||||
display: none;
|
||||
}
|
||||
.awe-col:nth-child(-n + 24) {
|
||||
display: none;
|
||||
}
|
||||
.icon-selector-warp-item {
|
||||
display: flex;
|
||||
border: 1px solid #ebeef5;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
transition: all 0.3s ease;
|
||||
.icon-selector-warp-item-value {
|
||||
transition: all 0.3s ease;
|
||||
i {
|
||||
font-size: 20px;
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
border: 1px solid var(--color-primary);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
.icon-selector-warp-item-value {
|
||||
i {
|
||||
color: var(--color-primary);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.icon-selector-active {
|
||||
border: 1px solid var(--color-primary);
|
||||
.icon-selector-warp-item-value {
|
||||
i {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.icon-selector-all {
|
||||
.el-input {
|
||||
padding: 0 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
&-tabs {
|
||||
display: flex;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 15px;
|
||||
margin-bottom: 5px;
|
||||
&-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
&-active {
|
||||
background: var(--color-primary);
|
||||
border-radius: 5px;
|
||||
.label {
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,5 @@
|
||||
@import './base.scss';
|
||||
@import './other.scss';
|
||||
@import './element.scss';
|
||||
@import './iconSelector.scss';
|
||||
@import './media/media.scss';
|
||||
@import './waves.scss';
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMounted, ref, toRefs, reactive, defineComponent, computed } from 'vue';
|
||||
import { nextTick, onMounted, ref, toRefs, reactive, defineComponent, computed } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { initBackEndControlRoutesFun } from '@/router/index.ts';
|
||||
@@ -95,7 +95,7 @@ export default defineComponent({
|
||||
const changePwdFormRef: any = ref(null);
|
||||
|
||||
const state = reactive({
|
||||
useLoginCaptcha: true,
|
||||
useLoginCaptcha: false,
|
||||
captchaImage: '',
|
||||
loginForm: {
|
||||
username: '',
|
||||
@@ -133,11 +133,13 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
// 移除公钥, 方便后续重新获取
|
||||
sessionStorage.removeItem('RsaPublicKey');
|
||||
nextTick(async () => {
|
||||
state.useLoginCaptcha = await useLoginCaptcha();
|
||||
getCaptcha();
|
||||
});
|
||||
// 移除公钥, 方便后续重新获取
|
||||
sessionStorage.removeItem('RsaPublicKey');
|
||||
});
|
||||
|
||||
const getCaptcha = async () => {
|
||||
if (!state.useLoginCaptcha) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
>删除</el-button
|
||||
>
|
||||
<div style="float: right">
|
||||
<el-select v-model="query.projectId" placeholder="请选择项目" filterable clearable>
|
||||
<el-select @focus="getProjects" v-model="query.projectId" placeholder="请选择项目" filterable clearable>
|
||||
<el-option v-for="item in projects" :key="item.id" :label="`${item.name} [${item.remark}]`" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
<el-button v-waves type="primary" icon="search" @click="search()" class="ml5">查询</el-button>
|
||||
@@ -29,8 +29,12 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="类型" min-width="90"></el-table-column>
|
||||
<el-table-column prop="database" label="数据库" min-width="160">
|
||||
<el-table-column prop="database" label="数据库" min-width="80">
|
||||
<template #default="scope">
|
||||
<el-popover :width="250" placement="right" trigger="click">
|
||||
<template #reference>
|
||||
<el-link type="primary" :underline="false" plain>查看</el-link>
|
||||
</template>
|
||||
<el-tag
|
||||
@click="showTableInfo(scope.row, db)"
|
||||
effect="plain"
|
||||
@@ -38,9 +42,10 @@
|
||||
size="small"
|
||||
v-for="db in scope.row.dbs"
|
||||
:key="db"
|
||||
style="cursor: pointer; margin-left: 3px"
|
||||
style="cursor: pointer; margin-left: 3px; margin-bottom: 3px;"
|
||||
>{{ db }}</el-tag
|
||||
>
|
||||
</el-popover>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="username" label="用户名" min-width="100"></el-table-column>
|
||||
@@ -161,8 +166,10 @@
|
||||
v-model="sqlExecLogDialog.visible"
|
||||
>
|
||||
<div class="toolbar">
|
||||
<el-input v-model="sqlExecLogDialog.query.db" placeholder="请输入数据库名" clearable style="width: 150px" />
|
||||
<el-input v-model="sqlExecLogDialog.query.table" placeholder="请输入表名" clearable class="ml5" style="width: 150px" />
|
||||
<el-select v-model="sqlExecLogDialog.query.db" placeholder="请选择数据库" filterable clearable>
|
||||
<el-option v-for="item in sqlExecLogDialog.dbs" :key="item" :label="`${item}`" :value="item"> </el-option>
|
||||
</el-select>
|
||||
<el-input v-model="sqlExecLogDialog.query.table" placeholder="请输入表名" clearable class="ml5" style="width: 180px" />
|
||||
<el-select v-model="sqlExecLogDialog.query.type" placeholder="请选择操作类型" clearable class="ml5">
|
||||
<el-option v-for="item in enums.DbSqlExecTypeEnum" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
||||
</el-select>
|
||||
@@ -307,6 +314,7 @@ export default defineComponent({
|
||||
visible: false,
|
||||
data: [],
|
||||
total: 0,
|
||||
dbs: [],
|
||||
query: {
|
||||
dbId: 0,
|
||||
db: '',
|
||||
@@ -398,8 +406,12 @@ export default defineComponent({
|
||||
search();
|
||||
};
|
||||
|
||||
const editDb = async (isAdd = false) => {
|
||||
const getProjects = async () => {
|
||||
state.projects = await projectApi.accountProjects.request(null);
|
||||
};
|
||||
|
||||
const editDb = async (isAdd = false) => {
|
||||
await getProjects();
|
||||
if (isAdd) {
|
||||
state.dbEditDialog.data = null;
|
||||
state.dbEditDialog.title = '新增数据库资源';
|
||||
@@ -434,6 +446,7 @@ export default defineComponent({
|
||||
const onShowSqlExec = async (row: any) => {
|
||||
state.sqlExecLogDialog.title = `${row.name}[${row.host}:${row.port}]`;
|
||||
state.sqlExecLogDialog.query.dbId = row.id;
|
||||
state.sqlExecLogDialog.dbs = row.database.split(' ');
|
||||
searchSqlExecLog();
|
||||
state.sqlExecLogDialog.visible = true;
|
||||
};
|
||||
@@ -441,6 +454,7 @@ export default defineComponent({
|
||||
const onBeforeCloseSqlExecDialog = () => {
|
||||
state.sqlExecLogDialog.visible = false;
|
||||
state.sqlExecLogDialog.data = [];
|
||||
state.sqlExecLogDialog.dbs = [];
|
||||
state.sqlExecLogDialog.total = 0;
|
||||
state.sqlExecLogDialog.query.dbId = 0;
|
||||
state.sqlExecLogDialog.query.pageNum = 1;
|
||||
@@ -602,6 +616,7 @@ export default defineComponent({
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
getProjects,
|
||||
filterTableInfos,
|
||||
enums,
|
||||
search,
|
||||
|
||||
@@ -114,8 +114,20 @@
|
||||
</div>
|
||||
|
||||
<div class="mt5">
|
||||
<el-row v-if="queryTab.nowTableName">
|
||||
<el-link @click="onDeleteData" class="ml5" type="danger" icon="delete" :underline="false"></el-link>
|
||||
<el-row>
|
||||
<el-link
|
||||
v-if="queryTab.nowTableName"
|
||||
@click="onDeleteData"
|
||||
class="ml5"
|
||||
type="danger"
|
||||
icon="delete"
|
||||
:underline="false"
|
||||
></el-link>
|
||||
|
||||
<span v-if="queryTab.execRes.data.length > 0">
|
||||
<el-divider direction="vertical" border-style="dashed" />
|
||||
<el-link type="success" :underline="false" @click="exportData"><span style="font-size: 12px">导出</span></el-link>
|
||||
</span>
|
||||
</el-row>
|
||||
<el-table
|
||||
@cell-dblclick="cellClick"
|
||||
@@ -183,11 +195,7 @@
|
||||
<template #prepend>
|
||||
<el-popover trigger="click" :width="320" placement="right">
|
||||
<template #reference>
|
||||
<el-link
|
||||
type="success"
|
||||
:underline="false"
|
||||
>选择列</el-link
|
||||
>
|
||||
<el-link type="success" :underline="false">选择列</el-link>
|
||||
</template>
|
||||
<el-table
|
||||
:data="getColumns4Map(dt.name)"
|
||||
@@ -312,6 +320,7 @@ import ProjectEnvSelect from '../component/ProjectEnvSelect.vue';
|
||||
import config from '@/common/config';
|
||||
import { getSession } from '@/common/utils/storage';
|
||||
import SqlExecBox from './component/SqlExecBox';
|
||||
import { dateStrFormat } from '@/common/utils/date.ts';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SqlExec',
|
||||
@@ -513,6 +522,36 @@ export default defineComponent({
|
||||
}
|
||||
};
|
||||
|
||||
const exportData = () => {
|
||||
const dataList = state.queryTab.execRes.data;
|
||||
isTrue(dataList.length > 0, '没有数据可导出');
|
||||
|
||||
const tableColumn = state.queryTab.execRes.tableColumn;
|
||||
// 二维数组
|
||||
const cvsData = [tableColumn];
|
||||
for (let data of dataList) {
|
||||
// 数据值组成的一维数组
|
||||
let dataValueArr: any = [];
|
||||
for (let column of tableColumn) {
|
||||
dataValueArr.push(data[column]);
|
||||
}
|
||||
cvsData.push(dataValueArr);
|
||||
}
|
||||
const csvString = cvsData.map((e) => e.join(',')).join('\n');
|
||||
|
||||
// 导出
|
||||
let link = document.createElement('a');
|
||||
let exportContent = '\uFEFF';
|
||||
let blob = new Blob([exportContent + csvString], {
|
||||
type: 'text/plain;charset=utrf-8',
|
||||
});
|
||||
link.id = 'download-csv';
|
||||
link.setAttribute('href', URL.createObjectURL(blob));
|
||||
link.setAttribute('download', `查询数据导出-${dateStrFormat('yyyyMMddHHmmss', new Date())}.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行sql str
|
||||
*
|
||||
@@ -1187,6 +1226,7 @@ export default defineComponent({
|
||||
changeTable,
|
||||
cellClick,
|
||||
onRunSql,
|
||||
exportData,
|
||||
removeDataTab,
|
||||
onDataTabClick,
|
||||
beforeUpload,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
</el-row>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :title="tree.title" v-model="tree.visible" :close-on-click-modal="false" width="50%">
|
||||
<el-dialog :title="tree.title" v-model="tree.visible" :close-on-click-modal="false" width="70%">
|
||||
<el-progress
|
||||
v-if="uploadProgressShow"
|
||||
style="width: 90%; margin-left: 20px"
|
||||
@@ -66,7 +66,16 @@
|
||||
:percentage="progressNum"
|
||||
/>
|
||||
<div style="height: 45vh; overflow: auto">
|
||||
<el-tree v-if="tree.visible" ref="fileTree" :highlight-current="true" :load="loadNode" :props="props" lazy node-key="id" :expand-on-click-node="true">
|
||||
<el-tree
|
||||
v-if="tree.visible"
|
||||
ref="fileTree"
|
||||
:highlight-current="true"
|
||||
:load="loadNode"
|
||||
:props="props"
|
||||
lazy
|
||||
node-key="id"
|
||||
:expand-on-click-node="true"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<el-dropdown size="small" @visible-change="getFilePath(data, $event)" trigger="contextmenu">
|
||||
@@ -81,9 +90,8 @@
|
||||
<SvgIcon name="document" />
|
||||
</span>
|
||||
|
||||
<span style="display: inline-block">
|
||||
<span>
|
||||
{{ node.label }}
|
||||
<span style="color: #67c23a" v-if="data.type == '-'"> [{{ formatFileSize(data.size) }}]</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -133,6 +141,10 @@
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<span style="display: inline-block" class="ml15">
|
||||
<span style="color: #67c23a" v-if="data.type == '-'">[{{ formatFileSize(data.size) }}]</span>
|
||||
<span v-if="data.mode" style="color: #67c23a"> [{{ data.mode }} {{ data.modTime }}]</span>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
@@ -161,7 +173,7 @@
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<div>
|
||||
<el-button @click="closeCreateFileDialog">关闭</el-button>
|
||||
<el-button v-auth="'machine:file:write'" type="primary" @click="createFile">确定</el-button>
|
||||
</div>
|
||||
@@ -277,9 +289,9 @@ export default defineComponent({
|
||||
file: null as any,
|
||||
});
|
||||
|
||||
watch(props, (newValue) => {
|
||||
if (newValue.machineId) {
|
||||
getFiles();
|
||||
watch(props, async (newValue) => {
|
||||
if (newValue.machineId && newValue.visible) {
|
||||
await getFiles();
|
||||
}
|
||||
state.dialogVisible = newValue.visible;
|
||||
});
|
||||
|
||||
@@ -198,6 +198,7 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
const getSshTunnelMachine = (machineId: any) => {
|
||||
notBlank(machineId, '请选择或先创建一台隧道机器');
|
||||
return state.sshTunnelMachineList.find((x: any) => x.id == machineId);
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
>删除</el-button
|
||||
>
|
||||
<div style="float: right">
|
||||
<el-select v-model="params.projectId" placeholder="请选择项目" @clear="search" filterable clearable>
|
||||
<el-select @focus="getProjects" v-model="params.projectId" placeholder="请选择项目" @clear="search" filterable clearable>
|
||||
<el-option v-for="item in projects" :key="item.id" :label="`${item.name} [${item.remark}]`" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
<el-input
|
||||
@@ -166,8 +166,6 @@
|
||||
:machineId="machineStatsDialog.machineId"
|
||||
:title="machineStatsDialog.title"
|
||||
></machine-stats>
|
||||
|
||||
<!-- <machine-rec v-model:visible="machineRecDialog.visible" :title="machineRecDialog.title" :machine-id="machineRecDialog.machineId" /> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -182,7 +180,6 @@ import FileManage from './FileManage.vue';
|
||||
import MachineEdit from './MachineEdit.vue';
|
||||
import ProcessList from './ProcessList.vue';
|
||||
import MachineStats from './MachineStats.vue';
|
||||
// import MachineRec from './MachineRec.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'MachineList',
|
||||
@@ -192,7 +189,6 @@ export default defineComponent({
|
||||
FileManage,
|
||||
MachineEdit,
|
||||
MachineStats,
|
||||
// MachineRec,
|
||||
},
|
||||
setup() {
|
||||
const router = useRouter();
|
||||
@@ -279,8 +275,12 @@ export default defineComponent({
|
||||
search();
|
||||
};
|
||||
|
||||
const openFormDialog = async (machine: any) => {
|
||||
const getProjects = async () => {
|
||||
state.projects = await projectApi.accountProjects.request(null);
|
||||
};
|
||||
|
||||
const openFormDialog = async (machine: any) => {
|
||||
await getProjects();
|
||||
let dialogTitle;
|
||||
if (machine) {
|
||||
state.machineEditDialog.data = state.currentData as any;
|
||||
@@ -372,6 +372,7 @@ export default defineComponent({
|
||||
return {
|
||||
...toRefs(state),
|
||||
choose,
|
||||
getProjects,
|
||||
showTerminal,
|
||||
openFormDialog,
|
||||
deleteMachine,
|
||||
|
||||
@@ -187,9 +187,9 @@ export default defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
watch(props, (newValue) => {
|
||||
if (props.machineId) {
|
||||
getScripts();
|
||||
watch(props, async (newValue) => {
|
||||
if (props.machineId && newValue.visible) {
|
||||
await getScripts();
|
||||
}
|
||||
state.dialogVisible = newValue.visible;
|
||||
});
|
||||
|
||||
@@ -70,6 +70,7 @@ export default defineComponent({
|
||||
foreground: getThemeConfig.value.terminalForeground || '#7e9192', //字体
|
||||
background: getThemeConfig.value.terminalBackground || '#002833', //背景色
|
||||
cursor: getThemeConfig.value.terminalCursor || '#268F81', //设置光标
|
||||
// cursorAccent: "red", // 光标停止颜色
|
||||
} as any,
|
||||
});
|
||||
const fitAddon = new FitAddon();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<el-button type="primary" icon="edit" :disabled="currentId == null" @click="editMongo(false)" plain>编辑</el-button>
|
||||
<el-button type="danger" icon="delete" :disabled="currentId == null" @click="deleteMongo" plain>删除</el-button>
|
||||
<div style="float: right">
|
||||
<el-select v-model="query.projectId" placeholder="请选择项目" filterable clearable>
|
||||
<el-select @focus="getProjects" v-model="query.projectId" placeholder="请选择项目" filterable clearable>
|
||||
<el-option v-for="item in projects" :key="item.id" :label="`${item.name} [${item.remark}]`" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
<el-button class="ml5" @click="search" type="success" icon="search"></el-button>
|
||||
@@ -370,8 +370,12 @@ export default defineComponent({
|
||||
state.total = res.total;
|
||||
};
|
||||
|
||||
const editMongo = async (isAdd = false) => {
|
||||
const getProjects = async () => {
|
||||
state.projects = await projectApi.accountProjects.request(null);
|
||||
};
|
||||
|
||||
const editMongo = async (isAdd = false) => {
|
||||
await getProjects();
|
||||
if (isAdd) {
|
||||
state.mongoEditDialog.data = null;
|
||||
state.mongoEditDialog.title = '新增mongo';
|
||||
@@ -390,6 +394,7 @@ export default defineComponent({
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
getProjects,
|
||||
search,
|
||||
handlePageChange,
|
||||
choose,
|
||||
|
||||
@@ -80,9 +80,18 @@
|
||||
<el-dialog width="500px" :title="showEnvDialog.title" v-model="showEnvDialog.visible">
|
||||
<div class="toolbar">
|
||||
<el-button @click="showAddEnvDialog" v-auth="permissions.saveMember" type="primary" icon="plus">添加</el-button>
|
||||
<!-- <el-button v-auth="'role:update'" :disabled="chooseId == null" type="danger" icon="delete">删除</el-button> -->
|
||||
<el-button @click="deleteEnv" v-auth="permissions.delProject" :disabled="showEnvDialog.chooseId == null" type="danger" icon="delete"
|
||||
>删除</el-button
|
||||
>
|
||||
</div>
|
||||
<el-table border :data="showEnvDialog.envs">
|
||||
<el-table @current-change="chooseEnv" border :data="showEnvDialog.envs">
|
||||
<el-table-column label="选择" width="50px">
|
||||
<template #default="scope">
|
||||
<el-radio v-model="showEnvDialog.chooseId" :label="scope.row.id">
|
||||
<i></i>
|
||||
</el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="name" label="环境名" width="125"></el-table-column>
|
||||
<el-table-column property="remark" label="描述" width="125"></el-table-column>
|
||||
<el-table-column property="createTime" label="创建时间">
|
||||
@@ -207,6 +216,8 @@ export default defineComponent({
|
||||
},
|
||||
showEnvDialog: {
|
||||
visible: false,
|
||||
chooseId: null,
|
||||
chooseData: null,
|
||||
envs: [],
|
||||
title: '',
|
||||
addVisible: false,
|
||||
@@ -340,6 +351,21 @@ export default defineComponent({
|
||||
state.showEnvDialog.visible = true;
|
||||
};
|
||||
|
||||
const chooseEnv = (item: any) => {
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
state.showEnvDialog.chooseData = item;
|
||||
state.showEnvDialog.chooseId = item.id;
|
||||
};
|
||||
|
||||
const deleteEnv = async () => {
|
||||
notNull(state.showEnvDialog.chooseData, '请选选择环境');
|
||||
await projectApi.delProjectEnvs.request({ id: state.showEnvDialog.chooseId });
|
||||
ElMessage.success('删除成功');
|
||||
state.showEnvDialog.envs = await projectApi.projectEnvs.request({ projectId: state.chooseId });
|
||||
};
|
||||
|
||||
const showAddMemberDialog = () => {
|
||||
state.showMemDialog.addVisible = true;
|
||||
};
|
||||
@@ -398,12 +424,14 @@ export default defineComponent({
|
||||
showMembers,
|
||||
setMemebers,
|
||||
showEnv,
|
||||
deleteEnv,
|
||||
showAddMemberDialog,
|
||||
addMember,
|
||||
chooseMember,
|
||||
deleteMember,
|
||||
cancelAddMember,
|
||||
showAddEnvDialog,
|
||||
chooseEnv,
|
||||
addEnv,
|
||||
cancelAddEnv,
|
||||
getAccount,
|
||||
|
||||
@@ -8,6 +8,7 @@ export const projectApi = {
|
||||
delProject: Api.create("/projects", 'delete'),
|
||||
// 获取项目下的环境信息
|
||||
projectEnvs: Api.create("/projects/{projectId}/envs", 'get'),
|
||||
delProjectEnvs: Api.create("/projects/envs", 'delete'),
|
||||
saveProjectEnv: Api.create("/projects/{projectId}/envs", 'post'),
|
||||
// 获取项目下的成员信息
|
||||
projectMems: Api.create("/projects/{projectId}/members", 'get'),
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<template #default>
|
||||
<el-form-item label="redis" label-width="40px">
|
||||
<el-select v-model="scanParam.id" placeholder="请选择redis" @change="changeRedis" @clear="clearRedis" clearable>
|
||||
<el-option v-for="item in redisList" :key="item.id" :label="item.host" :value="item.id">
|
||||
<span style="float: left">{{ item.host }}</span>
|
||||
<span style="float: right; color: #8492a6; margin-left: 6px; font-size: 13px">{{
|
||||
`库: [${item.db}]`
|
||||
}}</span>
|
||||
</el-option>
|
||||
<el-option v-for="item in redisList" :key="item.id" :label="item.host" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="库" label-width="20px">
|
||||
<el-select v-model="scanParam.db" @change="changeDb" placeholder="库" style="width: 70px">
|
||||
<el-option v-for="db in dbList" :key="db" :label="db" :value="db"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
@@ -43,6 +43,7 @@
|
||||
<el-tag @click="onAddData('string')" :color="getTypeColor('string')" style="cursor: pointer">string</el-tag>
|
||||
<el-tag @click="onAddData('hash')" :color="getTypeColor('hash')" class="ml5" style="cursor: pointer">hash</el-tag>
|
||||
<el-tag @click="onAddData('set')" :color="getTypeColor('set')" class="ml5" style="cursor: pointer">set</el-tag>
|
||||
<!-- <el-tag @click="onAddData('list')" :color="getTypeColor('list')" class="ml5" style="cursor: pointer">list</el-tag> -->
|
||||
</el-popover>
|
||||
</el-form-item>
|
||||
<div style="float: right">
|
||||
@@ -60,7 +61,7 @@
|
||||
<el-tag :color="getTypeColor(scope.row.type)" size="small">{{ scope.row.type }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="ttl" label="ttl(过期时间)" width="130">
|
||||
<el-table-column prop="ttl" label="ttl(过期时间)" width="140">
|
||||
<template #default="scope">
|
||||
{{ ttlConveter(scope.row.ttl) }}
|
||||
</template>
|
||||
@@ -82,6 +83,7 @@
|
||||
:title="dataEdit.title"
|
||||
:keyInfo="dataEdit.keyInfo"
|
||||
:redisId="scanParam.id"
|
||||
:db="scanParam.db"
|
||||
@cancel="onCancelDataEdit"
|
||||
@valChange="searchKey"
|
||||
/>
|
||||
@@ -92,6 +94,7 @@
|
||||
:title="dataEdit.title"
|
||||
:keyInfo="dataEdit.keyInfo"
|
||||
:redisId="scanParam.id"
|
||||
:db="scanParam.db"
|
||||
@cancel="onCancelDataEdit"
|
||||
@valChange="searchKey"
|
||||
/>
|
||||
@@ -101,6 +104,18 @@
|
||||
:title="dataEdit.title"
|
||||
:keyInfo="dataEdit.keyInfo"
|
||||
:redisId="scanParam.id"
|
||||
:db="scanParam.db"
|
||||
:operationType="dataEdit.operationType"
|
||||
@valChange="searchKey"
|
||||
@cancel="onCancelDataEdit"
|
||||
/>
|
||||
|
||||
<list-value
|
||||
v-model:visible="listValueDialog.visible"
|
||||
:title="dataEdit.title"
|
||||
:keyInfo="dataEdit.keyInfo"
|
||||
:redisId="scanParam.id"
|
||||
:db="scanParam.db"
|
||||
:operationType="dataEdit.operationType"
|
||||
@valChange="searchKey"
|
||||
@cancel="onCancelDataEdit"
|
||||
@@ -116,6 +131,7 @@ import ProjectEnvSelect from '../component/ProjectEnvSelect.vue';
|
||||
import HashValue from './HashValue.vue';
|
||||
import StringValue from './StringValue.vue';
|
||||
import SetValue from './SetValue.vue';
|
||||
import ListValue from './ListValue.vue';
|
||||
import { isTrue, notBlank, notNull } from '@/common/assert';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -124,17 +140,20 @@ export default defineComponent({
|
||||
StringValue,
|
||||
HashValue,
|
||||
SetValue,
|
||||
ListValue,
|
||||
ProjectEnvSelect,
|
||||
},
|
||||
setup() {
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
redisList: [],
|
||||
dbList: [],
|
||||
query: {
|
||||
envId: 0,
|
||||
},
|
||||
scanParam: {
|
||||
id: null,
|
||||
db: null,
|
||||
match: null,
|
||||
count: 10,
|
||||
cursor: {},
|
||||
@@ -158,6 +177,9 @@ export default defineComponent({
|
||||
setValueDialog: {
|
||||
visible: false,
|
||||
},
|
||||
listValueDialog: {
|
||||
visible: false,
|
||||
},
|
||||
keys: [],
|
||||
dbsize: 0,
|
||||
});
|
||||
@@ -178,6 +200,14 @@ export default defineComponent({
|
||||
|
||||
const changeRedis = (id: number) => {
|
||||
resetScanParam(id);
|
||||
state.scanParam.db = null;
|
||||
state.dbList = (state.redisList.find((x: any) => x.id == id) as any).db.split(',');
|
||||
state.keys = [];
|
||||
state.dbsize = 0;
|
||||
};
|
||||
|
||||
const changeDb = () => {
|
||||
resetScanParam(state.scanParam.id as any);
|
||||
state.keys = [];
|
||||
state.dbsize = 0;
|
||||
searchKey();
|
||||
@@ -188,8 +218,8 @@ export default defineComponent({
|
||||
notBlank(state.scanParam.count, 'count不能为空');
|
||||
|
||||
const match = state.scanParam.match;
|
||||
if (!match || match == '*') {
|
||||
isTrue(state.scanParam.count <= 200, 'match为空或者*时, count不能超过200');
|
||||
if (!match || (match as string).length < 4) {
|
||||
isTrue(state.scanParam.count <= 200, 'key为空或小于4字符时, count不能超过200');
|
||||
} else {
|
||||
isTrue(state.scanParam.count <= 20000, 'count不能超过20000');
|
||||
}
|
||||
@@ -214,6 +244,7 @@ export default defineComponent({
|
||||
state.redisList = [];
|
||||
state.scanParam.id = null;
|
||||
resetScanParam();
|
||||
state.scanParam.db = null;
|
||||
state.keys = [];
|
||||
state.dbsize = 0;
|
||||
};
|
||||
@@ -231,7 +262,7 @@ export default defineComponent({
|
||||
const redis: any = state.redisList.find((x: any) => x.id == id);
|
||||
// 集群模式count设小点,因为后端会从所有master节点scan一遍然后合并结果
|
||||
if (redis && redis.mode == 'cluster') {
|
||||
state.scanParam.count = 5;
|
||||
state.scanParam.count = 4;
|
||||
}
|
||||
}
|
||||
state.scanParam.match = null;
|
||||
@@ -253,6 +284,8 @@ export default defineComponent({
|
||||
state.stringValueDialog.visible = true;
|
||||
} else if (type == 'set') {
|
||||
state.setValueDialog.visible = true;
|
||||
} else if (type == 'list') {
|
||||
state.listValueDialog.visible = true;
|
||||
} else {
|
||||
ElMessage.warning('暂不支持该类型');
|
||||
}
|
||||
@@ -270,6 +303,8 @@ export default defineComponent({
|
||||
state.stringValueDialog.visible = true;
|
||||
} else if (type == 'set') {
|
||||
state.setValueDialog.visible = true;
|
||||
} else if (type == 'list') {
|
||||
state.listValueDialog.visible = true;
|
||||
} else {
|
||||
ElMessage.warning('暂不支持该类型');
|
||||
}
|
||||
@@ -290,6 +325,7 @@ export default defineComponent({
|
||||
.request({
|
||||
key,
|
||||
id: state.scanParam.id,
|
||||
db: state.scanParam.db,
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success('删除成功!');
|
||||
@@ -351,6 +387,7 @@ export default defineComponent({
|
||||
...toRefs(state),
|
||||
changeProjectEnv,
|
||||
changeRedis,
|
||||
changeDb,
|
||||
clearRedis,
|
||||
searchKey,
|
||||
scan,
|
||||
|
||||
@@ -81,6 +81,10 @@ export default defineComponent({
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
db: {
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
keyInfo: {
|
||||
type: [Object],
|
||||
},
|
||||
@@ -94,6 +98,7 @@ export default defineComponent({
|
||||
dialogVisible: false,
|
||||
operationType: 1,
|
||||
redisId: 0,
|
||||
db: 0,
|
||||
key: {
|
||||
key: '',
|
||||
type: 'hash',
|
||||
@@ -102,6 +107,7 @@ export default defineComponent({
|
||||
scanParam: {
|
||||
key: '',
|
||||
id: 0,
|
||||
db: 0,
|
||||
cursor: 0,
|
||||
match: '',
|
||||
count: 10,
|
||||
@@ -127,6 +133,7 @@ export default defineComponent({
|
||||
watch(props, async (newValue) => {
|
||||
const visible = newValue.visible;
|
||||
state.redisId = newValue.redisId;
|
||||
state.db = newValue.db;
|
||||
state.key = newValue.keyInfo;
|
||||
state.operationType = newValue.operationType;
|
||||
|
||||
@@ -141,6 +148,7 @@ export default defineComponent({
|
||||
|
||||
const reHscan = async () => {
|
||||
state.scanParam.id = state.redisId;
|
||||
state.scanParam.db = state.db;
|
||||
state.scanParam.cursor = 0;
|
||||
hscan();
|
||||
};
|
||||
@@ -186,6 +194,7 @@ export default defineComponent({
|
||||
});
|
||||
await redisApi.hdel.request({
|
||||
id: state.redisId,
|
||||
db: state.db,
|
||||
key: state.key.key,
|
||||
field,
|
||||
});
|
||||
@@ -196,6 +205,7 @@ export default defineComponent({
|
||||
const hset = async (row: any) => {
|
||||
await redisApi.saveHashValue.request({
|
||||
id: state.redisId,
|
||||
db: state.db,
|
||||
key: state.key.key,
|
||||
timed: state.key.timed,
|
||||
value: [
|
||||
@@ -215,7 +225,7 @@ export default defineComponent({
|
||||
const saveValue = async () => {
|
||||
notEmpty(state.key.key, 'key不能为空');
|
||||
isTrue(state.hashValues.length > 0, 'hash内容不能为空');
|
||||
const sv = { value: state.hashValues, id: state.redisId };
|
||||
const sv = { value: state.hashValues, id: state.redisId, db: state.db };
|
||||
Object.assign(sv, state.key);
|
||||
await redisApi.saveHashValue.request(sv);
|
||||
ElMessage.success('保存成功');
|
||||
|
||||
213
mayfly_go_web/src/views/ops/redis/ListValue.vue
Normal file
213
mayfly_go_web/src/views/ops/redis/ListValue.vue
Normal file
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="dialogVisible" :before-close="cancel" width="800px" :destroy-on-close="true">
|
||||
<el-form label-width="85px">
|
||||
<el-form-item prop="key" label="key:">
|
||||
<el-input :disabled="operationType == 2" v-model="key.key"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="timed" label="过期时间:">
|
||||
<el-input v-model.number="key.timed" type="number"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="dataType" label="数据类型:">
|
||||
<el-input v-model="key.type" disabled></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-button @click="onAddListValue" icon="plus" size="small" plain class="mt10">添加</el-button> -->
|
||||
<div v-if="operationType == 2" class="mt10" style="float: left">
|
||||
<span>len: {{ len }}</span>
|
||||
</div>
|
||||
<el-table :data="value" stripe style="width: 100%">
|
||||
<el-table-column prop="value" label="value" min-width="200">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.value" clearable type="textarea" :autosize="{ minRows: 2, maxRows: 10 }" size="small"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="140">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="operationType == 2"
|
||||
type="success"
|
||||
@click="lset(scope.row, scope.$index)"
|
||||
icon="check"
|
||||
size="small"
|
||||
plain
|
||||
></el-button>
|
||||
<!-- <el-button type="danger" @click="set.value.splice(scope.$index, 1)" icon="delete" size="small" plain></el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-row style="margin-top: 20px" type="flex" justify="end">
|
||||
<el-pagination
|
||||
style="text-align: right"
|
||||
:total="len"
|
||||
layout="prev, pager, next, total"
|
||||
@current-change="handlePageChange"
|
||||
v-model:current-page="pageNum"
|
||||
:page-size="pageSize"
|
||||
></el-pagination>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<!-- <template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="cancel()">取 消</el-button>
|
||||
<el-button @click="saveValue" type="primary" v-auth="'redis:data:save'">确 定</el-button>
|
||||
</div>
|
||||
</template> -->
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, reactive, watch, toRefs } from 'vue';
|
||||
import { redisApi } from './api';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { isTrue, notEmpty } from '@/common/assert';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ListValue',
|
||||
components: {},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
redisId: {
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
db: {
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
keyInfo: {
|
||||
type: [Object],
|
||||
},
|
||||
// 操作类型,1:新增,2:修改
|
||||
operationType: {
|
||||
type: [Number],
|
||||
},
|
||||
listValue: {
|
||||
type: [Array, Object],
|
||||
},
|
||||
},
|
||||
emits: ['valChange', 'cancel', 'update:visible'],
|
||||
setup(props: any, { emit }) {
|
||||
const state = reactive({
|
||||
dialogVisible: false,
|
||||
operationType: 1,
|
||||
redisId: '',
|
||||
db: 0,
|
||||
key: {
|
||||
key: '',
|
||||
type: 'string',
|
||||
timed: -1,
|
||||
},
|
||||
value: [{ value: '' }],
|
||||
len: 0,
|
||||
start: 0,
|
||||
stop: 0,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
|
||||
const cancel = () => {
|
||||
emit('update:visible', false);
|
||||
emit('cancel');
|
||||
setTimeout(() => {
|
||||
state.key = {
|
||||
key: '',
|
||||
type: 'string',
|
||||
timed: -1,
|
||||
};
|
||||
state.value = [];
|
||||
}, 500);
|
||||
};
|
||||
|
||||
watch(props, async (newValue) => {
|
||||
state.dialogVisible = newValue.visible;
|
||||
state.key = newValue.key;
|
||||
state.redisId = newValue.redisId;
|
||||
state.db = newValue.db;
|
||||
state.key = newValue.keyInfo;
|
||||
state.operationType = newValue.operationType;
|
||||
// 如果是查看编辑操作,则获取值
|
||||
if (state.dialogVisible && state.operationType == 2) {
|
||||
getListValue();
|
||||
}
|
||||
});
|
||||
|
||||
const getListValue = async () => {
|
||||
const pageNum = state.pageNum;
|
||||
const pageSize = state.pageSize;
|
||||
const res = await redisApi.getListValue.request({
|
||||
id: state.redisId,
|
||||
db: state.db,
|
||||
key: state.key.key,
|
||||
start: (pageNum - 1) * pageSize,
|
||||
stop: pageNum * pageSize - 1,
|
||||
});
|
||||
state.len = res.len;
|
||||
state.value = res.list.map((x: any) => {
|
||||
return {
|
||||
value: x,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const lset = async (row: any, rowIndex: number) => {
|
||||
await redisApi.setListValue.request({
|
||||
id: state.redisId,
|
||||
db: state.db,
|
||||
key: state.key.key,
|
||||
index: (state.pageNum - 1) * state.pageSize + rowIndex,
|
||||
value: row.value,
|
||||
});
|
||||
ElMessage.success('数据保存成功');
|
||||
};
|
||||
|
||||
const saveValue = async () => {
|
||||
notEmpty(state.key.key, 'key不能为空');
|
||||
isTrue(state.value.length > 0, 'list内容不能为空');
|
||||
// const sv = { value: state.value.map((x) => x.value), id: state.redisId };
|
||||
// Object.assign(sv, state.key);
|
||||
// await redisApi.saveSetValue.request(sv);
|
||||
|
||||
ElMessage.success('数据保存成功');
|
||||
cancel();
|
||||
emit('valChange');
|
||||
};
|
||||
|
||||
const onAddListValue = () => {
|
||||
state.value.unshift({ value: '' });
|
||||
};
|
||||
|
||||
const handlePageChange = (curPage: number) => {
|
||||
state.pageNum = curPage;
|
||||
getListValue();
|
||||
};
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
saveValue,
|
||||
handlePageChange,
|
||||
cancel,
|
||||
lset,
|
||||
onAddListValue,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style lang="scss">
|
||||
#string-value-text {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
position: relative;
|
||||
|
||||
.text-type-select {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
max-width: 70px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -45,7 +45,9 @@
|
||||
>
|
||||
</el-form-item>
|
||||
<el-form-item prop="db" label="库号:" required>
|
||||
<el-input v-model.number="form.db" placeholder="请输入库号"></el-input>
|
||||
<el-select @change="changeDb" v-model="dbList" multiple placeholder="请选择可操作库号" style="width: 100%">
|
||||
<el-option v-for="db in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]" :key="db" :label="db" :value="db" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="remark" label="备注:">
|
||||
<el-input v-model.trim="form.remark" auto-complete="off" type="textarea"></el-input>
|
||||
@@ -116,6 +118,7 @@ export default defineComponent({
|
||||
mode: 'standalone',
|
||||
host: '',
|
||||
password: null,
|
||||
db: '',
|
||||
project: null,
|
||||
projectId: null,
|
||||
envId: null,
|
||||
@@ -124,6 +127,7 @@ export default defineComponent({
|
||||
enableSshTunnel: null,
|
||||
sshTunnelMachineId: null,
|
||||
},
|
||||
dbList: [0],
|
||||
pwd: '',
|
||||
btnLoading: false,
|
||||
rules: {
|
||||
@@ -151,14 +155,14 @@ export default defineComponent({
|
||||
db: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入库号',
|
||||
message: '请选择库号',
|
||||
trigger: ['change', 'blur'],
|
||||
},
|
||||
],
|
||||
mode: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入模式',
|
||||
message: '请选择模式',
|
||||
trigger: ['change', 'blur'],
|
||||
},
|
||||
],
|
||||
@@ -174,13 +178,26 @@ export default defineComponent({
|
||||
if (newValue.redis) {
|
||||
getEnvs(newValue.redis.projectId);
|
||||
state.form = { ...newValue.redis };
|
||||
convertDb(state.form.db);
|
||||
} else {
|
||||
state.envs = [];
|
||||
state.form = { db: 0, enableSshTunnel: -1 } as any;
|
||||
state.form = { db: '0', enableSshTunnel: -1 } as any;
|
||||
state.dbList = [];
|
||||
}
|
||||
getSshTunnelMachines();
|
||||
});
|
||||
|
||||
const convertDb = (db: string) => {
|
||||
state.dbList = db.split(',').map((x) => Number.parseInt(x));
|
||||
};
|
||||
|
||||
/**
|
||||
* 改变表单中的数据库字段,方便表单错误提示。如全部删光,可提示请添加库号
|
||||
*/
|
||||
const changeDb = () => {
|
||||
state.form.db = state.dbList.length == 0 ? '' : state.dbList.join(',');
|
||||
};
|
||||
|
||||
const getSshTunnelMachines = async () => {
|
||||
if (state.form.enableSshTunnel == 1 && state.sshTunnelMachineList.length == 0) {
|
||||
const res = await machineApi.list.request({ pageNum: 1, pageSize: 100 });
|
||||
@@ -250,6 +267,7 @@ export default defineComponent({
|
||||
return {
|
||||
...toRefs(state),
|
||||
redisForm,
|
||||
changeDb,
|
||||
getSshTunnelMachines,
|
||||
getPwd,
|
||||
changeProject,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<el-button type="primary" icon="edit" :disabled="currentId == null" @click="editRedis(false)" plain>编辑</el-button>
|
||||
<el-button type="danger" icon="delete" :disabled="currentId == null" @click="deleteRedis" plain>删除</el-button>
|
||||
<div style="float: right">
|
||||
<el-select v-model="query.projectId" placeholder="请选择项目" filterable clearable>
|
||||
<el-select @focus="getProjects" v-model="query.projectId" placeholder="请选择项目" filterable clearable>
|
||||
<el-option v-for="item in projects" :key="item.id" :label="`${item.name} [${item.remark}]`" :value="item.id"> </el-option>
|
||||
</el-select>
|
||||
<el-button class="ml5" @click="search" type="success" icon="search"></el-button>
|
||||
@@ -263,8 +263,12 @@ export default defineComponent({
|
||||
state.total = res.total;
|
||||
};
|
||||
|
||||
const editRedis = async (isAdd = false) => {
|
||||
const getProjects = async () => {
|
||||
state.projects = await projectApi.accountProjects.request(null);
|
||||
};
|
||||
|
||||
const editRedis = async (isAdd = false) => {
|
||||
await getProjects();
|
||||
if (isAdd) {
|
||||
state.redisEditDialog.data = null;
|
||||
state.redisEditDialog.title = '新增redis';
|
||||
@@ -283,6 +287,7 @@ export default defineComponent({
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
getProjects,
|
||||
search,
|
||||
handlePageChange,
|
||||
choose,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90">
|
||||
<template #default="scope">
|
||||
<el-button type="danger" @click="set.value.splice(scope.$index, 1)" icon="delete" size="small" plain>删除</el-button>
|
||||
<el-button type="danger" @click="value.splice(scope.$index, 1)" icon="delete" size="small" plain>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -53,6 +53,10 @@ export default defineComponent({
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
db: {
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
keyInfo: {
|
||||
type: [Object],
|
||||
},
|
||||
@@ -70,6 +74,7 @@ export default defineComponent({
|
||||
dialogVisible: false,
|
||||
operationType: 1,
|
||||
redisId: '',
|
||||
db: 0,
|
||||
key: {
|
||||
key: '',
|
||||
type: 'string',
|
||||
@@ -95,6 +100,7 @@ export default defineComponent({
|
||||
state.dialogVisible = newValue.visible;
|
||||
state.key = newValue.key;
|
||||
state.redisId = newValue.redisId;
|
||||
state.db = newValue.db;
|
||||
state.key = newValue.keyInfo;
|
||||
state.operationType = newValue.operationType;
|
||||
// 如果是查看编辑操作,则获取值
|
||||
@@ -106,6 +112,7 @@ export default defineComponent({
|
||||
const getSetValue = async () => {
|
||||
const res = await redisApi.getSetValue.request({
|
||||
id: state.redisId,
|
||||
db: state.db,
|
||||
key: state.key.key,
|
||||
});
|
||||
state.value = res.map((x: any) => {
|
||||
@@ -118,7 +125,7 @@ export default defineComponent({
|
||||
const saveValue = async () => {
|
||||
notEmpty(state.key.key, 'key不能为空');
|
||||
isTrue(state.value.length > 0, 'set内容不能为空');
|
||||
const sv = { value: state.value.map((x) => x.value), id: state.redisId };
|
||||
const sv = { value: state.value.map((x) => x.value), id: state.redisId, db: state.db };
|
||||
Object.assign(sv, state.key);
|
||||
await redisApi.saveSetValue.request(sv);
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ export default defineComponent({
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
db: {
|
||||
type: [Number],
|
||||
require: true,
|
||||
},
|
||||
keyInfo: {
|
||||
type: [Object],
|
||||
},
|
||||
@@ -62,6 +66,7 @@ export default defineComponent({
|
||||
dialogVisible: false,
|
||||
operationType: 1,
|
||||
redisId: '',
|
||||
db: 0,
|
||||
key: {
|
||||
key: '',
|
||||
type: 'string',
|
||||
@@ -101,12 +106,20 @@ export default defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.db,
|
||||
(val) => {
|
||||
state.db = val;
|
||||
}
|
||||
);
|
||||
|
||||
watch(props, async (newValue) => {
|
||||
state.dialogVisible = newValue.visible;
|
||||
state.key = newValue.key;
|
||||
state.redisId = newValue.redisId;
|
||||
state.db = newValue.db;
|
||||
state.key = newValue.keyInfo;
|
||||
state.operationType = newValue.operationType
|
||||
state.operationType = newValue.operationType;
|
||||
// 如果是查看编辑操作,则获取值
|
||||
if (state.dialogVisible && state.operationType == 2) {
|
||||
getStringValue();
|
||||
@@ -116,6 +129,7 @@ export default defineComponent({
|
||||
const getStringValue = async () => {
|
||||
state.string.value = await redisApi.getStringValue.request({
|
||||
id: state.redisId,
|
||||
db: state.db,
|
||||
key: state.key.key,
|
||||
});
|
||||
};
|
||||
@@ -124,7 +138,7 @@ export default defineComponent({
|
||||
notEmpty(state.key.key, 'key不能为空');
|
||||
|
||||
notEmpty(state.string.value, 'value不能为空');
|
||||
const sv = { value: formatJsonString(state.string.value, true), id: state.redisId };
|
||||
const sv = { value: formatJsonString(state.string.value, true), id: state.redisId, db: state.db };
|
||||
Object.assign(sv, state.key);
|
||||
await redisApi.saveStringValue.request(sv);
|
||||
ElMessage.success('数据保存成功');
|
||||
|
||||
@@ -8,16 +8,19 @@ export const redisApi = {
|
||||
saveRedis: Api.create("/redis", 'post'),
|
||||
delRedis: Api.create("/redis/{id}", 'delete'),
|
||||
// 获取权限列表
|
||||
scan: Api.create("/redis/{id}/scan", 'post'),
|
||||
getStringValue: Api.create("/redis/{id}/string-value", 'get'),
|
||||
saveStringValue: Api.create("/redis/{id}/string-value", 'post'),
|
||||
getHashValue: Api.create("/redis/{id}/hash-value", 'get'),
|
||||
hscan: Api.create("/redis/{id}/hscan", 'get'),
|
||||
hget: Api.create("/redis/{id}/hget", 'get'),
|
||||
hdel: Api.create("/redis/{id}/hdel", 'delete'),
|
||||
saveHashValue: Api.create("/redis/{id}/hash-value", 'post'),
|
||||
getSetValue: Api.create("/redis/{id}/set-value", 'get'),
|
||||
saveSetValue: Api.create("/redis/{id}/set-value", 'post'),
|
||||
del: Api.create("/redis/{id}/scan/{cursor}/{count}", 'delete'),
|
||||
delKey: Api.create("/redis/{id}/key", 'delete'),
|
||||
scan: Api.create("/redis/{id}/{db}/scan", 'post'),
|
||||
getStringValue: Api.create("/redis/{id}/{db}/string-value", 'get'),
|
||||
saveStringValue: Api.create("/redis/{id}/{db}/string-value", 'post'),
|
||||
getHashValue: Api.create("/redis/{id}/{db}/hash-value", 'get'),
|
||||
hscan: Api.create("/redis/{id}/{db}/hscan", 'get'),
|
||||
hget: Api.create("/redis/{id}/{db}/hget", 'get'),
|
||||
hdel: Api.create("/redis/{id}/{db}/hdel", 'delete'),
|
||||
saveHashValue: Api.create("/redis/{id}/{db}/hash-value", 'post'),
|
||||
getSetValue: Api.create("/redis/{id}/{db}/set-value", 'get'),
|
||||
saveSetValue: Api.create("/redis/{id}/{db}/set-value", 'post'),
|
||||
del: Api.create("/redis/{id}/{db}/scan/{cursor}/{count}", 'delete'),
|
||||
delKey: Api.create("/redis/{id}/{db}/key", 'delete'),
|
||||
getListValue: Api.create("/redis/{id}/{db}/list-value", 'get'),
|
||||
saveListValue: Api.create("/redis/{id}/{db}/list-value", 'post'),
|
||||
setListValue: Api.create("/redis/{id}/{db}/list-value/lset", 'post'),
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
|
||||
"@babel/parser@^7.16.4":
|
||||
version "7.16.6"
|
||||
resolved "https://registry.npmmirror.com/@babel/parser/download/@babel/parser-7.16.6.tgz"
|
||||
integrity sha512-Gr86ujcNuPDnNOY8mi383Hvi8IYrJVJYuf3XcuBM/Dgd+bINn/7tHqsj+tKkoreMbmGsFLsltI/JJd8fOFWGDQ==
|
||||
version "7.19.1"
|
||||
resolved "https://registry.npmmirror.com/@babel/parser/-/parser-7.19.1.tgz"
|
||||
integrity sha512-h7RCSorm1DdTVGJf3P2Mhj3kdnkmF/EiysUkzS2TdgAYqyjFdMQJbVuXOBej2SBJaXan/lIVtT6KkGbyyq753A==
|
||||
|
||||
"@babel/runtime@^7.15.4":
|
||||
version "7.18.9"
|
||||
resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
|
||||
integrity sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==
|
||||
version "7.19.0"
|
||||
resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.19.0.tgz"
|
||||
integrity sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
@@ -19,14 +19,9 @@
|
||||
resolved "https://registry.npmmirror.com/@ctrl/tinycolor/-/tinycolor-3.4.1.tgz"
|
||||
integrity sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw==
|
||||
|
||||
"@element-plus/icons-vue@^2.0.6":
|
||||
version "2.0.6"
|
||||
resolved "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.0.6.tgz"
|
||||
integrity sha512-lPpG8hYkjL/Z97DH5Ei6w6o22Z4YdNglWCNYOPcB33JCF2A4wye6HFgSI7hEt9zdLyxlSpiqtgf9XcYU+m5mew==
|
||||
|
||||
"@element-plus/icons-vue@^2.0.9":
|
||||
"@element-plus/icons-vue@^2.0.6", "@element-plus/icons-vue@^2.0.9":
|
||||
version "2.0.9"
|
||||
resolved "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.0.9.tgz#b7777c57534522e387303d194451d50ff549d49a"
|
||||
resolved "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.0.9.tgz"
|
||||
integrity sha512-okdrwiVeKBmW41Hkl0eMrXDjzJwhQMuKiBOu17rOszqM+LS/yBYpNQNV5Jvoh06Wc+89fMmb/uhzf8NZuDuUaQ==
|
||||
|
||||
"@eslint/eslintrc@^1.0.5":
|
||||
@@ -44,17 +39,17 @@
|
||||
minimatch "^3.0.4"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@floating-ui/core@^0.7.3":
|
||||
version "0.7.3"
|
||||
resolved "https://registry.npmmirror.com/@floating-ui/core/-/core-0.7.3.tgz"
|
||||
integrity sha512-buc8BXHmG9l82+OQXOFU3Kr2XQx9ys01U/Q9HMIrZ300iLc8HLMgh7dcCqgYzAzf4BkoQvDcXf5Y+CuEZ5JBYg==
|
||||
"@floating-ui/core@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.npmmirror.com/@floating-ui/core/-/core-1.0.1.tgz"
|
||||
integrity sha512-bO37brCPfteXQfFY0DyNDGB3+IMe4j150KFQcgJ5aBP295p9nBGeHEs/p0czrRbtlHq4Px/yoPXO/+dOCcF4uA==
|
||||
|
||||
"@floating-ui/dom@^0.5.4":
|
||||
version "0.5.4"
|
||||
resolved "https://registry.npmmirror.com/@floating-ui/dom/-/dom-0.5.4.tgz"
|
||||
integrity sha512-419BMceRLq0RrmTSDxn8hf9R3VCJv2K9PUfugh5JyEFmdjzDo+e8U5EdR8nzKq8Yj1htzLm3b6eQEEam3/rrtg==
|
||||
"@floating-ui/dom@^1.0.1":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmmirror.com/@floating-ui/dom/-/dom-1.0.2.tgz"
|
||||
integrity sha512-5X9WSvZ8/fjy3gDu8yx9HAA4KG1lazUN2P4/VnaXLxTO9Dz53HI1oYoh1OlhqFNlHgGDiwFX5WhFCc2ljbW3yA==
|
||||
dependencies:
|
||||
"@floating-ui/core" "^0.7.3"
|
||||
"@floating-ui/core" "^1.0.1"
|
||||
|
||||
"@humanwhocodes/config-array@^0.9.2":
|
||||
version "0.9.2"
|
||||
@@ -140,7 +135,7 @@
|
||||
|
||||
"@types/web-bluetooth@^0.0.15":
|
||||
version "0.0.15"
|
||||
resolved "https://registry.npmmirror.com/@types/web-bluetooth/-/web-bluetooth-0.0.15.tgz#d60330046a6ed8a13b4a53df3813c44942ebdf72"
|
||||
resolved "https://registry.npmmirror.com/@types/web-bluetooth/-/web-bluetooth-0.0.15.tgz"
|
||||
integrity sha512-w7hEHXnPMEZ+4nGKl/KDRVpxkwYxYExuHOYXyzIzCDzEZ9ZCGMAewulr9IqJu2LR4N37fcnb1XVeuZ09qgOxhA==
|
||||
|
||||
"@typescript-eslint/eslint-plugin@^4.23.0":
|
||||
@@ -218,89 +213,47 @@
|
||||
resolved "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-2.3.3.tgz"
|
||||
integrity sha512-SmQLDyhz+6lGJhPELsBdzXGc+AcaT8stgkbiTFGpXPe8Tl1tJaBw1A6pxDqDuRsVkD8uscrkx3hA7QDOoKYtyw==
|
||||
|
||||
"@vue/compiler-core@3.2.26":
|
||||
version "3.2.26"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-core/download/@vue/compiler-core-3.2.26.tgz"
|
||||
integrity sha512-N5XNBobZbaASdzY9Lga2D9Lul5vdCIOXvUMd6ThcN8zgqQhPKfCV+wfAJNNJKQkSHudnYRO2gEB+lp0iN3g2Tw==
|
||||
"@vue/compiler-core@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.39.tgz"
|
||||
integrity sha512-mf/36OWXqWn0wsC40nwRRGheR/qoID+lZXbIuLnr4/AngM0ov8Xvv8GHunC0rKRIkh60bTqydlqTeBo49rlbqw==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.16.4"
|
||||
"@vue/shared" "3.2.26"
|
||||
"@vue/shared" "3.2.39"
|
||||
estree-walker "^2.0.2"
|
||||
source-map "^0.6.1"
|
||||
|
||||
"@vue/compiler-core@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.37.tgz"
|
||||
integrity sha512-81KhEjo7YAOh0vQJoSmAD68wLfYqJvoiD4ulyedzF+OEk/bk6/hx3fTNVfuzugIIaTrOx4PGx6pAiBRe5e9Zmg==
|
||||
"@vue/compiler-dom@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.2.39.tgz"
|
||||
integrity sha512-HMFI25Be1C8vLEEv1hgEO1dWwG9QQ8LTTPmCkblVJY/O3OvWx6r1+zsox5mKPMGvqYEZa6l8j+xgOfUspgo7hw==
|
||||
dependencies:
|
||||
"@vue/compiler-core" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
|
||||
"@vue/compiler-sfc@3.2.39", "@vue/compiler-sfc@^3.0.11":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.2.39.tgz"
|
||||
integrity sha512-fqAQgFs1/BxTUZkd0Vakn3teKUt//J3c420BgnYgEOoVdTwYpBTSXCMJ88GOBCylmUBbtquGPli9tVs7LzsWIA==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.16.4"
|
||||
"@vue/shared" "3.2.37"
|
||||
estree-walker "^2.0.2"
|
||||
source-map "^0.6.1"
|
||||
|
||||
"@vue/compiler-dom@3.2.26":
|
||||
version "3.2.26"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-dom/download/@vue/compiler-dom-3.2.26.tgz"
|
||||
integrity sha512-smBfaOW6mQDxcT3p9TKT6mE22vjxjJL50GFVJiI0chXYGU/xzC05QRGrW3HHVuJrmLTLx5zBhsZ2dIATERbarg==
|
||||
dependencies:
|
||||
"@vue/compiler-core" "3.2.26"
|
||||
"@vue/shared" "3.2.26"
|
||||
|
||||
"@vue/compiler-dom@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.2.37.tgz"
|
||||
integrity sha512-yxJLH167fucHKxaqXpYk7x8z7mMEnXOw3G2q62FTkmsvNxu4FQSu5+3UMb+L7fjKa26DEzhrmCxAgFLLIzVfqQ==
|
||||
dependencies:
|
||||
"@vue/compiler-core" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
|
||||
"@vue/compiler-sfc@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.2.37.tgz"
|
||||
integrity sha512-+7i/2+9LYlpqDv+KTtWhOZH+pa8/HnX/905MdVmAcI/mPQOBwkHHIzrsEsucyOIZQYMkXUiTkmZq5am/NyXKkg==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.16.4"
|
||||
"@vue/compiler-core" "3.2.37"
|
||||
"@vue/compiler-dom" "3.2.37"
|
||||
"@vue/compiler-ssr" "3.2.37"
|
||||
"@vue/reactivity-transform" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
"@vue/compiler-core" "3.2.39"
|
||||
"@vue/compiler-dom" "3.2.39"
|
||||
"@vue/compiler-ssr" "3.2.39"
|
||||
"@vue/reactivity-transform" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
estree-walker "^2.0.2"
|
||||
magic-string "^0.25.7"
|
||||
postcss "^8.1.10"
|
||||
source-map "^0.6.1"
|
||||
|
||||
"@vue/compiler-sfc@^3.0.11":
|
||||
version "3.2.26"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-sfc/download/@vue/compiler-sfc-3.2.26.tgz"
|
||||
integrity sha512-ePpnfktV90UcLdsDQUh2JdiTuhV0Skv2iYXxfNMOK/F3Q+2BO0AulcVcfoksOpTJGmhhfosWfMyEaEf0UaWpIw==
|
||||
"@vue/compiler-ssr@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.2.39.tgz"
|
||||
integrity sha512-EoGCJ6lincKOZGW+0Ky4WOKsSmqL7hp1ZYgen8M7u/mlvvEQUaO9tKKOy7K43M9U2aA3tPv0TuYYQFrEbK2eFQ==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.16.4"
|
||||
"@vue/compiler-core" "3.2.26"
|
||||
"@vue/compiler-dom" "3.2.26"
|
||||
"@vue/compiler-ssr" "3.2.26"
|
||||
"@vue/reactivity-transform" "3.2.26"
|
||||
"@vue/shared" "3.2.26"
|
||||
estree-walker "^2.0.2"
|
||||
magic-string "^0.25.7"
|
||||
postcss "^8.1.10"
|
||||
source-map "^0.6.1"
|
||||
|
||||
"@vue/compiler-ssr@3.2.26":
|
||||
version "3.2.26"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-ssr/download/@vue/compiler-ssr-3.2.26.tgz"
|
||||
integrity sha512-2mywLX0ODc4Zn8qBoA2PDCsLEZfpUGZcyoFRLSOjyGGK6wDy2/5kyDOWtf0S0UvtoyVq95OTSGIALjZ4k2q/ag==
|
||||
dependencies:
|
||||
"@vue/compiler-dom" "3.2.26"
|
||||
"@vue/shared" "3.2.26"
|
||||
|
||||
"@vue/compiler-ssr@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.2.37.tgz"
|
||||
integrity sha512-7mQJD7HdXxQjktmsWp/J67lThEIcxLemz1Vb5I6rYJHR5vI+lON3nPGOH3ubmbvYGt8xEUaAr1j7/tIFWiEOqw==
|
||||
dependencies:
|
||||
"@vue/compiler-dom" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
"@vue/compiler-dom" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
|
||||
"@vue/devtools-api@^6.0.0-beta.11":
|
||||
version "6.0.0-beta.20.1"
|
||||
@@ -312,89 +265,73 @@
|
||||
resolved "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.1.4.tgz"
|
||||
integrity sha512-IiA0SvDrJEgXvVxjNkHPFfDx6SXw0b/TUkqMcDZWNg9fnCAHbTpoo59YfJ9QLFkwa3raau5vSlRVzMSLDnfdtQ==
|
||||
|
||||
"@vue/reactivity-transform@3.2.26":
|
||||
version "3.2.26"
|
||||
resolved "https://registry.npmmirror.com/@vue/reactivity-transform/download/@vue/reactivity-transform-3.2.26.tgz"
|
||||
integrity sha512-XKMyuCmzNA7nvFlYhdKwD78rcnmPb7q46uoR00zkX6yZrUmcCQ5OikiwUEVbvNhL5hBJuvbSO95jB5zkUon+eQ==
|
||||
"@vue/reactivity-transform@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.39.tgz"
|
||||
integrity sha512-HGuWu864zStiWs9wBC6JYOP1E00UjMdDWIG5W+FpUx28hV3uz9ODOKVNm/vdOy/Pvzg8+OcANxAVC85WFBbl3A==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.16.4"
|
||||
"@vue/compiler-core" "3.2.26"
|
||||
"@vue/shared" "3.2.26"
|
||||
"@vue/compiler-core" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
estree-walker "^2.0.2"
|
||||
magic-string "^0.25.7"
|
||||
|
||||
"@vue/reactivity-transform@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.37.tgz"
|
||||
integrity sha512-IWopkKEb+8qpu/1eMKVeXrK0NLw9HicGviJzhJDEyfxTR9e1WtpnnbYkJWurX6WwoFP0sz10xQg8yL8lgskAZg==
|
||||
"@vue/reactivity@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.2.39.tgz"
|
||||
integrity sha512-vlaYX2a3qMhIZfrw3Mtfd+BuU+TZmvDrPMa+6lpfzS9k/LnGxkSuf0fhkP0rMGfiOHPtyKoU9OJJJFGm92beVQ==
|
||||
dependencies:
|
||||
"@babel/parser" "^7.16.4"
|
||||
"@vue/compiler-core" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
estree-walker "^2.0.2"
|
||||
magic-string "^0.25.7"
|
||||
"@vue/shared" "3.2.39"
|
||||
|
||||
"@vue/reactivity@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.2.37.tgz"
|
||||
integrity sha512-/7WRafBOshOc6m3F7plwzPeCu/RCVv9uMpOwa/5PiY1Zz+WLVRWiy0MYKwmg19KBdGtFWsmZ4cD+LOdVPcs52A==
|
||||
"@vue/runtime-core@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.2.39.tgz"
|
||||
integrity sha512-xKH5XP57JW5JW+8ZG1khBbuLakINTgPuINKL01hStWLTTGFOrM49UfCFXBcFvWmSbci3gmJyLl2EAzCaZWsx8g==
|
||||
dependencies:
|
||||
"@vue/shared" "3.2.37"
|
||||
"@vue/reactivity" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
|
||||
"@vue/runtime-core@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.2.37.tgz"
|
||||
integrity sha512-JPcd9kFyEdXLl/i0ClS7lwgcs0QpUAWj+SKX2ZC3ANKi1U4DOtiEr6cRqFXsPwY5u1L9fAjkinIdB8Rz3FoYNQ==
|
||||
"@vue/runtime-dom@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.2.39.tgz"
|
||||
integrity sha512-4G9AEJP+sLhsqf5wXcyKVWQKUhI+iWfy0hWQgea+CpaTD7BR0KdQzvoQdZhwCY6B3oleSyNLkLAQwm0ya/wNoA==
|
||||
dependencies:
|
||||
"@vue/reactivity" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
|
||||
"@vue/runtime-dom@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.2.37.tgz"
|
||||
integrity sha512-HimKdh9BepShW6YozwRKAYjYQWg9mQn63RGEiSswMbW+ssIht1MILYlVGkAGGQbkhSh31PCdoUcfiu4apXJoPw==
|
||||
dependencies:
|
||||
"@vue/runtime-core" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
"@vue/runtime-core" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
csstype "^2.6.8"
|
||||
|
||||
"@vue/server-renderer@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.2.37.tgz"
|
||||
integrity sha512-kLITEJvaYgZQ2h47hIzPh2K3jG8c1zCVbp/o/bzQOyvzaKiCquKS7AaioPI28GNxIsE/zSx+EwWYsNxDCX95MA==
|
||||
"@vue/server-renderer@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.2.39.tgz"
|
||||
integrity sha512-1yn9u2YBQWIgytFMjz4f/t0j43awKytTGVptfd3FtBk76t1pd8mxbek0G/DrnjJhd2V7mSTb5qgnxMYt8Z5iSQ==
|
||||
dependencies:
|
||||
"@vue/compiler-ssr" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
"@vue/compiler-ssr" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
|
||||
"@vue/shared@3.2.26":
|
||||
version "3.2.26"
|
||||
resolved "https://registry.npmmirror.com/@vue/shared/download/@vue/shared-3.2.26.tgz"
|
||||
integrity sha512-vPV6Cq+NIWbH5pZu+V+2QHE9y1qfuTq49uNWw4f7FDEeZaDU2H2cx5jcUZOAKW7qTrUS4k6qZPbMy1x4N96nbA==
|
||||
|
||||
"@vue/shared@3.2.37":
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.37.tgz"
|
||||
integrity sha512-4rSJemR2NQIo9Klm1vabqWjD8rs/ZaJSzMxkMNeJS6lHiUjjUeYFbooN19NgFjztubEKh3WlZUeOLVdbbUWHsw==
|
||||
"@vue/shared@3.2.39":
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.39.tgz"
|
||||
integrity sha512-D3dl2ZB9qE6mTuWPk9RlhDeP1dgNRUKC3NJxji74A4yL8M2MwlhLKUC/49WHjrNzSPug58fWx/yFbaTzGAQSBw==
|
||||
|
||||
"@vueuse/core@^9.1.0":
|
||||
version "9.1.0"
|
||||
resolved "https://registry.npmmirror.com/@vueuse/core/-/core-9.1.0.tgz#f0fb13fd99768c0eb617169a2d2c1cbd5f5a52eb"
|
||||
integrity sha512-BIroqvXEqt826aE9r3K5cox1zobuPuAzdYJ36kouC2TVhlXvFKIILgFVWrpp9HZPwB3aLzasmG3K87q7TSyXZg==
|
||||
version "9.2.0"
|
||||
resolved "https://registry.npmmirror.com/@vueuse/core/-/core-9.2.0.tgz"
|
||||
integrity sha512-/MZ6qpz6uSyaXrtoeBWQzAKRG3N7CvfVWvQxiM3ei3Xe5ydOjjtVbo7lGl9p8dECV93j7W8s63A8H0kFLpLyxg==
|
||||
dependencies:
|
||||
"@types/web-bluetooth" "^0.0.15"
|
||||
"@vueuse/metadata" "9.1.0"
|
||||
"@vueuse/shared" "9.1.0"
|
||||
"@vueuse/metadata" "9.2.0"
|
||||
"@vueuse/shared" "9.2.0"
|
||||
vue-demi "*"
|
||||
|
||||
"@vueuse/metadata@9.1.0":
|
||||
version "9.1.0"
|
||||
resolved "https://registry.npmmirror.com/@vueuse/metadata/-/metadata-9.1.0.tgz#194d4bd47f7acb91e348c0f436e678ddf7ee235b"
|
||||
integrity sha512-8OEhlog1iaAGTD3LICZ8oBGQdYeMwByvXetOtAOZCJOzyCRSwqwdggTsmVZZ1rkgYIEqgUBk942AsAPwM21s6A==
|
||||
"@vueuse/metadata@9.2.0":
|
||||
version "9.2.0"
|
||||
resolved "https://registry.npmmirror.com/@vueuse/metadata/-/metadata-9.2.0.tgz"
|
||||
integrity sha512-exN4KE6iquxDCdt72BgEhb3tlOpECtD61AUdXnUqBTIUCl70x1Ar/QXo3bYcvxmdMS2/peQyfeTzBjRTpvL5xw==
|
||||
|
||||
"@vueuse/shared@9.1.0":
|
||||
version "9.1.0"
|
||||
resolved "https://registry.npmmirror.com/@vueuse/shared/-/shared-9.1.0.tgz#d8459a45324f32fb05a2a56ed754637c3d0efaeb"
|
||||
integrity sha512-pB/3njQu4tfJJ78ajELNda0yMG6lKfpToQW7Soe09CprF1k3QuyoNi1tBNvo75wBDJWD+LOnr+c4B5HZ39jY/Q==
|
||||
"@vueuse/shared@9.2.0":
|
||||
version "9.2.0"
|
||||
resolved "https://registry.npmmirror.com/@vueuse/shared/-/shared-9.2.0.tgz"
|
||||
integrity sha512-NnRp/noSWuXW0dKhZK5D0YLrDi0nmZ18UeEgwXQq7Ul5TTP93lcNnKjrHtd68j2xFB/l59yPGFlCryL692bnrA==
|
||||
dependencies:
|
||||
vue-demi "*"
|
||||
|
||||
@@ -460,7 +397,7 @@ array-union@^2.1.0:
|
||||
|
||||
asciinema-player@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.npmmirror.com/asciinema-player/-/asciinema-player-3.0.1.tgz#4ea9e6ee2cc5c1f956bfb562950279dcfad3e737"
|
||||
resolved "https://registry.npmmirror.com/asciinema-player/-/asciinema-player-3.0.1.tgz"
|
||||
integrity sha512-plm/C/MhOtZWysrfcT/rzxOuu8vxvvDSvF50pqZS6KpJUDmATedAhO54zktbE/g7RiaaYfzgX8xjRhlQdgISwA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.15.4"
|
||||
@@ -595,14 +532,14 @@ cross-spawn@^7.0.2:
|
||||
which "^2.0.1"
|
||||
|
||||
csstype@^2.6.8:
|
||||
version "2.6.19"
|
||||
resolved "https://registry.npmmirror.com/csstype/download/csstype-2.6.19.tgz?cache=0&sync_timestamp=1637224514674&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fcsstype%2Fdownload%2Fcsstype-2.6.19.tgz"
|
||||
integrity sha512-ZVxXaNy28/k3kJg0Fou5MiYpp88j7H9hLZp8PDC3jV0WFjfH5E9xHb56L0W59cPbKbcHXeP4qyT8PrHp8t6LcQ==
|
||||
version "2.6.21"
|
||||
resolved "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz"
|
||||
integrity sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==
|
||||
|
||||
csstype@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2"
|
||||
integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==
|
||||
version "3.1.1"
|
||||
resolved "https://registry.npmmirror.com/csstype/-/csstype-3.1.1.tgz"
|
||||
integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==
|
||||
|
||||
dayjs@^1.11.3:
|
||||
version "1.11.3"
|
||||
@@ -658,14 +595,14 @@ echarts@^5.3.3:
|
||||
tslib "2.3.0"
|
||||
zrender "5.3.2"
|
||||
|
||||
element-plus@^2.2.15:
|
||||
version "2.2.15"
|
||||
resolved "https://registry.npmmirror.com/element-plus/-/element-plus-2.2.15.tgz#862bb6ecbd15b2d82d79dcf56bbbc30010771132"
|
||||
integrity sha512-SMIx8xKB1YawT9JocyFhbs3Av2rXFfxrCVTLMYS0DK0xnW+fKvwjZngLfwF6MyRzXIuzNW17XFtu0iP3tlJHbA==
|
||||
element-plus@^2.2.17:
|
||||
version "2.2.17"
|
||||
resolved "https://registry.npmmirror.com/element-plus/-/element-plus-2.2.17.tgz"
|
||||
integrity sha512-MGwMIE/q+FFD3kgS23x8HIe5043tmD1cTRwjhIX9o6fim1avFnUkrsfYRvybbz4CkyqSb185EheZS5AUPpXh2g==
|
||||
dependencies:
|
||||
"@ctrl/tinycolor" "^3.4.1"
|
||||
"@element-plus/icons-vue" "^2.0.6"
|
||||
"@floating-ui/dom" "^0.5.4"
|
||||
"@floating-ui/dom" "^1.0.1"
|
||||
"@popperjs/core" "npm:@sxzz/popperjs-es@^2.11.7"
|
||||
"@types/lodash" "^4.14.182"
|
||||
"@types/lodash-es" "^4.17.6"
|
||||
@@ -952,8 +889,8 @@ estraverse@^5.1.0, estraverse@^5.2.0:
|
||||
|
||||
estree-walker@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.npm.taobao.org/estree-walker/download/estree-walker-2.0.2.tgz"
|
||||
integrity sha1-UvAQF4wqTBF6d1fP6UKtt9LaTKw=
|
||||
resolved "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz"
|
||||
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
|
||||
|
||||
esutils@^2.0.2:
|
||||
version "2.0.3"
|
||||
@@ -1293,11 +1230,11 @@ lru-cache@^6.0.0:
|
||||
yallist "^4.0.0"
|
||||
|
||||
magic-string@^0.25.7:
|
||||
version "0.25.7"
|
||||
resolved "https://registry.npm.taobao.org/magic-string/download/magic-string-0.25.7.tgz"
|
||||
integrity sha1-P0l9b9NMZpxnmNy4IfLvMfVEUFE=
|
||||
version "0.25.9"
|
||||
resolved "https://registry.npmmirror.com/magic-string/-/magic-string-0.25.9.tgz"
|
||||
integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
|
||||
dependencies:
|
||||
sourcemap-codec "^1.4.4"
|
||||
sourcemap-codec "^1.4.8"
|
||||
|
||||
memoize-one@^6.0.0:
|
||||
version "6.0.0"
|
||||
@@ -1378,7 +1315,7 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
|
||||
|
||||
normalize-wheel-es@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmmirror.com/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz#0fa2593d619f7245a541652619105ab076acf09e"
|
||||
resolved "https://registry.npmmirror.com/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz"
|
||||
integrity sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==
|
||||
|
||||
nprogress@^0.2.0:
|
||||
@@ -1499,7 +1436,7 @@ readdirp@~3.6.0:
|
||||
|
||||
regenerator-runtime@^0.13.4:
|
||||
version "0.13.9"
|
||||
resolved "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
|
||||
resolved "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz"
|
||||
integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==
|
||||
|
||||
regexpp@^3.1.0, regexpp@^3.2.0:
|
||||
@@ -1566,7 +1503,7 @@ sass@^1.45.1:
|
||||
|
||||
screenfull@^6.0.2:
|
||||
version "6.0.2"
|
||||
resolved "https://registry.npmmirror.com/screenfull/-/screenfull-6.0.2.tgz#3dbe4b8c4f8f49fb8e33caa8f69d0bca730ab238"
|
||||
resolved "https://registry.npmmirror.com/screenfull/-/screenfull-6.0.2.tgz"
|
||||
integrity sha512-AQdy8s4WhNvUZ6P8F6PB21tSPIYKniic+Ogx0AacBMjKP1GUHN2E9URxQHtCusiwxudnCKkdy4GrHXPPJSkCCw==
|
||||
|
||||
select@^1.1.2:
|
||||
@@ -1599,9 +1536,9 @@ slash@^3.0.0:
|
||||
integrity sha1-ZTm+hwwWWtvVJAIg2+Nh8bxNRjQ=
|
||||
|
||||
solid-js@^1.3.0:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.npmmirror.com/solid-js/-/solid-js-1.5.1.tgz#b4281cf92cb00b235e62ef890d87ea996a9b9fa3"
|
||||
integrity sha512-Y6aKystIxnrB0quV5nhqNuJV+l2Fk3/PQy1mMya/bzxlGiMHAym7v1NaqEgqDIvctbkxOi5dBj0ER/ewrH060g==
|
||||
version "1.5.6"
|
||||
resolved "https://registry.npmmirror.com/solid-js/-/solid-js-1.5.6.tgz"
|
||||
integrity sha512-EA7hjMIEdDUuV6Fk3WUQ2fPx7sRnhjl+3M59zj6Sh+c7c3JF3N1cSViBvX8MYJG9vEBEqKQBZUfKHPe/9JgKvQ==
|
||||
dependencies:
|
||||
csstype "^3.1.0"
|
||||
|
||||
@@ -1622,17 +1559,17 @@ source-map-js@^1.0.2:
|
||||
|
||||
source-map@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz"
|
||||
integrity sha1-dHIq8y6WFOnCh6jQu95IteLxomM=
|
||||
resolved "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
sourcemap-codec@^1.4.4:
|
||||
sourcemap-codec@^1.4.8:
|
||||
version "1.4.8"
|
||||
resolved "https://registry.npm.taobao.org/sourcemap-codec/download/sourcemap-codec-1.4.8.tgz"
|
||||
integrity sha1-6oBL2UhXQC5pktBaOO8a41qatMQ=
|
||||
resolved "https://registry.npmmirror.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz"
|
||||
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
|
||||
|
||||
sql-formatter@^9.2.0:
|
||||
version "9.2.0"
|
||||
resolved "https://registry.npmmirror.com/sql-formatter/-/sql-formatter-9.2.0.tgz#18a398ae71436dc1936a45e6f230236b4347231b"
|
||||
resolved "https://registry.npmmirror.com/sql-formatter/-/sql-formatter-9.2.0.tgz"
|
||||
integrity sha512-Dn4lEpUeAhfNDR2LnEs9Uaq92TSHjhcNrzhllPuMnp188P4sLU7UcdcB9UqIfMfcN62gWXJlJ3KocaAf/SOzXQ==
|
||||
dependencies:
|
||||
argparse "^2.0.1"
|
||||
@@ -1751,9 +1688,9 @@ vue-clipboard3@^1.0.1:
|
||||
clipboard "^2.0.6"
|
||||
|
||||
vue-demi@*:
|
||||
version "0.12.1"
|
||||
resolved "https://registry.npmmirror.com/vue-demi/download/vue-demi-0.12.1.tgz"
|
||||
integrity sha1-9+GO++z/0RqwadFHLXoG4xm0F0w=
|
||||
version "0.13.11"
|
||||
resolved "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.13.11.tgz"
|
||||
integrity sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==
|
||||
|
||||
vue-eslint-parser@^8.0.1:
|
||||
version "8.0.1"
|
||||
@@ -1768,23 +1705,23 @@ vue-eslint-parser@^8.0.1:
|
||||
lodash "^4.17.21"
|
||||
semver "^7.3.5"
|
||||
|
||||
vue-router@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.npmmirror.com/vue-router/-/vue-router-4.1.2.tgz"
|
||||
integrity sha512-5BP1qXFncVRwgV/XnqzsKApdMjQPqWIpoUBdL1ynz8HyLxIX/UDAx7Ql2BjmA5CXT/p61JfZvkpiFWFpaqcfag==
|
||||
vue-router@^4.1.5:
|
||||
version "4.1.5"
|
||||
resolved "https://registry.npmmirror.com/vue-router/-/vue-router-4.1.5.tgz"
|
||||
integrity sha512-IsvoF5D2GQ/EGTs/Th4NQms9gd2NSqV+yylxIyp/OYp8xOwxmU8Kj/74E9DTSYAyH5LX7idVUngN3JSj1X4xcQ==
|
||||
dependencies:
|
||||
"@vue/devtools-api" "^6.1.4"
|
||||
|
||||
vue@^3.2.37:
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmmirror.com/vue/-/vue-3.2.37.tgz"
|
||||
integrity sha512-bOKEZxrm8Eh+fveCqS1/NkG/n6aMidsI6hahas7pa0w/l7jkbssJVsRhVDs07IdDq7h9KHswZOgItnwJAgtVtQ==
|
||||
vue@^3.2.39:
|
||||
version "3.2.39"
|
||||
resolved "https://registry.npmmirror.com/vue/-/vue-3.2.39.tgz"
|
||||
integrity sha512-tRkguhRTw9NmIPXhzk21YFBqXHT2t+6C6wPOgQ50fcFVWnPdetmRqbmySRHznrYjX2E47u0cGlKGcxKZJ38R/g==
|
||||
dependencies:
|
||||
"@vue/compiler-dom" "3.2.37"
|
||||
"@vue/compiler-sfc" "3.2.37"
|
||||
"@vue/runtime-dom" "3.2.37"
|
||||
"@vue/server-renderer" "3.2.37"
|
||||
"@vue/shared" "3.2.37"
|
||||
"@vue/compiler-dom" "3.2.39"
|
||||
"@vue/compiler-sfc" "3.2.39"
|
||||
"@vue/runtime-dom" "3.2.39"
|
||||
"@vue/server-renderer" "3.2.39"
|
||||
"@vue/shared" "3.2.39"
|
||||
|
||||
vuex@^4.0.2:
|
||||
version "4.0.2"
|
||||
@@ -1810,15 +1747,15 @@ wrappy@1:
|
||||
resolved "https://registry.nlark.com/wrappy/download/wrappy-1.0.2.tgz?cache=0&sync_timestamp=1619133505879&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fwrappy%2Fdownload%2Fwrappy-1.0.2.tgz"
|
||||
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
||||
|
||||
xterm-addon-fit@^0.5.0:
|
||||
version "0.5.0"
|
||||
resolved "https://registry.npmmirror.com/xterm-addon-fit/download/xterm-addon-fit-0.5.0.tgz"
|
||||
integrity sha1-LVG5g7eGqX3NbN6AXnAMf5E7xZY=
|
||||
xterm-addon-fit@^0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.npmmirror.com/xterm-addon-fit/-/xterm-addon-fit-0.6.0.tgz"
|
||||
integrity sha512-9/7A+1KEjkFam0yxTaHfuk9LEvvTSBi0PZmEkzJqgafXPEXL9pCMAVV7rB09sX6ATRDXAdBpQhZkhKj7CGvYeg==
|
||||
|
||||
xterm@^4.19.0:
|
||||
version "4.19.0"
|
||||
resolved "https://registry.npmmirror.com/xterm/-/xterm-4.19.0.tgz"
|
||||
integrity sha512-c3Cp4eOVsYY5Q839dR5IejghRPpxciGmLWWaP9g+ppfMeBChMeLa1DCA+pmX/jyDZ+zxFOmlJL/82qVdayVoGQ==
|
||||
xterm@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.npmmirror.com/xterm/-/xterm-5.0.0.tgz"
|
||||
integrity sha512-tmVsKzZovAYNDIaUinfz+VDclraQpPUnAME+JawosgWRMphInDded/PuY0xmU5dOhyeYZsI0nz5yd8dPYsdLTA==
|
||||
|
||||
yallist@^4.0.0:
|
||||
version "4.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module mayfly-go
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
@@ -15,11 +15,11 @@ require (
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
|
||||
go.mongodb.org/mongo-driver v1.9.1 // mongo
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // ssh
|
||||
golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7 // ssh
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
// gorm
|
||||
gorm.io/driver/mysql v1.3.5
|
||||
gorm.io/gorm v1.23.8
|
||||
gorm.io/driver/mysql v1.3.6
|
||||
gorm.io/gorm v1.23.10
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@@ -4,7 +4,11 @@ import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
common_router "mayfly-go/internal/common/router"
|
||||
devops_router "mayfly-go/internal/devops/router"
|
||||
db_router "mayfly-go/internal/db/router"
|
||||
machine_router "mayfly-go/internal/machine/router"
|
||||
mongo_router "mayfly-go/internal/mongo/router"
|
||||
project_router "mayfly-go/internal/project/router"
|
||||
redis_router "mayfly-go/internal/redis/router"
|
||||
sys_router "mayfly-go/internal/sys/router"
|
||||
"mayfly-go/pkg/config"
|
||||
"mayfly-go/pkg/middleware"
|
||||
@@ -68,22 +72,13 @@ func InitRouter() *gin.Engine {
|
||||
common_router.InitIndexRouter(api)
|
||||
common_router.InitCommonRouter(api)
|
||||
|
||||
sys_router.InitCaptchaRouter(api)
|
||||
sys_router.InitAccountRouter(api) // 注册account路由
|
||||
sys_router.InitResourceRouter(api)
|
||||
sys_router.InitRoleRouter(api)
|
||||
sys_router.InitSystemRouter(api)
|
||||
sys_router.InitSyslogRouter(api)
|
||||
sys_router.InitSysConfigRouter(api)
|
||||
sys_router.Init(api)
|
||||
|
||||
devops_router.InitProjectRouter(api)
|
||||
devops_router.InitDbRouter(api)
|
||||
devops_router.InitDbSqlExecRouter(api)
|
||||
devops_router.InitRedisRouter(api)
|
||||
devops_router.InitMachineRouter(api)
|
||||
devops_router.InitMachineScriptRouter(api)
|
||||
devops_router.InitMachineFileRouter(api)
|
||||
devops_router.InitMongoRouter(api)
|
||||
project_router.Init(api)
|
||||
machine_router.Init(api)
|
||||
db_router.Init(api)
|
||||
redis_router.Init(api)
|
||||
mongo_router.Init(api)
|
||||
}
|
||||
|
||||
return router
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
sys_application "mayfly-go/internal/sys/application"
|
||||
sysapp "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
)
|
||||
|
||||
func InitSaveLogFunc() ctx.SaveLogFunc {
|
||||
return sys_application.SyslogApp.SaveFromReq
|
||||
return sysapp.GetSyslogApp().SaveFromReq
|
||||
}
|
||||
|
||||
@@ -1,23 +1,30 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
dbapp "mayfly-go/internal/db/application"
|
||||
dbentity "mayfly-go/internal/db/domain/entity"
|
||||
machineentity "mayfly-go/internal/machine/domain/entity"
|
||||
projectentity "mayfly-go/internal/project/domain/entity"
|
||||
redisentity "mayfly-go/internal/redis/domain/entity"
|
||||
|
||||
machineapp "mayfly-go/internal/machine/application"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
redisapp "mayfly-go/internal/redis/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
)
|
||||
|
||||
type Index struct {
|
||||
ProjectApp application.Project
|
||||
MachineApp application.Machine
|
||||
DbApp application.Db
|
||||
RedisApp application.Redis
|
||||
ProjectApp projectapp.Project
|
||||
MachineApp machineapp.Machine
|
||||
DbApp dbapp.Db
|
||||
RedisApp redisapp.Redis
|
||||
}
|
||||
|
||||
func (i *Index) Count(rc *ctx.ReqCtx) {
|
||||
rc.ResData = map[string]interface{}{
|
||||
"projectNum": i.ProjectApp.Count(new(entity.Project)),
|
||||
"machineNum": i.MachineApp.Count(new(entity.Machine)),
|
||||
"dbNum": i.DbApp.Count(new(entity.Db)),
|
||||
"redisNum": i.RedisApp.Count(new(entity.Redis)),
|
||||
"projectNum": i.ProjectApp.Count(new(projectentity.Project)),
|
||||
"machineNum": i.MachineApp.Count(new(machineentity.Machine)),
|
||||
"dbNum": i.DbApp.Count(new(dbentity.Db)),
|
||||
"redisNum": i.RedisApp.Count(new(redisentity.Redis)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/common/api"
|
||||
devops_app "mayfly-go/internal/devops/application"
|
||||
dbapp "mayfly-go/internal/db/application"
|
||||
machineapp "mayfly-go/internal/machine/application"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
redisapp "mayfly-go/internal/redis/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -11,10 +14,10 @@ import (
|
||||
func InitIndexRouter(router *gin.RouterGroup) {
|
||||
index := router.Group("common/index")
|
||||
i := &api.Index{
|
||||
ProjectApp: devops_app.ProjectApp,
|
||||
MachineApp: devops_app.MachineApp,
|
||||
DbApp: devops_app.DbApp,
|
||||
RedisApp: devops_app.RedisApp,
|
||||
ProjectApp: projectapp.GetProjectApp(),
|
||||
MachineApp: machineapp.GetMachineApp(),
|
||||
DbApp: dbapp.GetDbApp(),
|
||||
RedisApp: redisapp.GetRedisApp(),
|
||||
}
|
||||
{
|
||||
// 首页基本信息统计
|
||||
|
||||
@@ -3,11 +3,12 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"mayfly-go/internal/devops/api/form"
|
||||
"mayfly-go/internal/devops/api/vo"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
sysApplication "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/internal/db/api/form"
|
||||
"mayfly-go/internal/db/api/vo"
|
||||
"mayfly-go/internal/db/application"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
sysapp "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/ginx"
|
||||
@@ -25,8 +26,8 @@ import (
|
||||
type Db struct {
|
||||
DbApp application.Db
|
||||
DbSqlExecApp application.DbSqlExec
|
||||
MsgApp sysApplication.Msg
|
||||
ProjectApp application.Project
|
||||
MsgApp sysapp.Msg
|
||||
ProjectApp projectapp.Project
|
||||
}
|
||||
|
||||
const DEFAULT_COLUMN_SIZE = 500
|
||||
@@ -129,37 +130,21 @@ func (d *Db) ExecSql(rc *ctx.ReqCtx) {
|
||||
})
|
||||
|
||||
rc.ReqParam = fmt.Sprintf("db: %d:%s | sql: %s", id, db, sql)
|
||||
|
||||
biz.NotEmpty(sql, "sql不能为空")
|
||||
if strings.HasPrefix(sql, "SELECT") || strings.HasPrefix(sql, "select") || strings.HasPrefix(sql, "show") || strings.HasPrefix(sql, "explain") {
|
||||
colNames, res, err := dbInstance.SelectData(sql)
|
||||
biz.ErrIsNilAppendErr(err, "查询失败: %s")
|
||||
colAndRes := make(map[string]interface{})
|
||||
colAndRes["colNames"] = colNames
|
||||
colAndRes["res"] = res
|
||||
rc.ResData = colAndRes
|
||||
} else {
|
||||
// 根据执行sql,生成执行记录
|
||||
execRecord := d.DbSqlExecApp.GenExecLog(rc.LoginAccount, id, db, sql, dbInstance)
|
||||
|
||||
rowsAffected, err := dbInstance.Exec(sql)
|
||||
execRes, err := d.DbSqlExecApp.Exec(&application.DbSqlExecReq{
|
||||
DbId: id,
|
||||
Db: db,
|
||||
Sql: sql,
|
||||
Remark: form.Remark,
|
||||
DbInstance: dbInstance,
|
||||
LoginAccount: rc.LoginAccount,
|
||||
})
|
||||
biz.ErrIsNilAppendErr(err, "执行失败: %s")
|
||||
res := make([]map[string]string, 0)
|
||||
resData := make(map[string]string)
|
||||
resData["影响条数"] = fmt.Sprintf("%d", rowsAffected)
|
||||
res = append(res, resData)
|
||||
|
||||
colAndRes := make(map[string]interface{})
|
||||
colAndRes["colNames"] = []string{"影响条数"}
|
||||
colAndRes["res"] = res
|
||||
|
||||
colAndRes["colNames"] = execRes.ColNames
|
||||
colAndRes["res"] = execRes.Res
|
||||
rc.ResData = colAndRes
|
||||
// 保存sql执行记录
|
||||
if res[0]["影响条数"] > "0" {
|
||||
execRecord.Remark = form.Remark
|
||||
d.DbSqlExecApp.Save(execRecord)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 执行sql文件
|
||||
@@ -255,7 +240,13 @@ func (d *Db) DumpSql(rc *ctx.ReqCtx) {
|
||||
countSql := fmt.Sprintf("SELECT COUNT(*) count FROM %s", table)
|
||||
_, countRes, _ := dbInstance.SelectData(countSql)
|
||||
// 查询出所有列信息总数,手动分页获取所有数据
|
||||
maCount := int(countRes[0]["count"].(int64))
|
||||
maCount := 0
|
||||
// 查询出所有列信息总数,手动分页获取所有数据
|
||||
if count64, is64 := countRes[0]["count"].(int64); is64 {
|
||||
maCount = int(count64)
|
||||
} else {
|
||||
maCount = countRes[0]["count"].(int)
|
||||
}
|
||||
// 计算需要查询的页数
|
||||
pageNum := maCount / DEFAULT_COLUMN_SIZE
|
||||
if maCount%DEFAULT_COLUMN_SIZE > 0 {
|
||||
@@ -264,9 +255,9 @@ func (d *Db) DumpSql(rc *ctx.ReqCtx) {
|
||||
|
||||
var sqlTmp string
|
||||
switch dbInstance.Type {
|
||||
case "mysql":
|
||||
case entity.DbTypeMysql:
|
||||
sqlTmp = "SELECT * FROM %s LIMIT %d, %d"
|
||||
case "postgres":
|
||||
case entity.DbTypePostgres:
|
||||
sqlTmp = "SELECT * FROM %s OFFSET %d LIMIT %d"
|
||||
}
|
||||
for index := 0; index < pageNum; index++ {
|
||||
@@ -1,8 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/db/application"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/ginx"
|
||||
)
|
||||
16
server/internal/db/application/application.go
Normal file
16
server/internal/db/application/application.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package application
|
||||
|
||||
import "mayfly-go/internal/db/infrastructure/persistence"
|
||||
|
||||
var (
|
||||
dbApp Db = newDbApp(persistence.GetDbRepo(), persistence.GetDbSqlRepo())
|
||||
dbSqlExecApp DbSqlExec = newDbSqlExecApp(persistence.GetDbSqlExecRepo())
|
||||
)
|
||||
|
||||
func GetDbApp() Db {
|
||||
return dbApp
|
||||
}
|
||||
|
||||
func GetDbSqlExecApp() DbSqlExec {
|
||||
return dbSqlExecApp
|
||||
}
|
||||
@@ -3,13 +3,12 @@ package application
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"mayfly-go/internal/constant"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/devops/infrastructure/machine"
|
||||
"mayfly-go/internal/devops/infrastructure/persistence"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/internal/db/domain/repository"
|
||||
machineapp "mayfly-go/internal/machine/application"
|
||||
"mayfly-go/internal/machine/infrastructure/machine"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/cache"
|
||||
"mayfly-go/pkg/global"
|
||||
@@ -52,16 +51,18 @@ type Db interface {
|
||||
GetDatabases(entity *entity.Db) []string
|
||||
}
|
||||
|
||||
func newDbApp(dbRepo repository.Db, dbSqlRepo repository.DbSql) Db {
|
||||
return &dbAppImpl{
|
||||
dbRepo: dbRepo,
|
||||
dbSqlRepo: dbSqlRepo,
|
||||
}
|
||||
}
|
||||
|
||||
type dbAppImpl struct {
|
||||
dbRepo repository.Db
|
||||
dbSqlRepo repository.DbSql
|
||||
}
|
||||
|
||||
var DbApp Db = &dbAppImpl{
|
||||
dbRepo: persistence.DbDao,
|
||||
dbSqlRepo: persistence.DbSqlDao,
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *dbAppImpl) GetPageList(condition *entity.Db, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return d.dbRepo.GetDbList(condition, pageParam, toEntity, orderBy...)
|
||||
@@ -232,7 +233,7 @@ var dbCache = cache.NewTimedCache(constant.DbConnExpireTime, 5*time.Second).
|
||||
|
||||
func init() {
|
||||
machine.AddCheckSshTunnelMachineUseFunc(func(machineId uint64) bool {
|
||||
// 遍历所有db连接实例,若存在redis实例使用该ssh隧道机器,则返回true,表示还在使用中...
|
||||
// 遍历所有db连接实例,若存在db实例使用该ssh隧道机器,则返回true,表示还在使用中...
|
||||
items := dbCache.Items()
|
||||
for _, v := range items {
|
||||
if v.Value.(*DbInstance).sshTunnelMachineId == machineId {
|
||||
@@ -265,7 +266,7 @@ func TestConnection(d *entity.Db) {
|
||||
func GetDbConn(d *entity.Db, db string) (*sql.DB, error) {
|
||||
// SSH Conect
|
||||
if d.EnableSshTunnel == 1 && d.SshTunnelMachineId != 0 {
|
||||
sshTunnelMachine := MachineApp.GetSshTunnelMachine(d.SshTunnelMachineId)
|
||||
sshTunnelMachine := machineapp.GetMachineApp().GetSshTunnelMachine(d.SshTunnelMachineId)
|
||||
if d.Type == entity.DbTypeMysql {
|
||||
mysql.RegisterDialContext(d.Network, func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
return sshTunnelMachine.GetDialConn("tcp", addr)
|
||||
@@ -334,46 +335,11 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
|
||||
for i, v := range vals {
|
||||
colType := colTypes[i]
|
||||
colName := colType.Name()
|
||||
// 字段类型名
|
||||
colScanType := colType.ScanType().Name()
|
||||
// 如果是第一行,则将列名加入到列信息中,由于map是无序的,所有需要返回列名的有序数组
|
||||
if isFirst {
|
||||
colNames = append(colNames, colName)
|
||||
}
|
||||
if v == nil {
|
||||
rowData[colName] = nil
|
||||
continue
|
||||
}
|
||||
// 这里把[]byte数据转成string
|
||||
stringV := string(v)
|
||||
if stringV == "" {
|
||||
rowData[colName] = stringV
|
||||
continue
|
||||
}
|
||||
if strings.Contains(colScanType, "int") || strings.Contains(colScanType, "Int") {
|
||||
intV, _ := strconv.Atoi(stringV)
|
||||
switch colType.ScanType().Kind() {
|
||||
case reflect.Int8:
|
||||
rowData[colName] = int8(intV)
|
||||
case reflect.Uint8:
|
||||
rowData[colName] = uint8(intV)
|
||||
case reflect.Int64:
|
||||
rowData[colName] = int64(intV)
|
||||
case reflect.Uint64:
|
||||
rowData[colName] = uint64(intV)
|
||||
case reflect.Uint:
|
||||
rowData[colName] = uint(intV)
|
||||
default:
|
||||
rowData[colName] = intV
|
||||
}
|
||||
continue
|
||||
}
|
||||
if strings.Contains(colScanType, "float") || strings.Contains(colScanType, "Float") {
|
||||
floatV, _ := strconv.ParseFloat(stringV, 64)
|
||||
rowData[colName] = floatV
|
||||
} else {
|
||||
rowData[colName] = stringV
|
||||
}
|
||||
rowData[colName] = valueConvert(v, colType)
|
||||
}
|
||||
// 放入结果集
|
||||
result = append(result, rowData)
|
||||
@@ -382,6 +348,55 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
|
||||
return colNames, result, nil
|
||||
}
|
||||
|
||||
// 将查询的值转为对应列类型的实际值,不全部转为字符串
|
||||
func valueConvert(data []byte, colType *sql.ColumnType) interface{} {
|
||||
if data == nil {
|
||||
return nil
|
||||
}
|
||||
// 列的数据库类型名
|
||||
colDatabaseTypeName := strings.ToLower(colType.DatabaseTypeName())
|
||||
|
||||
// 如果类型是bit,则直接返回第一个字节即可
|
||||
if strings.Contains(colDatabaseTypeName, "bit") {
|
||||
return data[0]
|
||||
}
|
||||
|
||||
// 这里把[]byte数据转成string
|
||||
stringV := string(data)
|
||||
if stringV == "" {
|
||||
return ""
|
||||
}
|
||||
colScanType := strings.ToLower(colType.ScanType().Name())
|
||||
|
||||
if strings.Contains(colScanType, "int") {
|
||||
// 如果长度超过16位,则返回字符串,因为前端js长度大于16会丢失精度
|
||||
if len(stringV) > 16 {
|
||||
return stringV
|
||||
}
|
||||
intV, _ := strconv.Atoi(stringV)
|
||||
switch colType.ScanType().Kind() {
|
||||
case reflect.Int8:
|
||||
return int8(intV)
|
||||
case reflect.Uint8:
|
||||
return uint8(intV)
|
||||
case reflect.Int64:
|
||||
return int64(intV)
|
||||
case reflect.Uint64:
|
||||
return uint64(intV)
|
||||
case reflect.Uint:
|
||||
return uint(intV)
|
||||
default:
|
||||
return intV
|
||||
}
|
||||
}
|
||||
if strings.Contains(colScanType, "float") {
|
||||
floatV, _ := strconv.ParseFloat(stringV, 64)
|
||||
return floatV
|
||||
}
|
||||
|
||||
return stringV
|
||||
}
|
||||
|
||||
type PqSqlDialer struct {
|
||||
sshTunnelMachine *machine.SshTunnelMachine
|
||||
}
|
||||
@@ -410,14 +425,6 @@ type DbInstance struct {
|
||||
// 执行查询语句
|
||||
// 依次返回 列名数组,结果map,错误
|
||||
func (d *DbInstance) SelectData(execSql string) ([]string, []map[string]interface{}, error) {
|
||||
execSql = strings.Trim(execSql, " ")
|
||||
isSelect := strings.HasPrefix(execSql, "SELECT") || strings.HasPrefix(execSql, "select")
|
||||
isShow := strings.HasPrefix(execSql, "show")
|
||||
isExplain := strings.HasPrefix(execSql, "explain")
|
||||
|
||||
if !isSelect && !isShow && !isExplain {
|
||||
return nil, nil, errors.New("该sql非查询语句")
|
||||
}
|
||||
return SelectDataByDb(d.db, execSql)
|
||||
}
|
||||
|
||||
@@ -558,8 +565,14 @@ func (mm *MysqlMetadata) GetColumns(tableNames ...string) []map[string]interface
|
||||
if len(tableNames) > 1 {
|
||||
countSql := fmt.Sprintf(MYSQL_COLOUMN_MA_COUNT, tableName)
|
||||
_, countRes, _ := mm.di.SelectData(countSql)
|
||||
maCount := 0
|
||||
// 查询出所有列信息总数,手动分页获取所有数据
|
||||
maCount := int(countRes[0]["maNum"].(int64))
|
||||
if count64, is64 := countRes[0]["maNum"].(int64); is64 {
|
||||
maCount = int(count64)
|
||||
} else {
|
||||
maCount = countRes[0]["maNum"].(int)
|
||||
}
|
||||
|
||||
// 计算需要查询的页数
|
||||
pageNum = maCount / DEFAULT_COLUMN_SIZE
|
||||
if maCount%DEFAULT_COLUMN_SIZE > 0 {
|
||||
@@ -590,7 +603,7 @@ func (mm *MysqlMetadata) GetTableInfos() []map[string]interface{} {
|
||||
|
||||
// 获取表索引信息
|
||||
func (mm *MysqlMetadata) GetTableIndex(tableName string) []map[string]interface{} {
|
||||
_, res, _ := mm.di.SelectData(MYSQL_INDEX_INFO)
|
||||
_, res, _ := mm.di.SelectData(fmt.Sprintf(MYSQL_INDEX_INFO, tableName))
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -672,8 +685,13 @@ func (pm *PgsqlMetadata) GetColumns(tableNames ...string) []map[string]interface
|
||||
if len(tableNames) > 1 {
|
||||
countSql := fmt.Sprintf(PGSQL_COLUMN_MA_COUNT, tableName)
|
||||
_, countRes, _ := pm.di.SelectData(countSql)
|
||||
maCount := 0
|
||||
// 查询出所有列信息总数,手动分页获取所有数据
|
||||
maCount := int(countRes[0]["maNum"].(int64))
|
||||
if count64, is64 := countRes[0]["maNum"].(int64); is64 {
|
||||
maCount = int(count64)
|
||||
} else {
|
||||
maCount = countRes[0]["maNum"].(int)
|
||||
}
|
||||
// 计算需要查询的页数
|
||||
pageNum = maCount / DEFAULT_COLUMN_SIZE
|
||||
if maCount%DEFAULT_COLUMN_SIZE > 0 {
|
||||
@@ -704,7 +722,7 @@ func (pm *PgsqlMetadata) GetTableInfos() []map[string]interface{} {
|
||||
|
||||
// 获取表索引信息
|
||||
func (pm *PgsqlMetadata) GetTableIndex(tableName string) []map[string]interface{} {
|
||||
_, res, _ := pm.di.SelectData(PGSQL_INDEX_INFO)
|
||||
_, res, _ := pm.di.SelectData(fmt.Sprintf(PGSQL_INDEX_INFO, tableName))
|
||||
return res
|
||||
}
|
||||
|
||||
200
server/internal/db/application/db_sql_exec.go
Normal file
200
server/internal/db/application/db_sql_exec.go
Normal file
@@ -0,0 +1,200 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/internal/db/domain/repository"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/model"
|
||||
"strings"
|
||||
|
||||
"github.com/xwb1989/sqlparser"
|
||||
)
|
||||
|
||||
type DbSqlExecReq struct {
|
||||
DbId uint64
|
||||
Db string
|
||||
Sql string
|
||||
Remark string
|
||||
LoginAccount *model.LoginAccount
|
||||
DbInstance *DbInstance
|
||||
}
|
||||
|
||||
type DbSqlExecRes struct {
|
||||
ColNames []string
|
||||
Res []map[string]interface{}
|
||||
}
|
||||
|
||||
type DbSqlExec interface {
|
||||
// 执行sql
|
||||
Exec(execSqlReq *DbSqlExecReq) (*DbSqlExecRes, error)
|
||||
|
||||
// 根据条件删除sql执行记录
|
||||
DeleteBy(condition *entity.DbSqlExec)
|
||||
|
||||
// 分页获取
|
||||
GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
|
||||
}
|
||||
|
||||
func newDbSqlExecApp(dbExecSqlRepo repository.DbSqlExec) DbSqlExec {
|
||||
return &dbSqlExecAppImpl{
|
||||
dbSqlExecRepo: dbExecSqlRepo,
|
||||
}
|
||||
}
|
||||
|
||||
type dbSqlExecAppImpl struct {
|
||||
dbSqlExecRepo repository.DbSqlExec
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) Exec(execSqlReq *DbSqlExecReq) (*DbSqlExecRes, error) {
|
||||
sql := execSqlReq.Sql
|
||||
loginAccount := execSqlReq.LoginAccount
|
||||
|
||||
// 如果是pgsql并且为查询语句,则直接返回,sqlparser不支持解析pgsql select语句
|
||||
if execSqlReq.DbInstance.Type == entity.DbTypePostgres && (strings.HasPrefix(sql, "SELECT") || strings.HasPrefix(sql, "select")) {
|
||||
return doSelect(nil, execSqlReq, nil)
|
||||
}
|
||||
|
||||
stmt, err := sqlparser.Parse(sql)
|
||||
if err != nil {
|
||||
global.Log.Error("sql解析失败: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dbSqlExecRecord := new(entity.DbSqlExec)
|
||||
dbSqlExecRecord.DbId = execSqlReq.DbId
|
||||
dbSqlExecRecord.Db = execSqlReq.Db
|
||||
dbSqlExecRecord.Sql = sql
|
||||
dbSqlExecRecord.Remark = execSqlReq.Remark
|
||||
dbSqlExecRecord.SetBaseInfo(loginAccount)
|
||||
|
||||
var execRes *DbSqlExecRes
|
||||
isSelect := false
|
||||
switch stmt := stmt.(type) {
|
||||
case *sqlparser.Select:
|
||||
isSelect = true
|
||||
execRes, err = doSelect(stmt, execSqlReq, dbSqlExecRecord)
|
||||
case *sqlparser.Show:
|
||||
isSelect = true
|
||||
execRes, err = doSelect(nil, execSqlReq, dbSqlExecRecord)
|
||||
case *sqlparser.OtherRead:
|
||||
isSelect = true
|
||||
execRes, err = doSelect(nil, execSqlReq, dbSqlExecRecord)
|
||||
case *sqlparser.Update:
|
||||
execRes, err = doUpdate(stmt, execSqlReq, dbSqlExecRecord)
|
||||
case *sqlparser.Delete:
|
||||
execRes, err = doDelete(stmt, execSqlReq, dbSqlExecRecord)
|
||||
case *sqlparser.Insert:
|
||||
execRes, err = doInsert(stmt, execSqlReq, dbSqlExecRecord)
|
||||
default:
|
||||
execRes, err = doExec(execSqlReq.Sql, execSqlReq.DbInstance)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !isSelect {
|
||||
// 保存执行记录
|
||||
d.dbSqlExecRepo.Insert(dbSqlExecRecord)
|
||||
}
|
||||
return execRes, nil
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) DeleteBy(condition *entity.DbSqlExec) {
|
||||
d.dbSqlExecRepo.DeleteBy(condition)
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return d.dbSqlExecRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func doSelect(selectStmt *sqlparser.Select, execSqlReq *DbSqlExecReq, dbSqlExec *entity.DbSqlExec) (*DbSqlExecRes, error) {
|
||||
dbInstance := execSqlReq.DbInstance
|
||||
sql := execSqlReq.Sql
|
||||
colNames, res, err := dbInstance.SelectData(sql)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DbSqlExecRes{
|
||||
ColNames: colNames,
|
||||
Res: res,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func doUpdate(update *sqlparser.Update, execSqlReq *DbSqlExecReq, dbSqlExec *entity.DbSqlExec) (*DbSqlExecRes, error) {
|
||||
dbInstance := execSqlReq.DbInstance
|
||||
|
||||
tableStr := sqlparser.String(update.TableExprs)
|
||||
// 可能使用别名,故空格切割
|
||||
tableName := strings.Split(tableStr, " ")[0]
|
||||
where := sqlparser.String(update.Where)
|
||||
|
||||
updateExprs := update.Exprs
|
||||
updateColumns := make([]string, 0)
|
||||
for _, v := range updateExprs {
|
||||
updateColumns = append(updateColumns, v.Name.Name.String())
|
||||
}
|
||||
|
||||
// 获取表主键列名,排除使用别名
|
||||
primaryKey := dbInstance.GetMeta().GetPrimaryKey(tableName)
|
||||
|
||||
updateColumnsAndPrimaryKey := strings.Join(updateColumns, ",") + "," + primaryKey
|
||||
// 查询要更新字段数据的旧值,以及主键值
|
||||
selectSql := fmt.Sprintf("SELECT %s FROM %s %s LIMIT 200", updateColumnsAndPrimaryKey, tableStr, where)
|
||||
_, res, _ := dbInstance.SelectData(selectSql)
|
||||
|
||||
bytes, _ := json.Marshal(res)
|
||||
dbSqlExec.OldValue = string(bytes)
|
||||
dbSqlExec.Table = tableName
|
||||
dbSqlExec.Type = entity.DbSqlExecTypeUpdate
|
||||
|
||||
return doExec(execSqlReq.Sql, dbInstance)
|
||||
}
|
||||
|
||||
func doDelete(delete *sqlparser.Delete, execSqlReq *DbSqlExecReq, dbSqlExec *entity.DbSqlExec) (*DbSqlExecRes, error) {
|
||||
dbInstance := execSqlReq.DbInstance
|
||||
|
||||
tableStr := sqlparser.String(delete.TableExprs)
|
||||
// 可能使用别名,故空格切割
|
||||
table := strings.Split(tableStr, " ")[0]
|
||||
where := sqlparser.String(delete.Where)
|
||||
|
||||
// 查询删除数据
|
||||
selectSql := fmt.Sprintf("SELECT * FROM %s %s LIMIT 200", tableStr, where)
|
||||
_, res, _ := dbInstance.SelectData(selectSql)
|
||||
|
||||
bytes, _ := json.Marshal(res)
|
||||
dbSqlExec.OldValue = string(bytes)
|
||||
dbSqlExec.Table = table
|
||||
dbSqlExec.Type = entity.DbSqlExecTypeDelete
|
||||
|
||||
return doExec(execSqlReq.Sql, dbInstance)
|
||||
}
|
||||
|
||||
func doInsert(insert *sqlparser.Insert, execSqlReq *DbSqlExecReq, dbSqlExec *entity.DbSqlExec) (*DbSqlExecRes, error) {
|
||||
tableStr := sqlparser.String(insert.Table)
|
||||
// 可能使用别名,故空格切割
|
||||
table := strings.Split(tableStr, " ")[0]
|
||||
dbSqlExec.Table = table
|
||||
dbSqlExec.Type = entity.DbSqlExecTypeInsert
|
||||
|
||||
return doExec(execSqlReq.Sql, execSqlReq.DbInstance)
|
||||
}
|
||||
|
||||
func doExec(sql string, dbInstance *DbInstance) (*DbSqlExecRes, error) {
|
||||
rowsAffected, err := dbInstance.Exec(sql)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := make([]map[string]interface{}, 0)
|
||||
resData := make(map[string]interface{})
|
||||
resData["影响条数"] = rowsAffected
|
||||
res = append(res, resData)
|
||||
|
||||
return &DbSqlExecRes{
|
||||
ColNames: []string{"影响条数"},
|
||||
Res: res,
|
||||
}, nil
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package repository
|
||||
|
||||
import "mayfly-go/internal/devops/domain/entity"
|
||||
import "mayfly-go/internal/db/domain/entity"
|
||||
|
||||
type DbSql interface {
|
||||
DeleteBy(condition *entity.DbSql)
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -2,18 +2,20 @@ package persistence
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/internal/db/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type dbRepo struct{}
|
||||
type dbRepoImpl struct{}
|
||||
|
||||
var DbDao repository.Db = &dbRepo{}
|
||||
func newDbRepo() repository.Db {
|
||||
return new(dbRepoImpl)
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *dbRepo) GetDbList(condition *entity.Db, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
func (d *dbRepoImpl) GetDbList(condition *entity.Db, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
sql := "SELECT d.* FROM t_db d JOIN t_project_member pm ON d.project_id = pm.project_id WHERE 1 = 1 "
|
||||
if condition.CreatorId != 0 {
|
||||
// 使用创建者id模拟项目成员id
|
||||
@@ -35,17 +37,17 @@ func (d *dbRepo) GetDbList(condition *entity.Db, pageParam *model.PageParam, toE
|
||||
return model.GetPageBySql(sql, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (d *dbRepo) Count(condition *entity.Db) int64 {
|
||||
func (d *dbRepoImpl) Count(condition *entity.Db) int64 {
|
||||
return model.CountBy(condition)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (d *dbRepo) GetDb(condition *entity.Db, cols ...string) error {
|
||||
func (d *dbRepoImpl) GetDb(condition *entity.Db, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (d *dbRepo) GetById(id uint64, cols ...string) *entity.Db {
|
||||
func (d *dbRepoImpl) GetById(id uint64, cols ...string) *entity.Db {
|
||||
db := new(entity.Db)
|
||||
if err := model.GetById(db, id, cols...); err != nil {
|
||||
return nil
|
||||
@@ -54,14 +56,14 @@ func (d *dbRepo) GetById(id uint64, cols ...string) *entity.Db {
|
||||
return db
|
||||
}
|
||||
|
||||
func (d *dbRepo) Insert(db *entity.Db) {
|
||||
func (d *dbRepoImpl) Insert(db *entity.Db) {
|
||||
biz.ErrIsNil(model.Insert(db), "新增数据库信息失败")
|
||||
}
|
||||
|
||||
func (d *dbRepo) Update(db *entity.Db) {
|
||||
func (d *dbRepoImpl) Update(db *entity.Db) {
|
||||
biz.ErrIsNil(model.UpdateById(db), "更新数据库信息失败")
|
||||
}
|
||||
|
||||
func (d *dbRepo) Delete(id uint64) {
|
||||
func (d *dbRepoImpl) Delete(id uint64) {
|
||||
model.DeleteById(new(entity.Db), id)
|
||||
}
|
||||
19
server/internal/db/infrastructure/persistence/db_sql.go
Normal file
19
server/internal/db/infrastructure/persistence/db_sql.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/internal/db/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type dbSqlRepoImpl struct{}
|
||||
|
||||
func newDbSqlRepo() repository.DbSql {
|
||||
return new(dbSqlRepoImpl)
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *dbSqlRepoImpl) DeleteBy(condition *entity.DbSql) {
|
||||
biz.ErrIsNil(model.DeleteByCondition(condition), "删除sql失败")
|
||||
}
|
||||
27
server/internal/db/infrastructure/persistence/db_sql_exec.go
Normal file
27
server/internal/db/infrastructure/persistence/db_sql_exec.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
"mayfly-go/internal/db/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type dbSqlExecRepoImpl struct{}
|
||||
|
||||
func newDbSqlExecRepo() repository.DbSqlExec {
|
||||
return new(dbSqlExecRepoImpl)
|
||||
}
|
||||
|
||||
func (d *dbSqlExecRepoImpl) Insert(dse *entity.DbSqlExec) {
|
||||
model.Insert(dse)
|
||||
}
|
||||
|
||||
func (d *dbSqlExecRepoImpl) DeleteBy(condition *entity.DbSqlExec) {
|
||||
biz.ErrIsNil(model.DeleteByCondition(condition), "删除sql执行记录失败")
|
||||
}
|
||||
|
||||
// 分页获取
|
||||
func (d *dbSqlExecRepoImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
21
server/internal/db/infrastructure/persistence/persistence.go
Normal file
21
server/internal/db/infrastructure/persistence/persistence.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package persistence
|
||||
|
||||
import "mayfly-go/internal/db/domain/repository"
|
||||
|
||||
var (
|
||||
dbRepo repository.Db = newDbRepo()
|
||||
dbSqlRepo repository.DbSql = newDbSqlRepo()
|
||||
dbSqlExecRepo repository.DbSqlExec = newDbSqlExecRepo()
|
||||
)
|
||||
|
||||
func GetDbRepo() repository.Db {
|
||||
return dbRepo
|
||||
}
|
||||
|
||||
func GetDbSqlRepo() repository.DbSql {
|
||||
return dbSqlRepo
|
||||
}
|
||||
|
||||
func GetDbSqlExecRepo() repository.DbSqlExec {
|
||||
return dbSqlExecRepo
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/api"
|
||||
"mayfly-go/internal/devops/application"
|
||||
sysApplication "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/internal/db/api"
|
||||
"mayfly-go/internal/db/application"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
sysapp "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -13,10 +14,10 @@ func InitDbRouter(router *gin.RouterGroup) {
|
||||
db := router.Group("dbs")
|
||||
{
|
||||
d := &api.Db{
|
||||
DbApp: application.DbApp,
|
||||
DbSqlExecApp: application.DbSqlExecApp,
|
||||
MsgApp: sysApplication.MsgApp,
|
||||
ProjectApp: application.ProjectApp,
|
||||
DbApp: application.GetDbApp(),
|
||||
DbSqlExecApp: application.GetDbSqlExecApp(),
|
||||
MsgApp: sysapp.GetMsgApp(),
|
||||
ProjectApp: projectapp.GetProjectApp(),
|
||||
}
|
||||
// 获取所有数据库列表
|
||||
db.GET("", func(c *gin.Context) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/api"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/db/api"
|
||||
"mayfly-go/internal/db/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -12,7 +12,7 @@ func InitDbSqlExecRouter(router *gin.RouterGroup) {
|
||||
db := router.Group("/dbs/:dbId/sql-execs")
|
||||
{
|
||||
d := &api.DbSqlExec{
|
||||
DbSqlExecApp: application.DbSqlExecApp,
|
||||
DbSqlExecApp: application.GetDbSqlExecApp(),
|
||||
}
|
||||
// 获取所有数据库sql执行记录列表
|
||||
db.GET("", func(c *gin.Context) {
|
||||
8
server/internal/db/router/router.go
Normal file
8
server/internal/db/router/router.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package router
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func Init(router *gin.RouterGroup) {
|
||||
InitDbRouter(router)
|
||||
InitDbSqlExecRouter(router)
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/devops/infrastructure/persistence"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/model"
|
||||
"strings"
|
||||
|
||||
"github.com/xwb1989/sqlparser"
|
||||
)
|
||||
|
||||
type DbSqlExec interface {
|
||||
// 生成sql执行记录
|
||||
GenExecLog(loginAccount *model.LoginAccount, dbId uint64, db string, sql string, dbInstance *DbInstance) *entity.DbSqlExec
|
||||
|
||||
// 保存sql执行记录
|
||||
Save(*entity.DbSqlExec)
|
||||
|
||||
// 根据条件删除sql执行记录
|
||||
DeleteBy(condition *entity.DbSqlExec)
|
||||
|
||||
// 分页获取
|
||||
GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
|
||||
}
|
||||
|
||||
type dbSqlExecAppImpl struct {
|
||||
dbSqlExecRepo repository.DbSqlExec
|
||||
}
|
||||
|
||||
var DbSqlExecApp DbSqlExec = &dbSqlExecAppImpl{
|
||||
dbSqlExecRepo: persistence.DbSqlExecDao,
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) GenExecLog(loginAccount *model.LoginAccount, dbId uint64, db string, sql string, dbInstance *DbInstance) *entity.DbSqlExec {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
global.Log.Error("生成sql执行记录失败", err)
|
||||
}
|
||||
}()
|
||||
stmt, err := sqlparser.Parse(sql)
|
||||
if err != nil {
|
||||
global.Log.Error("记录数据库sql执行记录失败", err)
|
||||
}
|
||||
|
||||
dbSqlExecRecord := new(entity.DbSqlExec)
|
||||
dbSqlExecRecord.DbId = dbId
|
||||
dbSqlExecRecord.Db = db
|
||||
dbSqlExecRecord.Sql = sql
|
||||
dbSqlExecRecord.SetBaseInfo(loginAccount)
|
||||
|
||||
switch stmt := stmt.(type) {
|
||||
case *sqlparser.Update:
|
||||
doUpdate(stmt, dbInstance, dbSqlExecRecord)
|
||||
case *sqlparser.Delete:
|
||||
doDelete(stmt, dbInstance, dbSqlExecRecord)
|
||||
case *sqlparser.Insert:
|
||||
doInsert(stmt, dbSqlExecRecord)
|
||||
}
|
||||
|
||||
return dbSqlExecRecord
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) Save(dse *entity.DbSqlExec) {
|
||||
d.dbSqlExecRepo.Insert(dse)
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) DeleteBy(condition *entity.DbSqlExec) {
|
||||
d.dbSqlExecRepo.DeleteBy(condition)
|
||||
}
|
||||
|
||||
func (d *dbSqlExecAppImpl) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return d.dbSqlExecRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func doUpdate(update *sqlparser.Update, dbInstance *DbInstance, dbSqlExec *entity.DbSqlExec) {
|
||||
tableStr := sqlparser.String(update.TableExprs)
|
||||
// 可能使用别名,故空格切割
|
||||
tableName := strings.Split(tableStr, " ")[0]
|
||||
where := sqlparser.String(update.Where)
|
||||
|
||||
updateExprs := update.Exprs
|
||||
updateColumns := make([]string, 0)
|
||||
for _, v := range updateExprs {
|
||||
updateColumns = append(updateColumns, v.Name.Name.String())
|
||||
}
|
||||
|
||||
// 获取表主键列名,排除使用别名
|
||||
primaryKey := dbInstance.GetMeta().GetPrimaryKey(tableName)
|
||||
|
||||
updateColumnsAndPrimaryKey := strings.Join(updateColumns, ",") + "," + primaryKey
|
||||
// 查询要更新字段数据的旧值,以及主键值
|
||||
selectSql := fmt.Sprintf("SELECT %s FROM %s %s LIMIT 200", updateColumnsAndPrimaryKey, tableStr, where)
|
||||
_, res, _ := dbInstance.SelectData(selectSql)
|
||||
|
||||
bytes, _ := json.Marshal(res)
|
||||
dbSqlExec.OldValue = string(bytes)
|
||||
dbSqlExec.Table = tableName
|
||||
dbSqlExec.Type = entity.DbSqlExecTypeUpdate
|
||||
}
|
||||
|
||||
func doDelete(delete *sqlparser.Delete, dbInstance *DbInstance, dbSqlExec *entity.DbSqlExec) {
|
||||
tableStr := sqlparser.String(delete.TableExprs)
|
||||
// 可能使用别名,故空格切割
|
||||
table := strings.Split(tableStr, " ")[0]
|
||||
where := sqlparser.String(delete.Where)
|
||||
|
||||
// 查询删除数据
|
||||
selectSql := fmt.Sprintf("SELECT * FROM %s %s LIMIT 200", tableStr, where)
|
||||
_, res, _ := dbInstance.SelectData(selectSql)
|
||||
|
||||
bytes, _ := json.Marshal(res)
|
||||
dbSqlExec.OldValue = string(bytes)
|
||||
dbSqlExec.Table = table
|
||||
dbSqlExec.Type = entity.DbSqlExecTypeDelete
|
||||
}
|
||||
|
||||
func doInsert(insert *sqlparser.Insert, dbSqlExec *entity.DbSqlExec) {
|
||||
tableStr := sqlparser.String(insert.Table)
|
||||
// 可能使用别名,故空格切割
|
||||
table := strings.Split(tableStr, " ")[0]
|
||||
dbSqlExec.Table = table
|
||||
dbSqlExec.Type = entity.DbSqlExecTypeInsert
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type dbSqlExecRepo struct{}
|
||||
|
||||
var DbSqlExecDao repository.DbSqlExec = &dbSqlExecRepo{}
|
||||
|
||||
func (d *dbSqlExecRepo) Insert(dse *entity.DbSqlExec) {
|
||||
model.Insert(dse)
|
||||
}
|
||||
|
||||
func (d *dbSqlExecRepo) DeleteBy(condition *entity.DbSqlExec) {
|
||||
biz.ErrIsNil(model.DeleteByCondition(condition), "删除sql执行记录失败")
|
||||
}
|
||||
|
||||
// 分页获取
|
||||
func (d *dbSqlExecRepo) GetPageList(condition *entity.DbSqlExec, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type dbSqlRepo struct{}
|
||||
|
||||
var DbSqlDao repository.DbSql = &dbSqlRepo{}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *dbSqlRepo) DeleteBy(condition *entity.DbSql) {
|
||||
biz.ErrIsNil(model.DeleteByCondition(condition), "删除sql失败")
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type machineFileRepo struct{}
|
||||
|
||||
var MachineFileDao repository.MachineFile = &machineFileRepo{}
|
||||
|
||||
// 分页获取机器文件信息列表
|
||||
func (m *machineFileRepo) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (m *machineFileRepo) GetMachineFile(condition *entity.MachineFile, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineFileRepo) GetById(id uint64, cols ...string) *entity.MachineFile {
|
||||
ms := new(entity.MachineFile)
|
||||
if err := model.GetById(ms, id, cols...); err != nil {
|
||||
return nil
|
||||
|
||||
}
|
||||
return ms
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineFileRepo) Delete(id uint64) {
|
||||
biz.ErrIsNil(model.DeleteById(new(entity.MachineFile), id), "删除失败")
|
||||
}
|
||||
|
||||
func (m *machineFileRepo) Create(entity *entity.MachineFile) {
|
||||
model.Insert(entity)
|
||||
}
|
||||
|
||||
func (m *machineFileRepo) UpdateById(entity *entity.MachineFile) {
|
||||
model.UpdateById(entity)
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type machineScriptRepo struct{}
|
||||
|
||||
var MachineScriptDao repository.MachineScript = &machineScriptRepo{}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineScriptRepo) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (m *machineScriptRepo) GetMachineScript(condition *entity.MachineScript, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptRepo) GetById(id uint64, cols ...string) *entity.MachineScript {
|
||||
ms := new(entity.MachineScript)
|
||||
if err := model.GetById(ms, id, cols...); err != nil {
|
||||
return nil
|
||||
|
||||
}
|
||||
return ms
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptRepo) Delete(id uint64) {
|
||||
biz.ErrIsNil(model.DeleteById(new(entity.MachineScript), id), "删除失败")
|
||||
}
|
||||
|
||||
func (m *machineScriptRepo) Create(entity *entity.MachineScript) {
|
||||
model.Insert(entity)
|
||||
}
|
||||
|
||||
func (m *machineScriptRepo) UpdateById(entity *entity.MachineScript) {
|
||||
model.UpdateById(entity)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type projectEnvRepo struct{}
|
||||
|
||||
var ProjectEnvRepo repository.ProjectEnv = &projectEnvRepo{}
|
||||
|
||||
func (p *projectEnvRepo) ListEnv(condition *entity.ProjectEnv, toEntity interface{}, orderBy ...string) {
|
||||
model.ListByOrder(condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func (p *projectEnvRepo) Save(entity *entity.ProjectEnv) {
|
||||
biz.ErrIsNilAppendErr(model.Insert(entity), "保存环境失败:%s")
|
||||
}
|
||||
|
||||
func (p *projectEnvRepo) DeleteEnvs(projectId uint64) {
|
||||
model.DeleteByCondition(&entity.ProjectEnv{ProjectId: projectId})
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type projectMemeberRepo struct{}
|
||||
|
||||
var ProjectMemberRepo repository.ProjectMemeber = &projectMemeberRepo{}
|
||||
|
||||
func (p *projectMemeberRepo) ListMemeber(condition *entity.ProjectMember, toEntity interface{}, orderBy ...string) {
|
||||
model.ListByOrder(condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func (p *projectMemeberRepo) Save(pm *entity.ProjectMember) {
|
||||
biz.ErrIsNilAppendErr(model.Insert(pm), "保存项目成员失败:%s")
|
||||
}
|
||||
|
||||
func (p *projectMemeberRepo) GetPageList(condition *entity.ProjectMember, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func (p *projectMemeberRepo) DeleteByPidMid(projectId, accountId uint64) {
|
||||
model.DeleteByCondition(&entity.ProjectMember{ProjectId: projectId, AccountId: accountId})
|
||||
}
|
||||
|
||||
func (p *projectMemeberRepo) DeleteMems(projectId uint64) {
|
||||
model.DeleteByCondition(&entity.ProjectMember{ProjectId: projectId})
|
||||
}
|
||||
|
||||
func (p *projectMemeberRepo) IsExist(projectId, accountId uint64) bool {
|
||||
return model.CountBy(&entity.ProjectMember{ProjectId: projectId, AccountId: accountId}) > 0
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type projectRepo struct{}
|
||||
|
||||
var ProjectRepo repository.Project = &projectRepo{}
|
||||
|
||||
func (p *projectRepo) GetPageList(condition *entity.Project, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
func (p *projectRepo) Count(condition *entity.Project) int64 {
|
||||
return model.CountBy(condition)
|
||||
}
|
||||
|
||||
func (p *projectRepo) GetByIdIn(ids []uint64, toEntity interface{}, orderBy ...string) {
|
||||
model.GetByIdIn(new(entity.Project), toEntity, ids, orderBy...)
|
||||
}
|
||||
|
||||
func (p *projectRepo) Save(project *entity.Project) {
|
||||
biz.ErrIsNil(model.Insert(project), "保存项目失败")
|
||||
}
|
||||
|
||||
func (p *projectRepo) Update(project *entity.Project) {
|
||||
biz.ErrIsNil(model.UpdateById(project), "更新项目信息")
|
||||
}
|
||||
|
||||
func (p *projectRepo) Delete(id uint64) {
|
||||
model.DeleteById(new(entity.Project), id)
|
||||
}
|
||||
@@ -3,11 +3,12 @@ package api
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"mayfly-go/internal/devops/api/form"
|
||||
"mayfly-go/internal/devops/api/vo"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/infrastructure/machine"
|
||||
"mayfly-go/internal/machine/api/form"
|
||||
"mayfly-go/internal/machine/api/vo"
|
||||
"mayfly-go/internal/machine/application"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/infrastructure/machine"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/config"
|
||||
"mayfly-go/pkg/ctx"
|
||||
@@ -18,7 +19,6 @@ import (
|
||||
"path"
|
||||
"sort"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
type Machine struct {
|
||||
MachineApp application.Machine
|
||||
ProjectApp application.Project
|
||||
ProjectApp projectapp.Project
|
||||
}
|
||||
|
||||
func (m *Machine) Machines(rc *ctx.ReqCtx) {
|
||||
@@ -175,8 +175,6 @@ func (m *Machine) WsSSH(g *gin.Context) {
|
||||
|
||||
var recorder *machine.Recorder
|
||||
if cli.GetMachine().EnableRecorder == 1 {
|
||||
mask := syscall.Umask(0)
|
||||
defer syscall.Umask(mask)
|
||||
now := time.Now()
|
||||
// 回放文件路径为: 基础配置路径/机器id/操作日期/操作者账号/操作时间.cast
|
||||
recPath := fmt.Sprintf("%s/%d/%s/%s", config.Conf.Server.GetMachineRecPath(), cli.GetMachine().Id, now.Format("20060102"), rc.LoginAccount.Username)
|
||||
@@ -4,16 +4,17 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"mayfly-go/internal/devops/api/form"
|
||||
"mayfly-go/internal/devops/api/vo"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/api/form"
|
||||
"mayfly-go/internal/machine/api/vo"
|
||||
"mayfly-go/internal/machine/application"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
sysApplication "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/ginx"
|
||||
"mayfly-go/pkg/utils"
|
||||
"mayfly-go/pkg/ws"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -121,8 +122,10 @@ func (m *MachineFile) GetDirEntry(rc *ctx.ReqCtx) {
|
||||
Path: readPath + fi.Name(),
|
||||
Type: getFileType(fi.Mode()),
|
||||
Mode: fi.Mode().String(),
|
||||
ModTime: fi.ModTime().Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
sort.Sort(vo.MachineFileInfos(fisVO))
|
||||
rc.ResData = fisVO
|
||||
rc.ReqParam = fmt.Sprintf("path: %s", readPath)
|
||||
}
|
||||
@@ -2,10 +2,11 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mayfly-go/internal/devops/api/form"
|
||||
"mayfly-go/internal/devops/api/vo"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/api/form"
|
||||
"mayfly-go/internal/machine/api/vo"
|
||||
"mayfly-go/internal/machine/application"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/ginx"
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
type MachineScript struct {
|
||||
MachineScriptApp application.MachineScript
|
||||
MachineApp application.Machine
|
||||
ProjectApp application.Project
|
||||
ProjectApp projectapp.Project
|
||||
}
|
||||
|
||||
func (m *MachineScript) MachineScripts(rc *ctx.ReqCtx) {
|
||||
@@ -61,9 +61,18 @@ type MachineFileInfo struct {
|
||||
Size int64 `json:"size"`
|
||||
Type string `json:"type"`
|
||||
Mode string `json:"mode"`
|
||||
ModTime string `json:"modTime"`
|
||||
}
|
||||
|
||||
type RoleVO struct {
|
||||
Id *int64
|
||||
Name *string
|
||||
type MachineFileInfos []MachineFileInfo
|
||||
|
||||
func (s MachineFileInfos) Len() int { return len(s) }
|
||||
|
||||
func (s MachineFileInfos) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
func (s MachineFileInfos) Less(i, j int) bool {
|
||||
if s[i].Type != s[j].Type {
|
||||
return s[i].Type > s[j].Type
|
||||
}
|
||||
return s[i].Name < s[j].Name
|
||||
}
|
||||
21
server/internal/machine/application/application.go
Normal file
21
server/internal/machine/application/application.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package application
|
||||
|
||||
import "mayfly-go/internal/machine/infrastructure/persistence"
|
||||
|
||||
var (
|
||||
machineApp Machine = newMachineApp(persistence.GetMachineRepo())
|
||||
machineFileApp MachineFile = newMachineFileApp(persistence.GetMachineFileRepo(), persistence.GetMachineRepo())
|
||||
machineScriptApp MachineScript = newMachineScriptApp(persistence.GetMachineScriptRepo(), persistence.GetMachineRepo())
|
||||
)
|
||||
|
||||
func GetMachineApp() Machine {
|
||||
return machineApp
|
||||
}
|
||||
|
||||
func GetMachineFileApp() MachineFile {
|
||||
return machineFileApp
|
||||
}
|
||||
|
||||
func GetMachineScriptApp() MachineScript {
|
||||
return machineScriptApp
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/devops/infrastructure/machine"
|
||||
"mayfly-go/internal/devops/infrastructure/persistence"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/internal/machine/infrastructure/machine"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
|
||||
@@ -37,12 +36,15 @@ type Machine interface {
|
||||
GetSshTunnelMachine(id uint64) *machine.SshTunnelMachine
|
||||
}
|
||||
|
||||
func newMachineApp(machineRepo repository.Machine) Machine {
|
||||
return &machineAppImpl{machineRepo: machineRepo}
|
||||
|
||||
}
|
||||
|
||||
type machineAppImpl struct {
|
||||
machineRepo repository.Machine
|
||||
}
|
||||
|
||||
var MachineApp Machine = &machineAppImpl{machineRepo: persistence.MachineDao}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineAppImpl) GetMachineList(condition *entity.Machine, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return m.machineRepo.GetMachineList(condition, pageParam, toEntity, orderBy...)
|
||||
@@ -56,7 +58,11 @@ func (m *machineAppImpl) Count(condition *entity.Machine) int64 {
|
||||
func (m *machineAppImpl) Save(me *entity.Machine) {
|
||||
// ’修改机器信息且密码不为空‘ or ‘新增’需要测试是否可连接
|
||||
if (me.Id != 0 && me.Password != "") || me.Id == 0 {
|
||||
biz.ErrIsNilAppendErr(machine.TestConn(*me, func(u uint64) *entity.Machine { return m.GetById(u) }), "该机器无法连接: %s")
|
||||
biz.ErrIsNilAppendErr(machine.TestConn(*me, func(u uint64) *entity.Machine {
|
||||
me := m.GetById(u)
|
||||
me.PwdDecrypt()
|
||||
return me
|
||||
}), "该机器无法连接: %s")
|
||||
}
|
||||
|
||||
oldMachine := &entity.Machine{Ip: me.Ip, Port: me.Port, Username: me.Username}
|
||||
@@ -4,9 +4,8 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/devops/infrastructure/persistence"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
"os"
|
||||
@@ -53,17 +52,16 @@ type MachineFile interface {
|
||||
RemoveFile(fileId uint64, path string)
|
||||
}
|
||||
|
||||
func newMachineFileApp(machineFileRepo repository.MachineFile, machineRepo repository.Machine) MachineFile {
|
||||
return &machineFileAppImpl{machineRepo: machineRepo, machineFileRepo: machineFileRepo}
|
||||
|
||||
}
|
||||
|
||||
type machineFileAppImpl struct {
|
||||
machineFileRepo repository.MachineFile
|
||||
machineRepo repository.Machine
|
||||
}
|
||||
|
||||
// 实现类单例
|
||||
var MachineFileApp MachineFile = &machineFileAppImpl{
|
||||
machineRepo: persistence.MachineDao,
|
||||
machineFileRepo: persistence.MachineFileDao,
|
||||
}
|
||||
|
||||
// 分页获取机器脚本信息列表
|
||||
func (m *machineFileAppImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return m.machineFileRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
|
||||
@@ -176,7 +174,7 @@ func (m *machineFileAppImpl) RemoveFile(fileId uint64, path string) {
|
||||
err = sftpCli.RemoveDirectory(path)
|
||||
// 如果文件夹有内容会删除失败,则使用rm -rf命令删除
|
||||
if err != nil {
|
||||
MachineApp.GetCli(machineId).Run(fmt.Sprintf("rm -rf %s", path))
|
||||
GetMachineApp().GetCli(machineId).Run(fmt.Sprintf("rm -rf %s", path))
|
||||
err = nil
|
||||
}
|
||||
} else {
|
||||
@@ -187,7 +185,7 @@ func (m *machineFileAppImpl) RemoveFile(fileId uint64, path string) {
|
||||
|
||||
// 获取sftp client
|
||||
func (m *machineFileAppImpl) getSftpCli(machineId uint64) *sftp.Client {
|
||||
return MachineApp.GetCli(machineId).GetSftpCli()
|
||||
return GetMachineApp().GetCli(machineId).GetSftpCli()
|
||||
}
|
||||
|
||||
// 校验并返回实际可访问的文件path
|
||||
@@ -1,9 +1,8 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/devops/infrastructure/persistence"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
@@ -23,6 +22,11 @@ type MachineScript interface {
|
||||
Delete(id uint64)
|
||||
}
|
||||
|
||||
func newMachineScriptApp(machineScriptRepo repository.MachineScript, machineRepo repository.Machine) MachineScript {
|
||||
return &machineScriptAppImpl{machineRepo: machineRepo, machineScriptRepo: machineScriptRepo}
|
||||
|
||||
}
|
||||
|
||||
type machineScriptAppImpl struct {
|
||||
machineScriptRepo repository.MachineScript
|
||||
machineRepo repository.Machine
|
||||
@@ -30,10 +34,10 @@ type machineScriptAppImpl struct {
|
||||
|
||||
const Common_Script_Machine_Id = 9999999
|
||||
|
||||
// 实现类单例
|
||||
var MachineScriptApp MachineScript = &machineScriptAppImpl{
|
||||
machineRepo: persistence.MachineDao,
|
||||
machineScriptRepo: persistence.MachineScriptDao}
|
||||
// // 实现类单例
|
||||
// var MachineScriptApp MachineScript = &machineScriptAppImpl{
|
||||
// machineRepo: persistence.MachineDao,
|
||||
// machineScriptRepo: persistence.MachineScriptDao}
|
||||
|
||||
// 分页获取机器脚本信息列表
|
||||
func (m *machineScriptAppImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"mayfly-go/internal/constant"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/cache"
|
||||
"mayfly-go/pkg/global"
|
||||
@@ -3,7 +3,7 @@ package machine
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/scheduler"
|
||||
"mayfly-go/pkg/utils"
|
||||
@@ -279,16 +279,21 @@ func getCPU(cpuInfo string, stats *Stats) (err error) {
|
||||
value := strings.Split(cpuInfo, ":")[1]
|
||||
values := strings.Split(value, ",")
|
||||
|
||||
us, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[0]), " ")[0], 32)
|
||||
separator := " "
|
||||
// 兼容旧版本使用%的情况
|
||||
if strings.Contains(values[0], "%") {
|
||||
separator = "%"
|
||||
}
|
||||
us, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[0]), separator)[0], 32)
|
||||
stats.CPU.User = float32(us)
|
||||
|
||||
sy, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[1]), " ")[0], 32)
|
||||
sy, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[1]), separator)[0], 32)
|
||||
stats.CPU.System = float32(sy)
|
||||
|
||||
id, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[3]), " ")[0], 32)
|
||||
id, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[3]), separator)[0], 32)
|
||||
stats.CPU.Idle = float32(id)
|
||||
|
||||
wa, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[4]), " ")[0], 32)
|
||||
wa, _ := strconv.ParseFloat(strings.Split(strings.TrimSpace(values[4]), separator)[0], 32)
|
||||
stats.CPU.Iowait = float32(wa)
|
||||
|
||||
return nil
|
||||
@@ -2,18 +2,20 @@ package persistence
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type machineRepo struct{}
|
||||
type machineRepoImpl struct{}
|
||||
|
||||
var MachineDao repository.Machine = &machineRepo{}
|
||||
func newMachineRepo() repository.Machine {
|
||||
return new(machineRepoImpl)
|
||||
}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineRepo) GetMachineList(condition *entity.Machine, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
func (m *machineRepoImpl) GetMachineList(condition *entity.Machine, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
sql := "SELECT m.* FROM t_machine m JOIN t_project_member pm ON m.project_id = pm.project_id WHERE 1 = 1 "
|
||||
if condition.CreatorId != 0 {
|
||||
// 使用创建者id模拟项目成员id
|
||||
@@ -32,17 +34,17 @@ func (m *machineRepo) GetMachineList(condition *entity.Machine, pageParam *model
|
||||
return model.GetPageBySql(sql, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (m *machineRepo) Count(condition *entity.Machine) int64 {
|
||||
func (m *machineRepoImpl) Count(condition *entity.Machine) int64 {
|
||||
return model.CountBy(condition)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (m *machineRepo) GetMachine(condition *entity.Machine, cols ...string) error {
|
||||
func (m *machineRepoImpl) GetMachine(condition *entity.Machine, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineRepo) GetById(id uint64, cols ...string) *entity.Machine {
|
||||
func (m *machineRepoImpl) GetById(id uint64, cols ...string) *entity.Machine {
|
||||
machine := new(entity.Machine)
|
||||
if err := model.GetById(machine, id, cols...); err != nil {
|
||||
return nil
|
||||
@@ -51,10 +53,10 @@ func (m *machineRepo) GetById(id uint64, cols ...string) *entity.Machine {
|
||||
return machine
|
||||
}
|
||||
|
||||
func (m *machineRepo) Create(entity *entity.Machine) {
|
||||
func (m *machineRepoImpl) Create(entity *entity.Machine) {
|
||||
biz.ErrIsNilAppendErr(model.Insert(entity), "创建机器信息失败: %s")
|
||||
}
|
||||
|
||||
func (m *machineRepo) UpdateById(entity *entity.Machine) {
|
||||
func (m *machineRepoImpl) UpdateById(entity *entity.Machine) {
|
||||
biz.ErrIsNilAppendErr(model.UpdateById(entity), "更新机器信息失败: %s")
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type machineFileRepoImpl struct{}
|
||||
|
||||
func newMachineFileRepo() repository.MachineFile {
|
||||
return new(machineFileRepoImpl)
|
||||
}
|
||||
|
||||
// 分页获取机器文件信息列表
|
||||
func (m *machineFileRepoImpl) GetPageList(condition *entity.MachineFile, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (m *machineFileRepoImpl) GetMachineFile(condition *entity.MachineFile, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineFileRepoImpl) GetById(id uint64, cols ...string) *entity.MachineFile {
|
||||
ms := new(entity.MachineFile)
|
||||
if err := model.GetById(ms, id, cols...); err != nil {
|
||||
return nil
|
||||
|
||||
}
|
||||
return ms
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineFileRepoImpl) Delete(id uint64) {
|
||||
biz.ErrIsNil(model.DeleteById(new(entity.MachineFile), id), "删除失败")
|
||||
}
|
||||
|
||||
func (m *machineFileRepoImpl) Create(entity *entity.MachineFile) {
|
||||
model.Insert(entity)
|
||||
}
|
||||
|
||||
func (m *machineFileRepoImpl) UpdateById(entity *entity.MachineFile) {
|
||||
model.UpdateById(entity)
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type machineScriptRepoImpl struct{}
|
||||
|
||||
func newMachineScriptRepo() repository.MachineScript {
|
||||
return new(machineScriptRepoImpl)
|
||||
}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineScriptRepoImpl) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return model.GetPage(pageParam, condition, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
func (m *machineScriptRepoImpl) GetMachineScript(condition *entity.MachineScript, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptRepoImpl) GetById(id uint64, cols ...string) *entity.MachineScript {
|
||||
ms := new(entity.MachineScript)
|
||||
if err := model.GetById(ms, id, cols...); err != nil {
|
||||
return nil
|
||||
|
||||
}
|
||||
return ms
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptRepoImpl) Delete(id uint64) {
|
||||
biz.ErrIsNil(model.DeleteById(new(entity.MachineScript), id), "删除失败")
|
||||
}
|
||||
|
||||
func (m *machineScriptRepoImpl) Create(entity *entity.MachineScript) {
|
||||
model.Insert(entity)
|
||||
}
|
||||
|
||||
func (m *machineScriptRepoImpl) UpdateById(entity *entity.MachineScript) {
|
||||
model.UpdateById(entity)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package persistence
|
||||
|
||||
import "mayfly-go/internal/machine/domain/repository"
|
||||
|
||||
var (
|
||||
machineRepo repository.Machine = newMachineRepo()
|
||||
machineFileRepo repository.MachineFile = newMachineFileRepo()
|
||||
machineScriptRepo repository.MachineScript = newMachineScriptRepo()
|
||||
)
|
||||
|
||||
func GetMachineRepo() repository.Machine {
|
||||
return machineRepo
|
||||
}
|
||||
|
||||
func GetMachineFileRepo() repository.MachineFile {
|
||||
return machineFileRepo
|
||||
}
|
||||
|
||||
func GetMachineScriptRepo() repository.MachineScript {
|
||||
return machineScriptRepo
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/api"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/machine/api"
|
||||
"mayfly-go/internal/machine/application"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -10,8 +11,8 @@ import (
|
||||
|
||||
func InitMachineRouter(router *gin.RouterGroup) {
|
||||
m := &api.Machine{
|
||||
MachineApp: application.MachineApp,
|
||||
ProjectApp: application.ProjectApp,
|
||||
MachineApp: application.GetMachineApp(),
|
||||
ProjectApp: projectapp.GetProjectApp(),
|
||||
}
|
||||
|
||||
machines := router.Group("machines")
|
||||
@@ -1,8 +1,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/api"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/machine/api"
|
||||
"mayfly-go/internal/machine/application"
|
||||
sysApplication "mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
@@ -13,9 +13,9 @@ func InitMachineFileRouter(router *gin.RouterGroup) {
|
||||
machineFile := router.Group("machines")
|
||||
{
|
||||
mf := &api.MachineFile{
|
||||
MachineFileApp: application.MachineFileApp,
|
||||
MachineApp: application.MachineApp,
|
||||
MsgApp: sysApplication.MsgApp,
|
||||
MachineFileApp: application.GetMachineFileApp(),
|
||||
MachineApp: application.GetMachineApp(),
|
||||
MsgApp: sysApplication.GetMsgApp(),
|
||||
}
|
||||
|
||||
// 获取指定机器文件列表
|
||||
@@ -1,8 +1,9 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/api"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/machine/api"
|
||||
"mayfly-go/internal/machine/application"
|
||||
projectapp "mayfly-go/internal/project/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -12,9 +13,9 @@ func InitMachineScriptRouter(router *gin.RouterGroup) {
|
||||
machines := router.Group("machines")
|
||||
{
|
||||
ms := &api.MachineScript{
|
||||
MachineScriptApp: application.MachineScriptApp,
|
||||
MachineApp: application.MachineApp,
|
||||
ProjectApp: application.ProjectApp,
|
||||
MachineScriptApp: application.GetMachineScriptApp(),
|
||||
MachineApp: application.GetMachineApp(),
|
||||
ProjectApp: projectapp.GetProjectApp(),
|
||||
}
|
||||
|
||||
// 获取指定机器脚本列表
|
||||
9
server/internal/machine/router/router.go
Normal file
9
server/internal/machine/router/router.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package router
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func Init(router *gin.RouterGroup) {
|
||||
InitMachineRouter(router)
|
||||
InitMachineFileRouter(router)
|
||||
InitMachineScriptRouter(router)
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"mayfly-go/internal/devops/api/form"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/mongo/api/form"
|
||||
"mayfly-go/internal/mongo/application"
|
||||
"mayfly-go/internal/mongo/domain/entity"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/ginx"
|
||||
11
server/internal/mongo/application/application.go
Normal file
11
server/internal/mongo/application/application.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package application
|
||||
|
||||
import "mayfly-go/internal/mongo/infrastructure/persistence"
|
||||
|
||||
var (
|
||||
mongoApp Mongo = newMongoAppImpl(persistence.GetMongoRepo())
|
||||
)
|
||||
|
||||
func GetMongoApp() Mongo {
|
||||
return mongoApp
|
||||
}
|
||||
@@ -3,10 +3,10 @@ package application
|
||||
import (
|
||||
"context"
|
||||
"mayfly-go/internal/constant"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/devops/infrastructure/machine"
|
||||
"mayfly-go/internal/devops/infrastructure/persistence"
|
||||
machineapp "mayfly-go/internal/machine/application"
|
||||
"mayfly-go/internal/machine/infrastructure/machine"
|
||||
"mayfly-go/internal/mongo/domain/entity"
|
||||
"mayfly-go/internal/mongo/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/cache"
|
||||
"mayfly-go/pkg/global"
|
||||
@@ -42,12 +42,14 @@ type Mongo interface {
|
||||
GetMongoCli(id uint64) *mongo.Client
|
||||
}
|
||||
|
||||
type mongoAppImpl struct {
|
||||
mongoRepo repository.Mongo
|
||||
func newMongoAppImpl(mongoRepo repository.Mongo) Mongo {
|
||||
return &mongoAppImpl{
|
||||
mongoRepo: mongoRepo,
|
||||
}
|
||||
}
|
||||
|
||||
var MongoApp Mongo = &mongoAppImpl{
|
||||
mongoRepo: persistence.MongoDao,
|
||||
type mongoAppImpl struct {
|
||||
mongoRepo repository.Mongo
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
@@ -191,7 +193,7 @@ type MongoSshDialer struct {
|
||||
}
|
||||
|
||||
func (sd *MongoSshDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
if sshConn, err := MachineApp.GetSshTunnelMachine(sd.machineId).GetDialConn(network, address); err == nil {
|
||||
if sshConn, err := machineapp.GetMachineApp().GetSshTunnelMachine(sd.machineId).GetDialConn(network, address); err == nil {
|
||||
// 将ssh conn包装,否则内部部设置超时会报错,ssh conn不支持设置超时会返回错误: ssh: tcpChan: deadline not supported
|
||||
return &utils.WrapSshConn{Conn: sshConn}, nil
|
||||
} else {
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/mongo/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -2,18 +2,20 @@ package persistence
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mayfly-go/internal/devops/domain/entity"
|
||||
"mayfly-go/internal/devops/domain/repository"
|
||||
"mayfly-go/internal/mongo/domain/entity"
|
||||
"mayfly-go/internal/mongo/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
type mongoRepo struct{}
|
||||
type mongoRepoImpl struct{}
|
||||
|
||||
var MongoDao repository.Mongo = &mongoRepo{}
|
||||
func newMongoRepo() repository.Mongo {
|
||||
return new(mongoRepoImpl)
|
||||
}
|
||||
|
||||
// 分页获取数据库信息列表
|
||||
func (d *mongoRepo) GetList(condition *entity.Mongo, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
func (d *mongoRepoImpl) GetList(condition *entity.Mongo, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
sql := "SELECT d.* FROM t_mongo d JOIN t_project_member pm ON d.project_id = pm.project_id WHERE 1 = 1 "
|
||||
if condition.CreatorId != 0 {
|
||||
// 使用创建者id模拟项目成员id
|
||||
@@ -29,17 +31,17 @@ func (d *mongoRepo) GetList(condition *entity.Mongo, pageParam *model.PageParam,
|
||||
return model.GetPageBySql(sql, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (d *mongoRepo) Count(condition *entity.Mongo) int64 {
|
||||
func (d *mongoRepoImpl) Count(condition *entity.Mongo) int64 {
|
||||
return model.CountBy(condition)
|
||||
}
|
||||
|
||||
// 根据条件获取
|
||||
func (d *mongoRepo) Get(condition *entity.Mongo, cols ...string) error {
|
||||
func (d *mongoRepoImpl) Get(condition *entity.Mongo, cols ...string) error {
|
||||
return model.GetBy(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (d *mongoRepo) GetById(id uint64, cols ...string) *entity.Mongo {
|
||||
func (d *mongoRepoImpl) GetById(id uint64, cols ...string) *entity.Mongo {
|
||||
db := new(entity.Mongo)
|
||||
if err := model.GetById(db, id, cols...); err != nil {
|
||||
return nil
|
||||
@@ -48,14 +50,14 @@ func (d *mongoRepo) GetById(id uint64, cols ...string) *entity.Mongo {
|
||||
return db
|
||||
}
|
||||
|
||||
func (d *mongoRepo) Insert(db *entity.Mongo) {
|
||||
func (d *mongoRepoImpl) Insert(db *entity.Mongo) {
|
||||
biz.ErrIsNil(model.Insert(db), "新增mongo信息失败")
|
||||
}
|
||||
|
||||
func (d *mongoRepo) Update(db *entity.Mongo) {
|
||||
func (d *mongoRepoImpl) Update(db *entity.Mongo) {
|
||||
biz.ErrIsNil(model.UpdateById(db), "更新mongo信息失败")
|
||||
}
|
||||
|
||||
func (d *mongoRepo) Delete(id uint64) {
|
||||
func (d *mongoRepoImpl) Delete(id uint64) {
|
||||
model.DeleteById(new(entity.Mongo), id)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/mongo/domain/repository"
|
||||
)
|
||||
|
||||
var (
|
||||
mongoRepo repository.Mongo = newMongoRepo()
|
||||
)
|
||||
|
||||
func GetMongoRepo() repository.Mongo {
|
||||
return mongoRepo
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/devops/api"
|
||||
"mayfly-go/internal/devops/application"
|
||||
"mayfly-go/internal/mongo/api"
|
||||
"mayfly-go/internal/mongo/application"
|
||||
"mayfly-go/pkg/ctx"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -12,7 +12,7 @@ func InitMongoRouter(router *gin.RouterGroup) {
|
||||
m := router.Group("mongos")
|
||||
{
|
||||
ma := &api.Mongo{
|
||||
MongoApp: application.MongoApp,
|
||||
MongoApp: application.GetMongoApp(),
|
||||
}
|
||||
|
||||
// 获取所有mongo列表
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user