refactor: vue3 axios api ...
This commit is contained in:
@@ -1,62 +1,59 @@
|
||||
import { defHttp } from '@/config/axios'
|
||||
import type { CodegenDetailVO, CodegenPreviewVO, CodegenTableVO, DatabaseTableVO } from './types'
|
||||
import { useAxios } from '@/hooks/web/useAxios'
|
||||
import type { CodegenTableVO } from './types'
|
||||
|
||||
const request = useAxios()
|
||||
|
||||
// 查询列表代码生成表定义
|
||||
export const getCodegenTablePageApi = ({ params }) => {
|
||||
return defHttp.get<PageResult<CodegenTableVO>>({ url: '/infra/codegen/table/page', params })
|
||||
export const getCodegenTablePageApi = (params) => {
|
||||
return request.get({ url: '/infra/codegen/table/page', params })
|
||||
}
|
||||
|
||||
// 查询详情代码生成表定义
|
||||
export const getCodegenTableApi = (id: number) => {
|
||||
return defHttp.get<CodegenDetailVO>({ url: '/infra/codegen/detail?tableId=' + id })
|
||||
return request.get({ url: '/infra/codegen/detail?tableId=' + id })
|
||||
}
|
||||
|
||||
// 新增代码生成表定义
|
||||
export const createCodegenTableApi = (params: CodegenTableVO) => {
|
||||
return defHttp.post({ url: '/infra/codegen/create', params })
|
||||
export const createCodegenTableApi = (data: CodegenTableVO) => {
|
||||
return request.post({ url: '/infra/codegen/create', data })
|
||||
}
|
||||
|
||||
// 修改代码生成表定义
|
||||
export const updateCodegenTableApi = (params: CodegenTableVO) => {
|
||||
return defHttp.put({ url: '/infra/codegen/update', params })
|
||||
export const updateCodegenTableApi = (data: CodegenTableVO) => {
|
||||
return request.put({ url: '/infra/codegen/update', data })
|
||||
}
|
||||
|
||||
// 基于数据库的表结构,同步数据库的表和字段定义
|
||||
export const syncCodegenFromDBApi = (id: number) => {
|
||||
return defHttp.put({ url: '/infra/codegen/sync-from-db?tableId=' + id })
|
||||
return request.put({ url: '/infra/codegen/sync-from-db?tableId=' + id })
|
||||
}
|
||||
|
||||
// 基于 SQL 建表语句,同步数据库的表和字段定义
|
||||
export const syncCodegenFromSQLApi = (id: number, sql: string) => {
|
||||
return defHttp.put({
|
||||
url: '/infra/codegen/sync-from-sql?tableId=' + id + '&sql=' + sql,
|
||||
headers: {
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
})
|
||||
return request.put({ url: '/infra/codegen/sync-from-sql?tableId=' + id + '&sql=' + sql })
|
||||
}
|
||||
|
||||
// 预览生成代码
|
||||
export const previewCodegenApi = (id: number) => {
|
||||
return defHttp.get<CodegenPreviewVO[]>({ url: '/infra/codegen/preview?tableId=' + id })
|
||||
return request.get({ url: '/infra/codegen/preview?tableId=' + id })
|
||||
}
|
||||
|
||||
// 下载生成代码
|
||||
export const downloadCodegenApi = (id: number) => {
|
||||
return defHttp.get({ url: '/infra/codegen/download?tableId=' + id, responseType: 'blob' })
|
||||
return request.get({ url: '/infra/codegen/download?tableId=' + id, responseType: 'blob' })
|
||||
}
|
||||
|
||||
// 获得表定义
|
||||
export const getSchemaTableListApi = (params) => {
|
||||
return defHttp.get<DatabaseTableVO[]>({ url: '/infra/codegen/db/table/list', params })
|
||||
return request.get({ url: '/infra/codegen/db/table/list', params })
|
||||
}
|
||||
|
||||
// 基于数据库的表结构,创建代码生成器的表定义
|
||||
export const createCodegenListApi = (params) => {
|
||||
return defHttp.post({ url: '/infra/codegen/create-list', params })
|
||||
export const createCodegenListApi = (data) => {
|
||||
return request.post({ url: '/infra/codegen/create-list', data })
|
||||
}
|
||||
|
||||
// 删除代码生成表定义
|
||||
export const deleteCodegenTableApi = (id: number) => {
|
||||
return defHttp.delete({ url: '/infra/codegen/delete?tableId=' + id })
|
||||
return request.delete({ url: '/infra/codegen/delete?tableId=' + id })
|
||||
}
|
||||
|
Reference in New Issue
Block a user