mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-12 20:30:25 +08:00
refactor: code review
This commit is contained in:
@@ -158,18 +158,19 @@
|
|||||||
@data-delete="onRefresh"
|
@data-delete="onRefresh"
|
||||||
></db-table-data>
|
></db-table-data>
|
||||||
|
|
||||||
<el-row type="flex" class="mt5" :gutter="10" justify="end" style="user-select: none">
|
<el-row type="flex" class="mt5" :gutter="10" justify="space-between" style="user-select: none">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-text
|
<el-text
|
||||||
style="color: var(--el-color-info-light-3); font-size: 12px; margin-top: 5px"
|
id="copyValue"
|
||||||
class="is-truncated"
|
style="color: var(--el-color-info-light-3)"
|
||||||
@click="handleCopySql(sql)"
|
class="is-truncated font12 mt5"
|
||||||
|
@click="copyToClipboard(sql)"
|
||||||
:title="sql"
|
:title="sql"
|
||||||
>{{ sql }}</el-text
|
>{{ sql }}</el-text
|
||||||
>
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-row :gutter="10" justify="center">
|
<el-row :gutter="10" justify="left">
|
||||||
<el-link class="op-page" :underline="false" @click="pageNum = 1" :disabled="pageNum == 1" icon="DArrowLeft" title="首页" />
|
<el-link class="op-page" :underline="false" @click="pageNum = 1" :disabled="pageNum == 1" icon="DArrowLeft" title="首页" />
|
||||||
<el-link class="op-page" :underline="false" @click="pageNum = --pageNum || 1" :disabled="pageNum == 1" icon="Back" title="上一页" />
|
<el-link class="op-page" :underline="false" @click="pageNum = --pageNum || 1" :disabled="pageNum == 1" icon="Back" title="上一页" />
|
||||||
<div class="op-page">
|
<div class="op-page">
|
||||||
@@ -183,9 +184,9 @@
|
|||||||
@keydown.enter="handleSetPageNum"
|
@keydown.enter="handleSetPageNum"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<el-link class="op-page" :underline="false" @click="++pageNum" icon="Right" />
|
<el-link class="op-page" :underline="false" @click="++pageNum" :disabled="datas.length < pageSize" icon="Right" />
|
||||||
<el-link class="op-page" :underline="false" @click="handleEndPage" icon="DArrowRight" />
|
<el-link class="op-page" :underline="false" @click="handleEndPage" :disabled="datas.length < pageSize" icon="DArrowRight" />
|
||||||
<div style="width: 90px; margin-left: 20px" class="op-page">
|
<div style="width: 90px" class="op-page ml10">
|
||||||
<el-select size="small" :default-first-option="true" v-model="pageSize" @change="handleSizeChange">
|
<el-select size="small" :default-first-option="true" v-model="pageSize" @change="handleSizeChange">
|
||||||
<el-option
|
<el-option
|
||||||
style="font-size: 12px; height: 24px; line-height: 24px"
|
style="font-size: 12px; height: 24px; line-height: 24px"
|
||||||
@@ -196,21 +197,13 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
<el-link
|
<el-link class="op-page ml10" v-if="!state.counting" :underline="false" @click="handleCount" icon="Stopwatch" title="计数" />
|
||||||
class="op-page"
|
<el-link class="op-page ml10" v-if="state.counting" :underline="false" title="计数中...">
|
||||||
style="margin-left: 20px"
|
|
||||||
v-if="!state.counting"
|
|
||||||
:underline="false"
|
|
||||||
@click="handleCount"
|
|
||||||
icon="Stopwatch"
|
|
||||||
title="计数"
|
|
||||||
/>
|
|
||||||
<el-link class="op-page" style="margin-left: 20px" v-if="state.counting" :underline="false" title="计数中...">
|
|
||||||
<el-icon class="is-loading">
|
<el-icon class="is-loading">
|
||||||
<Loading />
|
<Loading />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-link>
|
</el-link>
|
||||||
<el-text class="op-page" style="font-size: 12px" v-if="state.showTotal">总 {{ state.total }} 条</el-text>
|
<el-text class="op-page font12" v-if="state.showTotal">总 {{ state.total }} 条</el-text>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -334,7 +327,7 @@ const state = reactive({
|
|||||||
],
|
],
|
||||||
setPageNum: 0,
|
setPageNum: 0,
|
||||||
total: 0,
|
total: 0,
|
||||||
showTotal: 0,
|
showTotal: false,
|
||||||
counting: false,
|
counting: false,
|
||||||
selectionDatas: [] as any,
|
selectionDatas: [] as any,
|
||||||
condPopVisible: false,
|
condPopVisible: false,
|
||||||
@@ -459,11 +452,6 @@ const handleCount = async () => {
|
|||||||
state.counting = false;
|
state.counting = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCopySql = async (sql: string) => {
|
|
||||||
await copyToClipboard(sql);
|
|
||||||
ElMessage.success('复制成功');
|
|
||||||
};
|
|
||||||
|
|
||||||
// 完整的条件,每次选中后会重置条件框内容,故需要这个变量在获取建议时将文本框内容保存
|
// 完整的条件,每次选中后会重置条件框内容,故需要这个变量在获取建议时将文本框内容保存
|
||||||
let completeCond = '';
|
let completeCond = '';
|
||||||
// 是否存在列建议
|
// 是否存在列建议
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
|
||||||
"mayfly-go/internal/db/dbm/dbi"
|
"mayfly-go/internal/db/dbm/dbi"
|
||||||
"mayfly-go/internal/db/domain/entity"
|
"mayfly-go/internal/db/domain/entity"
|
||||||
"mayfly-go/internal/db/domain/repository"
|
"mayfly-go/internal/db/domain/repository"
|
||||||
@@ -19,6 +18,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DataSyncTask interface {
|
type DataSyncTask interface {
|
||||||
@@ -99,14 +100,12 @@ func (app *dataSyncAppImpl) AddCronJob(taskEntity *entity.DataSyncTask) {
|
|||||||
|
|
||||||
// 根据状态添加新的任务
|
// 根据状态添加新的任务
|
||||||
if taskEntity.Status == entity.DataSyncTaskStatusEnable {
|
if taskEntity.Status == entity.DataSyncTaskStatusEnable {
|
||||||
scheduler.AddFunByKey(key, taskEntity.TaskCron, func() {
|
|
||||||
go func() {
|
|
||||||
taskId := taskEntity.Id
|
taskId := taskEntity.Id
|
||||||
|
scheduler.AddFunByKey(key, taskEntity.TaskCron, func() {
|
||||||
logx.Infof("开始执行同步任务: %d", taskId)
|
logx.Infof("开始执行同步任务: %d", taskId)
|
||||||
if err := app.RunCronJob(taskId); err != nil {
|
if err := app.RunCronJob(taskId); err != nil {
|
||||||
logx.Errorf("定时执行数据同步任务失败: %s", err.Error())
|
logx.Errorf("定时执行数据同步任务失败: %s", err.Error())
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +230,7 @@ func (app *dataSyncAppImpl) doDataSync(sql string, task *entity.DataSyncTask) (*
|
|||||||
// 遍历columns 取task.UpdField的字段类型
|
// 遍历columns 取task.UpdField的字段类型
|
||||||
updFieldType = dbi.DataTypeString
|
updFieldType = dbi.DataTypeString
|
||||||
for _, column := range columns {
|
for _, column := range columns {
|
||||||
if strings.ToLower(column.Name) == strings.ToLower(task.UpdField) {
|
if strings.EqualFold(strings.ToLower(column.Name), strings.ToLower(task.UpdField)) {
|
||||||
updFieldType = srcDialect.GetDataConverter().GetDataType(column.Type)
|
updFieldType = srcDialect.GetDataConverter().GetDataType(column.Type)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ func doUpdate(ctx context.Context, update *sqlparser.Update, execSqlReq *DbSqlEx
|
|||||||
tableStr := sqlparser.String(update.TableExprs)
|
tableStr := sqlparser.String(update.TableExprs)
|
||||||
// 可能使用别名,故空格切割
|
// 可能使用别名,故空格切割
|
||||||
tableName := strings.Split(tableStr, " ")[0]
|
tableName := strings.Split(tableStr, " ")[0]
|
||||||
if strings.Index(tableName, ".") > -1 {
|
if strings.Contains(tableName, ".") {
|
||||||
tableName = strings.Split(tableName, ".")[1]
|
tableName = strings.Split(tableName, ".")[1]
|
||||||
}
|
}
|
||||||
where := sqlparser.String(update.Where)
|
where := sqlparser.String(update.Where)
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ func (m *machineCronJobAppImpl) addCronJob(mcj *entity.MachineCronJob) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scheduler.AddFunByKey(key, mcj.Cron, func() {
|
scheduler.AddFunByKey(key, mcj.Cron, func() {
|
||||||
go m.RunCronJob(key)
|
m.RunCronJob(key)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func (m *machineCronJobAppImpl) runCronJob0(mid uint64, cronJob *entity.MachineCronJob) {
|
func (m *machineCronJobAppImpl) runCronJob0(mid uint64, cronJob *entity.MachineCronJob) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func (s *Server) Default() {
|
|||||||
s.Model = "release"
|
s.Model = "release"
|
||||||
}
|
}
|
||||||
if s.Port == 0 {
|
if s.Port == 0 {
|
||||||
s.Port = 8888
|
s.Port = 18888
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`,
|
|||||||
VALUES (161, 49, 'dbms23ax/xleaiec2/3NUXQFIO/', 2, 1, '数据库备份', 'db:backup', 1705973876, 'null', 1, 'admin', 1, 'admin', '2024-01-23 09:37:56', '2024-01-23 09:37:56', 0, NULL),
|
VALUES (161, 49, 'dbms23ax/xleaiec2/3NUXQFIO/', 2, 1, '数据库备份', 'db:backup', 1705973876, 'null', 1, 'admin', 1, 'admin', '2024-01-23 09:37:56', '2024-01-23 09:37:56', 0, NULL),
|
||||||
(160, 49, 'dbms23ax/xleaiec2/ghErkTdb/', 2, 1, '数据库恢复', 'db:restore', 1705973909, 'null', 1, 'admin', 1, 'admin', '2024-01-23 09:38:29', '2024-01-23 09:38:29', 0, NULL);
|
(160, 49, 'dbms23ax/xleaiec2/ghErkTdb/', 2, 1, '数据库恢复', 'db:restore', 1705973909, 'null', 1, 'admin', 1, 'admin', '2024-01-23 09:38:29', '2024-01-23 09:38:29', 0, NULL);
|
||||||
|
|
||||||
ALTER TABLE `mayfly-go`.`t_db_backup`
|
ALTER TABLE `t_db_backup`
|
||||||
ADD COLUMN `enabled_desc` varchar(64) NULL COMMENT '任务启用描述' AFTER `enabled`;
|
ADD COLUMN `enabled_desc` varchar(64) NULL COMMENT '任务启用描述' AFTER `enabled`;
|
||||||
|
|
||||||
ALTER TABLE `mayfly-go`.`t_db_restore`
|
ALTER TABLE `t_db_restore`
|
||||||
ADD COLUMN `enabled_desc` varchar(64) NULL COMMENT '任务启用描述' AFTER `enabled`;
|
ADD COLUMN `enabled_desc` varchar(64) NULL COMMENT '任务启用描述' AFTER `enabled`;
|
||||||
|
|
||||||
ALTER TABLE `mayfly-go`.`t_db_backup_history`
|
ALTER TABLE `t_db_backup_history`
|
||||||
ADD COLUMN `restoring` int(1) NOT NULL DEFAULT(0) COMMENT '备份历史恢复标识',
|
ADD COLUMN `restoring` int(1) NOT NULL DEFAULT(0) COMMENT '备份历史恢复标识',
|
||||||
ADD COLUMN `deleting` int(1) NOT NULL DEFAULT(0) COMMENT '备份历史删除标识';
|
ADD COLUMN `deleting` int(1) NOT NULL DEFAULT(0) COMMENT '备份历史删除标识';
|
||||||
|
|||||||
Reference in New Issue
Block a user