refactor: vue3 axios api ...

This commit is contained in:
xingyu
2022-07-19 22:33:54 +08:00
parent ba96eef51a
commit 9e2e220b69
121 changed files with 1022 additions and 9700 deletions

View File

@ -1,12 +1,13 @@
import { defHttp } from '@/config/axios'
import { ApiAccessLogVO } from './types'
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
// 查询列表API 访问日志
export const getApiAccessLogPageApi = ({ params }) => {
return defHttp.get<PageResult<ApiAccessLogVO>>({ url: '/infra/api-access-log/page', params })
export const getApiAccessLogPageApi = (params) => {
return request.get({ url: '/infra/api-access-log/page', params })
}
// 导出API 访问日志
export const exportApiAccessLogApi = (params) => {
return defHttp.get({ url: '/infra/api-access-log/export-excel', params, responseType: 'blob' })
return request.get({ url: '/infra/api-access-log/export-excel', params, responseType: 'blob' })
}

View File

@ -1,19 +1,20 @@
import { defHttp } from '@/config/axios'
import { ApiErrorLogVO } from './types'
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
// 查询列表API 访问日志
export const getApiErrorLogPageApi = ({ params }) => {
return defHttp.get<PageResult<ApiErrorLogVO>>({ url: '/infra/api-error-log/page', params })
export const getApiErrorLogPageApi = (params) => {
return request.get({ url: '/infra/api-error-log/page', params })
}
// 更新 API 错误日志的处理状态
export const updateApiErrorLogPageApi = (id: number, processStatus: number) => {
return defHttp.put({
return request.put({
url: '/infra/api-error-log/update-status?id=' + id + '&processStatus=' + processStatus
})
}
// 导出API 访问日志
export const exportApiErrorLogApi = ({ params }) => {
return defHttp.get({ url: '/infra/api-error-log/export-excel', params, responseType: 'blob' })
export const exportApiErrorLogApi = (params) => {
return request.get({ url: '/infra/api-error-log/export-excel', params, responseType: 'blob' })
}

View File

@ -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 })
}

View File

@ -1,37 +1,39 @@
import { defHttp } from '@/config/axios'
import { useAxios } from '@/hooks/web/useAxios'
import type { ConfigVO } from './types'
const request = useAxios()
// 查询参数列表
export const getConfigPageApi = ({ params }) => {
return defHttp.get<PageResult<ConfigVO>>({ url: '/infra/config/page', params })
export const getConfigPageApi = (params) => {
return request.get({ url: '/infra/config/page', params })
}
// 查询参数详情
export const getConfigApi = (id: number) => {
return defHttp.get<ConfigVO>({ url: '/infra/config/get?id=' + id })
return request.get({ url: '/infra/config/get?id=' + id })
}
// 根据参数键名查询参数值
export const getConfigKeyApi = (configKey: string) => {
return defHttp.get<ConfigVO>({ url: '/infra/config/get-value-by-key?key=' + configKey })
return request.get({ url: '/infra/config/get-value-by-key?key=' + configKey })
}
// 新增参数
export const createConfigApi = (params: ConfigVO) => {
return defHttp.post({ url: '/infra/config/create', params })
export const createConfigApi = (data: ConfigVO) => {
return request.post({ url: '/infra/config/create', data })
}
// 修改参数
export const updateConfigApi = (params: ConfigVO) => {
return defHttp.put({ url: '/infra/config/update', params })
export const updateConfigApi = (data: ConfigVO) => {
return request.put({ url: '/infra/config/update', data })
}
// 删除参数
export const deleteConfigApi = (id: number) => {
return defHttp.delete({ url: '/infra/config/delete?id=' + id })
return request.delete({ url: '/infra/config/delete?id=' + id })
}
// 导出参数
export const exportConfigApi = ({ params }) => {
return defHttp.get({ url: '/infra/config/export', params, responseType: 'blob' })
export const exportConfigApi = (params) => {
return request.get({ url: '/infra/config/export', params, responseType: 'blob' })
}

View File

@ -1,27 +1,29 @@
import { defHttp } from '@/config/axios'
import { useAxios } from '@/hooks/web/useAxios'
import type { DataSourceConfigVO } from './types'
const request = useAxios()
// 查询数据源配置列表
export const getDataSourceConfigListApi = () => {
return defHttp.get<DataSourceConfigVO[]>({ url: '/infra/data-source-config/list' })
return request.get({ url: '/infra/data-source-config/list' })
}
// 查询数据源配置详情
export const getDataSourceConfigApi = (id: number) => {
return defHttp.get<DataSourceConfigVO>({ url: '/infra/data-source-config/get?id=' + id })
return request.get({ url: '/infra/data-source-config/get?id=' + id })
}
// 新增数据源配置
export const createDataSourceConfigApi = (params: DataSourceConfigVO) => {
return defHttp.post({ url: '/infra/data-source-config/create', params })
export const createDataSourceConfigApi = (data: DataSourceConfigVO) => {
return request.post({ url: '/infra/data-source-config/create', data })
}
// 修改数据源配置
export const updateDataSourceConfigApi = (params: DataSourceConfigVO) => {
return defHttp.put({ url: '/infra/data-source-config/update', params })
export const updateDataSourceConfigApi = (data: DataSourceConfigVO) => {
return request.put({ url: '/infra/data-source-config/update', data })
}
// 删除数据源配置
export const deleteDataSourceConfigApi = (id: number) => {
return defHttp.delete({ url: '/infra/data-source-config/delete?id=' + id })
return request.delete({ url: '/infra/data-source-config/delete?id=' + id })
}

View File

@ -1,16 +1,18 @@
import { defHttp } from '@/config/axios'
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
// 导出Html
export const exportHtmlApi = () => {
return defHttp.get({ url: '/infra/db-doc/export-html', responseType: 'blob' })
return request.get({ url: '/infra/db-doc/export-html', responseType: 'blob' })
}
// 导出Word
export const exportWordApi = () => {
return defHttp.get({ url: '/infra/db-doc/export-word', responseType: 'blob' })
return request.get({ url: '/infra/db-doc/export-word', responseType: 'blob' })
}
// 导出Markdown
export const exportMarkdownApi = () => {
return defHttp.get({ url: '/infra/db-doc/export-markdown', responseType: 'blob' })
return request.get({ url: '/infra/db-doc/export-markdown', responseType: 'blob' })
}

View File

@ -1,12 +1,13 @@
import { defHttp } from '@/config/axios'
import type { FileVO } from './types'
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
// 查询文件列表
export const getFilePageApi = ({ params }) => {
return defHttp.get<PageResult<FileVO>>({ url: '/infra/file/page', params })
export const getFilePageApi = (params) => {
return request.get({ url: '/infra/file/page', params })
}
// 删除文件
export const deleteFileApi = (id: number) => {
return defHttp.delete({ url: '/infra/file/delete?id=' + id })
return request.delete({ url: '/infra/file/delete?id=' + id })
}

View File

@ -1,37 +1,39 @@
import { defHttp } from '@/config/axios'
import { useAxios } from '@/hooks/web/useAxios'
import type { FileConfigVO } from './types'
const request = useAxios()
// 查询文件配置列表
export const getFileConfigPageApi = ({ params }) => {
return defHttp.get<PageResult<FileConfigVO>>({ url: '/infra/file-config/page', params })
export const getFileConfigPageApi = (params) => {
return request.get({ url: '/infra/file-config/page', params })
}
// 查询文件配置详情
export const getFileConfigApi = (id: number) => {
return defHttp.get<FileConfigVO>({ url: '/infra/file-config/get?id=' + id })
return request.get({ url: '/infra/file-config/get?id=' + id })
}
// 更新文件配置为主配置
export const updateFileConfigMasterApi = (id: number) => {
return defHttp.get<FileConfigVO>({ url: '/infra/file-config/update-master?id=' + id })
return request.get({ url: '/infra/file-config/update-master?id=' + id })
}
// 新增文件配置
export const createFileConfigApi = (params: FileConfigVO) => {
return defHttp.post({ url: '/infra/file-config/create', params })
export const createFileConfigApi = (data: FileConfigVO) => {
return request.post({ url: '/infra/file-config/create', data })
}
// 修改文件配置
export const updateFileConfigApi = (params: FileConfigVO) => {
return defHttp.put({ url: '/infra/file-config/update', params })
export const updateFileConfigApi = (data: FileConfigVO) => {
return request.put({ url: '/infra/file-config/update', data })
}
// 删除文件配置
export const deleteFileConfigApi = (id: number) => {
return defHttp.delete({ url: '/infra/file-config/delete?id=' + id })
return request.delete({ url: '/infra/file-config/delete?id=' + id })
}
// 测试文件配置
export const testFileConfigApi = (id: number) => {
return defHttp.get({ url: '/infra/file-config/test?id=' + id })
return request.get({ url: '/infra/file-config/test?id=' + id })
}

View File

@ -1,38 +1,36 @@
import { defHttp } from '@/config/axios'
import { useAxios } from '@/hooks/web/useAxios'
import type { JobVO } from './types'
const request = useAxios()
// 任务列表
export const getJobPageApi = ({ params }) => {
return defHttp.get<PageResult<JobVO>>({ url: '/infra/job/page', params })
export const getJobPageApi = (params) => {
return request.get({ url: '/infra/job/page', params })
}
// 任务详情
export const getJobApi = (id: number) => {
return defHttp.get<JobVO>({ url: '/infra/job/get?id=' + id })
return request.get({ url: '/infra/job/get?id=' + id })
}
// 新增任务
export const createJobApi = (params: JobVO) => {
return defHttp.post({ url: '/infra/job/create', params })
export const createJobApi = (data: JobVO) => {
return request.post({ url: '/infra/job/create', data })
}
// 修改定时任务调度
export const updateJobApi = (params: JobVO) => {
return defHttp.put({ url: '/infra/job/update', params })
return request.put({ url: '/infra/job/update', params })
}
// 删除定时任务调度
export const deleteJobApi = (id: number) => {
return defHttp.delete({ url: '/infra/job/delete?id=' + id })
return request.delete({ url: '/infra/job/delete?id=' + id })
}
// 导出定时任务调度
export const exportJobApi = (params) => {
return defHttp.get({
url: '/infra/job/export-excel',
params,
responseType: 'blob'
})
return request.get({ url: '/infra/job/export-excel', params, responseType: 'blob' })
}
// 任务状态修改
@ -41,15 +39,15 @@ export const updateJobStatusApi = (id: number, status: number) => {
id,
status
}
return defHttp.put({ url: '/infra/job/update-status', data: data })
return request.put({ url: '/infra/job/update-status', data: data })
}
// 定时任务立即执行一次
export const runJobApi = (id: number) => {
return defHttp.put({ url: '/infra/job/trigger?id=' + id })
return request.put({ url: '/infra/job/trigger?id=' + id })
}
// 获得定时任务的下 n 次执行时间
export const getJobNextTimesApi = (id: number) => {
return defHttp.get({ url: '/infra/job/get_next_times?id=' + id })
return request.get({ url: '/infra/job/get_next_times?id=' + id })
}

View File

@ -1,19 +1,20 @@
import { defHttp } from '@/config/axios'
import type { JobLogVO } from './types'
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
// 任务日志列表
export const getJobLogPageApi = ({ params }) => {
return defHttp.get<PageResult<JobLogVO>>({ url: '/infra/job-log/page', params })
export const getJobLogPageApi = (params) => {
return request.get({ url: '/infra/job-log/page', params })
}
// 任务日志详情
export const getJobLogApi = (id: number) => {
return defHttp.get<JobLogVO>({ url: '/infra/job-log/get?id=' + id })
return request.get({ url: '/infra/job-log/get?id=' + id })
}
// 导出定时任务日志
export const exportJobLogApi = (params) => {
return defHttp.get({
return request.get({
url: '/infra/job-log/export-excel',
params,
responseType: 'blob'

View File

@ -1,16 +1,25 @@
import { defHttp } from '@/config/axios'
import { RedisKeyInfo, RedisMonitorInfoVO } from '@/api/infra/redis/types'
import { useAxios } from '@/hooks/web/useAxios'
const request = useAxios()
/**
* 获取redis 监控信息
*/
export const redisMonitorInfo = () => {
return defHttp.get<RedisMonitorInfoVO>({ url: '/infra/redis/get-monitor-info' })
export const getCacheApi = () => {
return request.get({ url: '/infra/redis/get-monitor-info' })
}
// 获取模块
export const getKeyDefineListApi = () => {
return request.get({ url: '/infra/redis/get-key-define-list' })
}
/**
* 获取redis key列表
*/
export const redisKeysInfo = () => {
return defHttp.get<RedisKeyInfo[]>({ url: '/infra/redis/get-key-list' })
export const getKeyListApi = (keyTemplate: string) => {
return request.get({
url: '/infra/redis/get-key-list',
params: {
keyTemplate
}
})
}