dark
7 months ago
12 changed files with 202 additions and 33 deletions
-
6src/request.ts
-
31src/service/base.ts
-
25src/service/system.ts
-
2src/store/department.ts
-
10src/store/system.ts
-
9src/store/types/department.d.ts
-
15src/types/department.d.ts
-
23src/types/login.d.ts
-
50src/types/menus.d.ts
-
30src/types/roles.d.ts
-
25src/types/user.d.ts
-
9vite.config.ts
@ -0,0 +1,31 @@ |
|||
import { request, AxiosRequestConfig } from '@/request.ts' |
|||
|
|||
type TPage = { |
|||
page: number |
|||
pageSize: number |
|||
} |
|||
|
|||
export const createCURD = <TParams, TResult>(api: string, options?: AxiosRequestConfig) => { |
|||
|
|||
return { |
|||
list: (params?: TParams & TPage) => { |
|||
return request.get<TResult>(api, { ...options, params }) |
|||
}, |
|||
add: (data: TParams) => { |
|||
return request.post<TResult>(`${api}/add`, data, options) |
|||
}, |
|||
update: (id: number, data: TParams) => { |
|||
return request.put(`${api}/${id}`, data, options) |
|||
}, |
|||
delete: (id: number) => { |
|||
return request.delete(`${api}/delete`, { ...options, params: { id } }) |
|||
}, |
|||
batchDelete: (ids: number[]) => { |
|||
return request.delete(`${api}/deletes`, { ...options, params: { ids } }) |
|||
}, |
|||
info: (id: number) => { |
|||
return request.get<TResult>(`${api}/${id}`, options) |
|||
} |
|||
} |
|||
|
|||
} |
@ -1,23 +1,16 @@ |
|||
import request from '../request.ts' |
|||
import { LoginRequest, LoginResponse } from '@/types/login' |
|||
import { createCURD } from '@/service/base.ts' |
|||
|
|||
const systemServ = { |
|||
|
|||
dept: { |
|||
...createCURD('/sys/dept') |
|||
}, |
|||
menus: { |
|||
list: () => { |
|||
return request.get('/menus') |
|||
}, |
|||
add: (data: any) => { |
|||
return request.post('/menus', data) |
|||
}, |
|||
update: (id: number| string, data: any) => { |
|||
return request.put(`/menus/${id}`, data) |
|||
}, |
|||
delete: (id: number| string) => { |
|||
return request.delete(`/menus/${id}`) |
|||
}, |
|||
info: (id: number| string) => { |
|||
return request.get(`/menus/${id}`) |
|||
} |
|||
...createCURD('/sys/menu') |
|||
}, |
|||
login: (data: LoginRequest) => { |
|||
return request.post<LoginResponse>('/sys/login', data) |
|||
} |
|||
|
|||
} |
|||
|
@ -1,9 +0,0 @@ |
|||
|
|||
export interface IDepartment { |
|||
id: string |
|||
name: string |
|||
parentId: number |
|||
order: number |
|||
createAt: string |
|||
updateAt: string |
|||
} |
@ -0,0 +1,15 @@ |
|||
|
|||
export interface IDepartment { |
|||
id: number, |
|||
parent_id: number, |
|||
manager_user_id: number, |
|||
phone: string, |
|||
name: string, |
|||
sort: number, |
|||
status: string, |
|||
remark: string |
|||
} |
|||
|
|||
export interface DepartmentRequest extends IDepartment { |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
|
|||
export interface LoginLogRequest { |
|||
key: string, |
|||
start: string, |
|||
end: string, |
|||
order: string, |
|||
prop: string, |
|||
page: number, |
|||
pageSize: number |
|||
} |
|||
|
|||
export interface LoginRequest { |
|||
'mfa_status': boolean; |
|||
'username': string; |
|||
'password': string; |
|||
'code': string; |
|||
} |
|||
|
|||
export interface LoginResponse { |
|||
'token': string; |
|||
'mfa_status': boolean; |
|||
} |
|||
|
@ -0,0 +1,50 @@ |
|||
|
|||
export interface MenuButton { |
|||
code: string, |
|||
label: string |
|||
} |
|||
export interface IMenu { |
|||
parent_id: number, |
|||
parent_path: string, |
|||
sort: number, |
|||
code: string, |
|||
name: string, |
|||
description: string, |
|||
sequence: number, |
|||
type: string, |
|||
path: string, |
|||
properties: string, |
|||
status: string |
|||
buttons: MenuButton[] |
|||
} |
|||
|
|||
export interface MenuRequest extends IMenu { |
|||
|
|||
} |
|||
|
|||
export interface MenuResponse { |
|||
id: number, |
|||
} |
|||
|
|||
|
|||
export interface MenuDropRequest { |
|||
source: number, |
|||
target: number, |
|||
action: string |
|||
} |
|||
|
|||
|
|||
export interface MenuListRequest { |
|||
order: string, |
|||
prop: string, |
|||
page: number, |
|||
pageSize: number |
|||
} |
|||
|
|||
|
|||
export interface MenuListResponse { |
|||
page: number, |
|||
pageSize: number, |
|||
total: number, |
|||
rows: IMenu[] |
|||
} |
@ -0,0 +1,30 @@ |
|||
|
|||
export interface IRole { |
|||
sort: number, |
|||
code: string, |
|||
name: string, |
|||
description: string, |
|||
sequence: number, |
|||
status: string, |
|||
menu_ids: number[] |
|||
} |
|||
|
|||
export interface RoleRequest extends IRole { |
|||
|
|||
} |
|||
|
|||
export interface RoleListResponse { |
|||
key: string, |
|||
order: string, |
|||
prop: string, |
|||
page: number, |
|||
pageSize: number |
|||
|
|||
} |
|||
|
|||
export interface RoleListResponse { |
|||
page: number, |
|||
pageSize: number, |
|||
total: number, |
|||
rows: IRole[] |
|||
} |
@ -0,0 +1,25 @@ |
|||
|
|||
|
|||
export interface IUser { |
|||
id: number, |
|||
created_at: string, |
|||
created_by: number, |
|||
updated_at: string, |
|||
updated_by: number, |
|||
username: string, |
|||
dept_id: number, |
|||
dept_name: string, |
|||
name: string, |
|||
phone: string, |
|||
email: string, |
|||
remark: string, |
|||
status: string, |
|||
mfa_status: boolean, |
|||
} |
|||
|
|||
export interface IUserInfo { |
|||
info: IUser, |
|||
buttons: string[], |
|||
nickname: string, |
|||
avatar: string |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue