chore: 优化 apis 导入,随着模块和接口的增加,方便维护

This commit is contained in:
2024-09-06 21:14:13 +08:00
parent cb03111c22
commit 8a80db0f92
80 changed files with 210 additions and 179 deletions

View File

@@ -1,7 +1,9 @@
import type * as Area from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
/** @desc 获取地区列表 */
export const getAreaList = (params: { type: 'province' | 'city' | 'area', code?: string }) => {
return http.get<Area.AreaItem>('/area/list', params)
return http.get<T.AreaItem>('/area/list', params)
}

View File

@@ -1,31 +1,33 @@
import type * as Auth from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/auth'
/** @desc 账号登录 */
export function accountLogin(req: Auth.AccountLoginReq) {
return http.post<Auth.LoginResp>(`${BASE_URL}/account`, req)
export function accountLogin(req: T.AccountLoginReq) {
return http.post<T.LoginResp>(`${BASE_URL}/account`, req)
}
/** @desc 手机号登录 */
export function phoneLogin(req: Auth.PhoneLoginReq) {
return http.post<Auth.LoginResp>(`${BASE_URL}/phone`, req)
export function phoneLogin(req: T.PhoneLoginReq) {
return http.post<T.LoginResp>(`${BASE_URL}/phone`, req)
}
/** @desc 邮箱登录 */
export function emailLogin(req: Auth.EmailLoginReq) {
return http.post<Auth.LoginResp>(`${BASE_URL}/email`, req)
export function emailLogin(req: T.EmailLoginReq) {
return http.post<T.LoginResp>(`${BASE_URL}/email`, req)
}
/** @desc 三方账号登录 */
export function socialLogin(source: string, req: any) {
return http.post<Auth.LoginResp>(`/oauth/${source}`, req)
return http.post<T.LoginResp>(`/oauth/${source}`, req)
}
/** @desc 三方账号登录授权 */
export function socialAuth(source: string) {
return http.get<Auth.SocialAuthAuthorizeResp>(`/oauth/${source}`)
return http.get<T.SocialAuthAuthorizeResp>(`/oauth/${source}`)
}
/** @desc 退出登录 */
@@ -35,10 +37,10 @@ export function logout() {
/** @desc 获取用户信息 */
export const getUserInfo = () => {
return http.get<Auth.UserInfo>(`${BASE_URL}/user/info`)
return http.get<T.UserInfo>(`${BASE_URL}/user/info`)
}
/** @desc 获取路由信息 */
export const getUserRoute = () => {
return http.get<Auth.RouteItem[]>(`${BASE_URL}/route`)
return http.get<T.RouteItem[]>(`${BASE_URL}/route`)
}

View File

@@ -1,11 +1,13 @@
import type * as Common from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/captcha'
/** @desc 获取图片验证码 */
export function getImageCaptcha() {
return http.get<Common.ImageCaptchaResp>(`${BASE_URL}/image`)
return http.get<T.ImageCaptchaResp>(`${BASE_URL}/image`)
}
/** @desc 获取短信验证码 */
@@ -20,10 +22,10 @@ export function getEmailCaptcha(query: { email: string }) {
/** @desc 获取行为验证码 */
export function getBehaviorCaptcha(req: any) {
return http.get<Common.BehaviorCaptchaResp>(`${BASE_URL}/behavior`, req)
return http.get<T.BehaviorCaptchaResp>(`${BASE_URL}/behavior`, req)
}
/** @desc 校验行为验证码 */
export function checkBehaviorCaptcha(req: any) {
return http.post<Common.CheckBehaviorCaptchaResp>(`${BASE_URL}/behavior`, req)
return http.post<T.CheckBehaviorCaptchaResp>(`${BASE_URL}/behavior`, req)
}

View File

@@ -1,14 +1,16 @@
import type * as Common from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/dashboard'
/** @desc 查询访问趋势 */
export function listDashboardAccessTrend(days: number) {
return http.get<Common.DashboardAccessTrendResp[]>(`${BASE_URL}/access/trend/${days}`)
return http.get<T.DashboardAccessTrendResp[]>(`${BASE_URL}/access/trend/${days}`)
}
/** @desc 查询公告列表 */
export function listDashboardNotice() {
return http.get<Common.DashboardNoticeResp[]>(`${BASE_URL}/notice`)
return http.get<T.DashboardNoticeResp[]>(`${BASE_URL}/notice`)
}

View File

@@ -1,24 +1,26 @@
import type * as Monitor from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/log'
/** @desc 查询日志列表 */
export function listLog(query: Monitor.LogPageQuery) {
return http.get<PageRes<Monitor.LogResp[]>>(`${BASE_URL}`, query)
export function listLog(query: T.LogPageQuery) {
return http.get<PageRes<T.LogResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询日志详情 */
export function getLog(id: string) {
return http.get<Monitor.LogDetailResp>(`${BASE_URL}/${id}`)
return http.get<T.LogDetailResp>(`${BASE_URL}/${id}`)
}
/** @desc 导出登录日志 */
export function exportLoginLog(query: Monitor.LogQuery) {
export function exportLoginLog(query: T.LogQuery) {
return http.download<any>(`${BASE_URL}/export/login`, query)
}
/** @desc 导出操作日志 */
export function exportOperationLog(query: Monitor.LogQuery) {
export function exportOperationLog(query: T.LogQuery) {
return http.download<any>(`${BASE_URL}/export/operation`, query)
}

View File

@@ -1,11 +1,13 @@
import type * as Monitor from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/monitor/online'
/** @desc 查询在线用户列表 */
export function listOnlineUser(query: Monitor.OnlineUserPageQuery) {
return http.get<PageRes<Monitor.OnlineUserResp[]>>(`${BASE_URL}`, query)
export function listOnlineUser(query: T.OnlineUserPageQuery) {
return http.get<PageRes<T.OnlineUserResp[]>>(`${BASE_URL}`, query)
}
/** @desc 强退在线用户 */

View File

@@ -1,6 +1,8 @@
import type * as Schedule from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/schedule/job'
/** @desc 查询任务组列表 */
@@ -9,8 +11,8 @@ export function listGroup() {
}
/** @desc 查询任务列表 */
export function listJob(query: Schedule.JobPageQuery) {
return http.get<PageRes<Schedule.JobResp[]>>(`${BASE_URL}`, query)
export function listJob(query: T.JobPageQuery) {
return http.get<PageRes<T.JobResp[]>>(`${BASE_URL}`, query)
}
/** @desc 新增任务 */

View File

@@ -1,11 +1,13 @@
import type * as Schedule from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/schedule/log'
/** @desc 查询任务日志列表 */
export function listJobLog(query: Schedule.JobLogPageQuery) {
return http.get<PageRes<Schedule.JobLogResp[]>>(`${BASE_URL}`, query)
export function listJobLog(query: T.JobLogPageQuery) {
return http.get<PageRes<T.JobLogResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询任务日志详情 */
@@ -24,11 +26,11 @@ export function retryJob(id: number) {
}
/** @desc 查询任务实例列表 */
export function listJobInstance(query: Schedule.JobInstanceQuery) {
return http.get<Schedule.JobInstanceResp[]>(`${BASE_URL}/instance`, query)
export function listJobInstance(query: T.JobInstanceQuery) {
return http.get<T.JobInstanceResp[]>(`${BASE_URL}/instance`, query)
}
/** @desc 查询任务实例日志列表 */
export function listJobInstanceLog(query: Schedule.JobInstanceLogQuery) {
return http.get<Schedule.JobInstanceLogResp>(`${BASE_URL}/instance/log`, query)
export function listJobInstanceLog(query: T.JobInstanceLogQuery) {
return http.get<T.JobInstanceLogResp>(`${BASE_URL}/instance/log`, query)
}

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/dept'
/** @desc 查询部门列表 */
export function listDept(query: System.DeptQuery) {
return http.get<System.DeptResp[]>(`${BASE_URL}/tree`, query)
export function listDept(query: T.DeptQuery) {
return http.get<T.DeptResp[]>(`${BASE_URL}/tree`, query)
}
/** @desc 查询部门详情 */
export function getDept(id: string) {
return http.get<System.DeptResp>(`${BASE_URL}/${id}`)
return http.get<T.DeptResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增部门 */
@@ -29,6 +31,6 @@ export function deleteDept(id: string) {
}
/** @desc 导出部门 */
export function exportDept(query: System.DeptQuery) {
export function exportDept(query: T.DeptQuery) {
return http.download<any>(`${BASE_URL}/export`, query)
}

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/dict'
/** @desc 查询字典列表 */
export function listDict(query: System.DictQuery) {
return http.get<System.DictResp[]>(`${BASE_URL}/list`, query)
export function listDict(query: T.DictQuery) {
return http.get<T.DictResp[]>(`${BASE_URL}/list`, query)
}
/** @desc 查询字典详情 */
export function getDict(id: string) {
return http.get<System.DictResp>(`${BASE_URL}/${id}`)
return http.get<T.DictResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增字典 */
@@ -29,13 +31,13 @@ export function deleteDict(id: string) {
}
/** @desc 查询字典项列表 */
export function listDictItem(query: System.DictItemPageQuery) {
return http.get<PageRes<System.DictItemResp[]>>(`${BASE_URL}/item`, query)
export function listDictItem(query: T.DictItemPageQuery) {
return http.get<PageRes<T.DictItemResp[]>>(`${BASE_URL}/item`, query)
}
/** @desc 查询字典项详情 */
export function getDictItem(id: string) {
return http.get<System.DictItemResp>(`${BASE_URL}/item/${id}`)
return http.get<T.DictItemResp>(`${BASE_URL}/item/${id}`)
}
/** @desc 新增字典项 */

View File

@@ -1,11 +1,13 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/file'
/** @desc 查询文件列表 */
export function listFile(query: System.FilePageQuery) {
return http.get<PageRes<System.FileItem[]>>(`${BASE_URL}`, query)
export function listFile(query: T.FilePageQuery) {
return http.get<PageRes<T.FileItem[]>>(`${BASE_URL}`, query)
}
/** @desc 修改文件 */
@@ -20,5 +22,5 @@ export function deleteFile(ids: string | Array<string>) {
/** @desc 查询文件资源统计统计 */
export function getFileStatistics() {
return http.get<System.FileStatisticsResp>(`${BASE_URL}/statistics`)
return http.get<T.FileStatisticsResp>(`${BASE_URL}/statistics`)
}

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/menu'
/** @desc 查询菜单列表 */
export function listMenu(query: System.MenuQuery) {
return http.get<System.MenuResp[]>(`${BASE_URL}/tree`, query)
export function listMenu(query: T.MenuQuery) {
return http.get<T.MenuResp[]>(`${BASE_URL}/tree`, query)
}
/** @desc 查询菜单详情 */
export function getMenu(id: string) {
return http.get<System.MenuResp>(`${BASE_URL}/${id}`)
return http.get<T.MenuResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增菜单 */

View File

@@ -1,11 +1,13 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/message'
/** @desc 查询消息列表 */
export function listMessage(query: System.MessagePageQuery) {
return http.get<PageRes<System.MessageResp[]>>(`${BASE_URL}`, query)
export function listMessage(query: T.MessagePageQuery) {
return http.get<PageRes<T.MessageResp[]>>(`${BASE_URL}`, query)
}
/** @desc 删除消息 */

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/notice'
/** @desc 查询公告列表 */
export function listNotice(query: System.NoticePageQuery) {
return http.get<PageRes<System.NoticeResp[]>>(`${BASE_URL}`, query)
export function listNotice(query: T.NoticePageQuery) {
return http.get<PageRes<T.NoticeResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询公告详情 */
export function getNotice(id: string) {
return http.get<System.NoticeResp>(`${BASE_URL}/${id}`)
return http.get<T.NoticeResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增公告 */

View File

@@ -1,11 +1,13 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/option'
/** @desc 查询参数列表 */
export function listOption(query: System.OptionQuery) {
return http.get<System.OptionResp[]>(`${BASE_URL}`, query)
export function listOption(query: T.OptionQuery) {
return http.get<T.OptionResp[]>(`${BASE_URL}`, query)
}
/** @desc 修改参数 */
@@ -14,6 +16,6 @@ export function updateOption(data: any) {
}
/** @desc 重置参数 */
export function resetOptionValue(query: System.OptionQuery) {
export function resetOptionValue(query: T.OptionQuery) {
return http.patch(`${BASE_URL}/value`, query)
}

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/role'
/** @desc 查询角色列表 */
export function listRole(query: System.RolePageQuery) {
return http.get<PageRes<System.RoleResp[]>>(`${BASE_URL}`, query)
export function listRole(query: T.RolePageQuery) {
return http.get<PageRes<T.RoleResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询角色详情 */
export function getRole(id: string) {
return http.get<System.RoleDetailResp>(`${BASE_URL}/${id}`)
return http.get<T.RoleDetailResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增角色 */

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/storage'
/** @desc 查询存储列表 */
export function listStorage(query: System.StoragePageQuery) {
return http.get<PageRes<System.StorageResp[]>>(`${BASE_URL}`, query)
export function listStorage(query: T.StoragePageQuery) {
return http.get<PageRes<T.StorageResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询存储详情 */
export function getStorage(id: string) {
return http.get<System.StorageResp>(`${BASE_URL}/${id}`)
return http.get<T.StorageResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增存储 */

View File

@@ -1,16 +1,18 @@
import type * as System from './type'
import type * as T from './type'
import http from '@/utils/http'
export type * from './type'
const BASE_URL = '/system/user'
/** @desc 查询用户列表 */
export function listUser(query: System.UserPageQuery) {
return http.get<PageRes<System.UserResp[]>>(`${BASE_URL}`, query)
export function listUser(query: T.UserPageQuery) {
return http.get<PageRes<T.UserResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询用户详情 */
export function getUser(id: string) {
return http.get<System.UserDetailResp>(`${BASE_URL}/${id}`)
return http.get<T.UserDetailResp>(`${BASE_URL}/${id}`)
}
/** @desc 新增用户 */
@@ -29,7 +31,7 @@ export function deleteUser(ids: string | Array<string>) {
}
/** @desc 导出用户 */
export function exportUser(query: System.UserQuery) {
export function exportUser(query: T.UserQuery) {
return http.download(`${BASE_URL}/export`, query)
}

View File

@@ -1,32 +1,34 @@
import type * as Tool from './type'
import type { LabelValueState } from '@/types/global'
import type * as T from './type'
import http from '@/utils/http'
import type { LabelValueState } from '@/types/global'
export type * from './type'
const BASE_URL = '/generator'
/** @desc 查询代码生成列表 */
export function listGenerator(query: Tool.TablePageQuery) {
return http.get<PageRes<Tool.TableResp[]>>(`${BASE_URL}/table`, query)
export function listGenerator(query: T.TablePageQuery) {
return http.get<PageRes<T.TableResp[]>>(`${BASE_URL}/table`, query)
}
/** @desc 查询字段配置列表 */
export function listFieldConfig(tableName: string, requireSync: boolean) {
return http.get<Tool.FieldConfigResp[]>(`${BASE_URL}/field/${tableName}?requireSync=${requireSync}`)
return http.get<T.FieldConfigResp[]>(`${BASE_URL}/field/${tableName}?requireSync=${requireSync}`)
}
/** @desc 查询生成配置信息 */
export function getGenConfig(tableName: string) {
return http.get<Tool.GenConfigResp>(`${BASE_URL}/config/${tableName}`)
return http.get<T.GenConfigResp>(`${BASE_URL}/config/${tableName}`)
}
/** @desc 保存配置信息 */
export function saveGenConfig(tableName: string, req: Tool.GeneratorConfigResp) {
export function saveGenConfig(tableName: string, req: T.GeneratorConfigResp) {
return http.post(`${BASE_URL}/config/${tableName}`, req)
}
/** @desc 生成预览 */
export function genPreview(tableName: string) {
return http.get<Tool.GeneratePreviewResp[]>(`${BASE_URL}/preview/${tableName}`)
return http.get<T.GeneratePreviewResp[]>(`${BASE_URL}/preview/${tableName}`)
}
/** @desc 生成代码 */