fix():修复代码生成器
parent
c758f1f41a
commit
6dba2788a9
|
@ -1,5 +1,6 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
|
||||||
// 登录方法
|
// 登录方法
|
||||||
export function login(username, password, code, uuid) {
|
export function login(username, password, code, uuid) {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
@ -18,6 +18,14 @@ export function listDbTable(query) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询db所有数据库列表
|
||||||
|
export function listDbTableAll() {
|
||||||
|
return request({
|
||||||
|
url: '/code/gen/db/listAll',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 查询表详细信息
|
// 查询表详细信息
|
||||||
export function getGenTable(tableId) {
|
export function getGenTable(tableId) {
|
||||||
return request({
|
return request({
|
||||||
|
@ -36,11 +44,14 @@ export function updateGenTable(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导入表
|
// 导入表
|
||||||
export function importTable(data) {
|
export function importTable(tables, dbName) {
|
||||||
return request({
|
return request({
|
||||||
url: '/code/gen/importTable',
|
url: '/code/gen/importTable',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params: data
|
params: {
|
||||||
|
tables: tables,
|
||||||
|
dbName: dbName
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +80,29 @@ export function genCode(tableName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步数据库
|
// 同步数据库
|
||||||
export function synchDb(tableName) {
|
export function synchDb(tableName,dbName) {
|
||||||
return request({
|
return request({
|
||||||
url: '/code/gen/synchDb/' + tableName,
|
url: '/code/gen/synchDb/' + tableName+'/'+dbName,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询所有数据库名称
|
||||||
|
export function selDbNameAll() {
|
||||||
|
return request({
|
||||||
|
url: '/code/gen/db/selDbNameAll',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据数据库名称与表名称查询表字段
|
||||||
|
export function selectDbTableColumnsByName(dbName,table) {
|
||||||
|
return request({
|
||||||
|
url: '/code/gen/selectDbTableColumnsByName',
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
dbName: dbName,
|
||||||
|
table: table
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ export default {
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
captchaEnabled: true,
|
captchaEnabled: false,
|
||||||
// 注册开关
|
// 注册开关
|
||||||
register: false,
|
register: false,
|
||||||
redirect: undefined
|
redirect: undefined
|
||||||
|
|
|
@ -127,9 +127,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getGenTable, updateGenTable} from "@/api/tool/gen";
|
import {getGenTable, updateGenTable} from "/src/api/tool/gen";
|
||||||
import {optionselect as getDictOptionselect} from "@/api/system/dict/type";
|
import {optionselect as getDictOptionselect} from "/src/api/system/dict/type";
|
||||||
import {listMenu as getMenuTreeselect} from "@/api/system/menu";
|
import {listMenu as getMenuTreeselect} from "/src/api/system/menu";
|
||||||
import basicInfoForm from "./basicInfoForm";
|
import basicInfoForm from "./basicInfoForm";
|
||||||
import genInfoForm from "./genInfoForm";
|
import genInfoForm from "./genInfoForm";
|
||||||
import Sortable from 'sortablejs'
|
import Sortable from 'sortablejs'
|
||||||
|
@ -183,7 +183,8 @@ export default {
|
||||||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
||||||
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
||||||
const validateResult = res.data.every(item => !!item);
|
console.log(res)
|
||||||
|
const validateResult = res.every(item => !!item);
|
||||||
if (validateResult) {
|
if (validateResult) {
|
||||||
const genTable = Object.assign({}, basicForm.model, genForm.model);
|
const genTable = Object.assign({}, basicForm.model, genForm.model);
|
||||||
genTable.columns = this.columns;
|
genTable.columns = this.columns;
|
||||||
|
@ -194,10 +195,8 @@ export default {
|
||||||
parentMenuId: genTable.parentMenuId
|
parentMenuId: genTable.parentMenuId
|
||||||
};
|
};
|
||||||
updateGenTable(genTable).then(res => {
|
updateGenTable(genTable).then(res => {
|
||||||
this.$modal.msgSuccess(res.data.msg);
|
this.$modal.msgSuccess(res.msg);
|
||||||
if (res.code === 200) {
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$modal.msgError("表单校验未通过,请重新检查提交内容");
|
this.$modal.msgError("表单校验未通过,请重新检查提交内容");
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<el-form-item prop="moduleName">
|
<el-form-item prop="moduleName">
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
生成模块名
|
生成模块名
|
||||||
<el-tooltip content="可理解为子系统名,例如 system" placement="top">
|
<el-tooltip content="指的是项目在网关注册的路径名称(不推荐首字母大写),例: 一个项目在网关注册路径为'- Path=/system/**',其下有两个服务模块,它们的控制层路径是s1,s2,那么这里添system" placement="top">
|
||||||
<i class="el-icon-question"></i>
|
<i class="el-icon-question"></i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
<el-form-item prop="businessName">
|
<el-form-item prop="businessName">
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
生成业务名
|
生成业务名
|
||||||
<el-tooltip content="可理解为功能英文名,例如 user" placement="top">
|
<el-tooltip content="指的是模块的控制层名称(不推荐首字母大写),例: 一个项目在网关注册路径为'- Path=/system/**',其下有两个服务模块,它们的控制层路径是auth和app,这次生成auth的模块,那么这里填控制层路径auth" placement="top">
|
||||||
<i class="el-icon-question"></i>
|
<i class="el-icon-question"></i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<el-form-item prop="functionName">
|
<el-form-item prop="functionName">
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
生成功能名
|
生成功能名
|
||||||
<el-tooltip content="用作类描述,例如 用户" placement="top">
|
<el-tooltip content="用作类描述,例如 用户管理" placement="top">
|
||||||
<i class="el-icon-question"></i>
|
<i class="el-icon-question"></i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
<!-- 导入表 -->
|
<!-- 导入表 -->
|
||||||
<el-dialog :visible.sync="visible" append-to-body title="导入表" top="5vh" width="800px">
|
<el-dialog :visible.sync="visible" append-to-body title="导入表" top="5vh" width="800px">
|
||||||
<el-form ref="queryForm" :inline="true" :model="queryParams" size="small">
|
<el-form ref="queryForm" :inline="true" :model="queryParams" size="small">
|
||||||
|
<el-form-item label="数据库名称" prop="dbName">
|
||||||
|
<el-select v-model="queryParams.dbName" placeholder="请选择数据库" clearable>
|
||||||
|
<el-option v-for="item in dbs" :key="item" :label="item" :value="item"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="表名称" prop="tableName">
|
<el-form-item label="表名称" prop="tableName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.tableName"
|
v-model="queryParams.tableName"
|
||||||
|
@ -48,7 +53,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {importTable, listDbTable} from "@/api/tool/gen";
|
import {importTable, listDbTable, selDbNameAll} from "@/api/tool/gen";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -61,6 +66,7 @@ export default {
|
||||||
total: 0,
|
total: 0,
|
||||||
// 表数据
|
// 表数据
|
||||||
dbTableList: [],
|
dbTableList: [],
|
||||||
|
dbs: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
|
@ -74,6 +80,7 @@ export default {
|
||||||
// 显示弹框
|
// 显示弹框
|
||||||
show() {
|
show() {
|
||||||
this.getList();
|
this.getList();
|
||||||
|
this.selDbNameList();
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
clickRow(row) {
|
clickRow(row) {
|
||||||
|
@ -107,11 +114,23 @@ export default {
|
||||||
this.$modal.msgError("请选择要导入的表");
|
this.$modal.msgError("请选择要导入的表");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
importTable({tables: tableNames}).then(res => {
|
const dbName = this.queryParams.dbName;
|
||||||
this.$modal.msgSuccess(res.data.msg);
|
importTable(tableNames, dbName).then(res => {
|
||||||
|
console.log(res)
|
||||||
|
if (res.code === 200){
|
||||||
|
this.$modal.msgSuccess("成功");
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit("ok");
|
this.$emit("ok");
|
||||||
|
}else{
|
||||||
|
this.$modal.msgSuccess(res.data.msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
// 查询所有数据库名称
|
||||||
|
selDbNameList() {
|
||||||
|
selDbNameAll().then(res => {
|
||||||
|
this.dbs = res.data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,6 +91,13 @@
|
||||||
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
|
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="数据库名称"
|
||||||
|
align="center"
|
||||||
|
prop="dbName"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
width="120"
|
||||||
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
align="center"
|
align="center"
|
||||||
|
@ -188,7 +195,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {delTable, genCode, listTable, previewTable, synchDb} from "@/api/tool/gen";
|
import {delTable, genCode, listTable, previewTable, synchDb} from "/src/api/tool/gen";
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
import hljs from "highlight.js/lib/highlight";
|
import hljs from "highlight.js/lib/highlight";
|
||||||
import "highlight.js/styles/github-gist.css";
|
import "highlight.js/styles/github-gist.css";
|
||||||
|
@ -256,7 +263,9 @@ export default {
|
||||||
/** 查询表集合 */
|
/** 查询表集合 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
console.log(this.loading)
|
||||||
listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
|
console.log(response)
|
||||||
this.tableList = response.data.rows;
|
this.tableList = response.data.rows;
|
||||||
this.total = response.data.total;
|
this.total = response.data.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
@ -286,8 +295,9 @@ export default {
|
||||||
/** 同步数据库操作 */
|
/** 同步数据库操作 */
|
||||||
handleSynchDb(row) {
|
handleSynchDb(row) {
|
||||||
const tableName = row.tableName;
|
const tableName = row.tableName;
|
||||||
|
const dbName = row.dbName;
|
||||||
this.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function () {
|
this.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function () {
|
||||||
return synchDb(tableName);
|
return synchDb(tableName, dbName);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$modal.msgSuccess("同步成功");
|
this.$modal.msgSuccess("同步成功");
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|
Loading…
Reference in New Issue