2021-02-09 15:55:54 +08:00
|
|
|
import request from '@/utils/request'
|
|
|
|
|
2021-02-09 22:14:01 +08:00
|
|
|
// 获得表定义分页
|
2021-02-11 01:05:21 +08:00
|
|
|
export function getCodegenTablePage(query) {
|
2021-02-09 22:14:01 +08:00
|
|
|
return request({
|
2021-02-10 13:41:00 +08:00
|
|
|
url: '/tool/codegen/table/page',
|
2021-02-09 22:14:01 +08:00
|
|
|
method: 'get',
|
|
|
|
params: query
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获得表和字段的明细
|
2021-02-11 01:05:21 +08:00
|
|
|
export function getCodegenDetail(tableId) {
|
2021-02-09 22:14:01 +08:00
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/detail?tableId=' + tableId,
|
|
|
|
method: 'get',
|
|
|
|
})
|
|
|
|
}
|
2021-02-10 13:41:00 +08:00
|
|
|
|
|
|
|
// 修改代码生成信息
|
|
|
|
export function updateCodegen(data) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/update',
|
|
|
|
method: 'put',
|
|
|
|
data: data
|
|
|
|
})
|
|
|
|
}
|
2021-02-10 17:45:04 +08:00
|
|
|
|
2021-02-11 01:05:21 +08:00
|
|
|
// 基于数据库的表结构,同步数据库的表和字段定义
|
2021-02-13 13:40:29 +08:00
|
|
|
export function syncCodegenFromDB(tableId) {
|
2021-02-11 01:05:21 +08:00
|
|
|
return request({
|
2021-02-13 13:40:29 +08:00
|
|
|
url: '/tool/codegen/sync-from-db?tableId=' + tableId,
|
2021-02-11 01:05:21 +08:00
|
|
|
method: 'put'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-02-13 13:40:29 +08:00
|
|
|
// 基于 SQL 建表语句,同步数据库的表和字段定义
|
|
|
|
export function syncCodegenFromSQL(tableId, sql) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/sync-from-sql?tableId=' + tableId,
|
|
|
|
method: 'put',
|
|
|
|
headers:{
|
|
|
|
'Content-type': 'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
|
|
data: 'tableId=' + tableId + "&sql=" + sql,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-02-10 17:45:04 +08:00
|
|
|
// 预览生成代码
|
|
|
|
export function previewCodegen(tableId) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/preview?tableId=' + tableId,
|
2021-02-10 19:05:22 +08:00
|
|
|
method: 'get',
|
2021-02-10 17:45:04 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 下载生成代码
|
|
|
|
export function downloadCodegen(tableId) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/download?tableId=' + tableId,
|
|
|
|
method: 'get',
|
|
|
|
responseType: 'blob'
|
|
|
|
})
|
|
|
|
}
|
2021-02-11 01:05:21 +08:00
|
|
|
|
|
|
|
// 获得表定义分页
|
|
|
|
export function getSchemaTableList(query) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/db/table/list',
|
|
|
|
method: 'get',
|
|
|
|
params: query
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 基于数据库的表结构,创建代码生成器的表定义
|
2021-02-13 13:40:29 +08:00
|
|
|
export function createCodegenListFromDB(tableNames) {
|
2021-02-11 01:05:21 +08:00
|
|
|
return request({
|
2021-02-13 13:40:29 +08:00
|
|
|
url: '/tool/codegen/create-list-from-db',
|
2021-02-11 01:05:21 +08:00
|
|
|
method: 'post',
|
|
|
|
headers:{
|
|
|
|
'Content-type': 'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
|
|
data: 'tableNames=' + tableNames
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-02-13 13:40:29 +08:00
|
|
|
// 基于 SQL 建表语句,创建代码生成器的表定义
|
|
|
|
export function createCodegenListFromSQL(data) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/create-list-from-sql',
|
|
|
|
method: 'post',
|
|
|
|
headers:{
|
|
|
|
'Content-type': 'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
|
|
data: 'sql=' + data.sql,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-02-11 01:05:21 +08:00
|
|
|
// 删除数据库的表和字段定义
|
|
|
|
export function deleteCodegen(tableId) {
|
|
|
|
return request({
|
|
|
|
url: '/tool/codegen/delete?tableId=' + tableId,
|
|
|
|
method: 'delete'
|
|
|
|
})
|
|
|
|
}
|