后台管理页面用户管理新增用户问题修复
This commit is contained in:
@@ -28,7 +28,12 @@ adminApi.interceptors.request.use(
|
||||
|
||||
adminApi.interceptors.response.use(
|
||||
response => {
|
||||
return response.data.data
|
||||
const res = response.data
|
||||
if (res.code !== 200) {
|
||||
message.error(res.message || '请求失败')
|
||||
return Promise.reject(new Error(res.message || '请求失败'))
|
||||
}
|
||||
return res.data
|
||||
},
|
||||
async (error: AxiosError) => {
|
||||
if (error.response?.status === 401) {
|
||||
@@ -46,6 +51,9 @@ adminApi.interceptors.response.use(
|
||||
console.error('跳转到登录页异常:', err)
|
||||
window.location.href = '/admin/login'
|
||||
}
|
||||
} else {
|
||||
const errorMsg = (error.response?.data as any)?.message || error.message || '请求失败'
|
||||
message.error(errorMsg)
|
||||
}
|
||||
|
||||
console.error('Admin API Error:', error)
|
||||
@@ -205,4 +213,77 @@ export const adminShopApi = {
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserVO {
|
||||
id: number
|
||||
shopId?: number
|
||||
shopName?: string
|
||||
nickname: string
|
||||
account: string
|
||||
avatar: string
|
||||
signature?: string
|
||||
level?: string
|
||||
type: number
|
||||
vipId?: number
|
||||
createTime: string
|
||||
updateTime: string
|
||||
status: number
|
||||
phone?: string
|
||||
}
|
||||
|
||||
export interface UserListResponse {
|
||||
list: UserVO[]
|
||||
total: number
|
||||
page: number
|
||||
size: number
|
||||
}
|
||||
|
||||
export interface CreateUserRequest {
|
||||
shopId: number
|
||||
nickname: string
|
||||
account: string
|
||||
phone: string
|
||||
password: string
|
||||
type: number
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; shopId?: number }) => {
|
||||
return adminApi.get<UserListResponse>('/admin/user/list', { params })
|
||||
},
|
||||
createUser: (data: CreateUserRequest) => {
|
||||
return adminApi.post<number>('/admin/user/create', data)
|
||||
},
|
||||
updateUser: (id: number, data: Partial<CreateUserRequest>) => {
|
||||
return adminApi.put<boolean>(`/admin/user/update/${id}`, data)
|
||||
},
|
||||
updateUserStatus: (id: number, status: number) => {
|
||||
return adminApi.put(`/admin/user/status/${id}`, { status })
|
||||
},
|
||||
deleteUser: (id: number) => {
|
||||
return adminApi.delete<boolean>(`/admin/user/delete/${id}`)
|
||||
},
|
||||
resetPassword: (id: number) => {
|
||||
return adminApi.post(`/admin/user/reset-password/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface PermissionVO {
|
||||
id: number
|
||||
permissionName: string
|
||||
permissionCode: string
|
||||
description: string
|
||||
module: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export const permissionApi = {
|
||||
listAllPermissions: () => {
|
||||
return adminApi.get<PermissionVO[]>('/permission/list/all')
|
||||
},
|
||||
getUserPermissions: () => {
|
||||
return adminApi.get<PermissionVO[]>('/permission/list/user/current')
|
||||
}
|
||||
}
|
||||
|
||||
export default adminApi
|
||||
|
||||
Reference in New Issue
Block a user