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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/detail?tableId=' + tableId,
|
2021-02-09 22:14:01 +08:00
|
|
|
method: 'get',
|
|
|
|
})
|
|
|
|
}
|
2021-02-10 13:41:00 +08:00
|
|
|
|
|
|
|
// 修改代码生成信息
|
|
|
|
export function updateCodegen(data) {
|
|
|
|
return request({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/update',
|
2021-02-10 13:41:00 +08:00
|
|
|
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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/sync-from-sql?tableId=' + tableId,
|
2021-02-13 13:40:29 +08:00
|
|
|
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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/download?tableId=' + tableId,
|
2021-02-10 17:45:04 +08:00
|
|
|
method: 'get',
|
|
|
|
responseType: 'blob'
|
|
|
|
})
|
|
|
|
}
|
2021-02-11 01:05:21 +08:00
|
|
|
|
|
|
|
// 获得表定义分页
|
|
|
|
export function getSchemaTableList(query) {
|
|
|
|
return request({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/db/table/list',
|
2021-02-11 01:05:21 +08:00
|
|
|
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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/create-list-from-sql',
|
2021-02-13 13:40:29 +08:00
|
|
|
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({
|
2022-03-11 00:39:34 +08:00
|
|
|
url: '/infra/codegen/delete?tableId=' + tableId,
|
2021-02-11 01:05:21 +08:00
|
|
|
method: 'delete'
|
|
|
|
})
|
|
|
|
}
|