Skip to content

Commit

Permalink
chore: 优化 apis 导入,随着模块和接口的增加,方便维护
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 6, 2024
1 parent cb03111 commit 8a80db0
Show file tree
Hide file tree
Showing 80 changed files with 210 additions and 179 deletions.
6 changes: 4 additions & 2 deletions src/apis/area/index.ts
Original file line number Diff line number Diff line change
@@ -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)
}
24 changes: 13 additions & 11 deletions src/apis/auth/index.ts
Original file line number Diff line number Diff line change
@@ -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 退出登录 */
Expand All @@ -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`)
}
10 changes: 6 additions & 4 deletions src/apis/common/captcha.ts
Original file line number Diff line number Diff line change
@@ -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 获取短信验证码 */
Expand All @@ -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)
}
8 changes: 5 additions & 3 deletions src/apis/common/home.ts
Original file line number Diff line number Diff line change
@@ -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`)
}
14 changes: 8 additions & 6 deletions src/apis/monitor/log.ts
Original file line number Diff line number Diff line change
@@ -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)
}
8 changes: 5 additions & 3 deletions src/apis/monitor/online.ts
Original file line number Diff line number Diff line change
@@ -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 强退在线用户 */
Expand Down
8 changes: 5 additions & 3 deletions src/apis/schedule/job.ts
Original file line number Diff line number Diff line change
@@ -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 查询任务组列表 */
Expand All @@ -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 新增任务 */
Expand Down
16 changes: 9 additions & 7 deletions src/apis/schedule/log.ts
Original file line number Diff line number Diff line change
@@ -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 查询任务日志详情 */
Expand All @@ -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)
}
12 changes: 7 additions & 5 deletions src/apis/system/dept.ts
Original file line number Diff line number Diff line change
@@ -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 新增部门 */
Expand All @@ -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)
}
16 changes: 9 additions & 7 deletions src/apis/system/dict.ts
Original file line number Diff line number Diff line change
@@ -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 新增字典 */
Expand All @@ -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 新增字典项 */
Expand Down
10 changes: 6 additions & 4 deletions src/apis/system/file.ts
Original file line number Diff line number Diff line change
@@ -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 修改文件 */
Expand All @@ -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`)
}
10 changes: 6 additions & 4 deletions src/apis/system/menu.ts
Original file line number Diff line number Diff line change
@@ -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 新增菜单 */
Expand Down
8 changes: 5 additions & 3 deletions src/apis/system/message.ts
Original file line number Diff line number Diff line change
@@ -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 删除消息 */
Expand Down
10 changes: 6 additions & 4 deletions src/apis/system/notice.ts
Original file line number Diff line number Diff line change
@@ -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 新增公告 */
Expand Down
Loading

0 comments on commit 8a80db0

Please sign in to comment.