diff --git a/src/apis/login.ts b/src/apis/login.ts index c2818d1..369aeab 100644 --- a/src/apis/login.ts +++ b/src/apis/login.ts @@ -1,7 +1,4 @@ import http from 'libs/http' -export interface Login { - username: string - password: string -} -export const login = (params: Login): Promise => http.post('login', params) +export const login = (params: User.Login): Promise => http.post('/auth/login', params) +export const logout = (params: User.Login): Promise => http.post('/auth/logout', params) diff --git a/src/apis/system.ts b/src/apis/system.ts index 99fa143..2d86b3c 100644 --- a/src/apis/system.ts +++ b/src/apis/system.ts @@ -1,3 +1,3 @@ import http from 'libs/http' -export const debugControl = (params: System.CmdControlParams): Promise => http.post('/debug/cmd', params) +export const debugControl = (params: System.CmdControlParams): Promise => http.post('/debug/cmd', params) diff --git a/src/apis/user.ts b/src/apis/user.ts new file mode 100644 index 0000000..665bf9d --- /dev/null +++ b/src/apis/user.ts @@ -0,0 +1,7 @@ +import http from 'libs/http' + +export const current = (): Promise => http.get('/auth/current') +export const addUser = (params: User.User): Promise => http.post('/user', params) +export const updateUser = (params: User.User): Promise => http.put('/user', params) +export const userList = (params: System.Page): Promise> => http.get('/user/list', { params }) +export const delUser = (params: string): Promise => http.delete(`/user/${params}`) diff --git a/src/types/socket.d.ts b/src/types/socket.d.ts index 200c6cc..84064f9 100644 --- a/src/types/socket.d.ts +++ b/src/types/socket.d.ts @@ -1,25 +1,16 @@ declare namespace Socket { - type Response = NotificationResponse | MachineStateResponse + type Response = NotificationResponse - interface NotificationResponse { - type: 'notification' - data: NotificationData + interface cmdResponse { + type: 'cmd_debug' | 'cmd_response' + data: cmdData } - interface MachineStateResponse { - type: 'machineState' - data: MachineStateData - } - interface NotificationData { + interface cmdData { commandId: string command: string - level: string + status: 'receive' | 'start' | 'device_result' | 'device_send' | 'success' | 'error' | 'finish' title: string content: string - dateTime: string - } - - type MachineStateData = MachineStateBase & { - [key: string]: any } } diff --git a/src/types/System.d.ts b/src/types/system.d.ts similarity index 63% rename from src/types/System.d.ts rename to src/types/system.d.ts index 9aea243..9d8f1cb 100644 --- a/src/types/System.d.ts +++ b/src/types/system.d.ts @@ -15,4 +15,17 @@ declare namespace System { interface SystemUser { username: string } + interface ApiResponse { + code: string + data: T + msg: string + } + interface Page { + pageNum: number + pageSize: number + } + interface PageResponse { + list: T[] + total: number + } } diff --git a/src/types/user.d.ts b/src/types/user.d.ts new file mode 100644 index 0000000..06ac548 --- /dev/null +++ b/src/types/user.d.ts @@ -0,0 +1,17 @@ +declare namespace User { + interface User { + id: number + createTime: string + updateTime: string + username: string + nickname: string + password: string | null + role: string + deleted: string + fixedUser: string + } + interface Login { + username: string + password: string + } +}