Files
JayuCloud/Frontend/src/api/user.ts
T

117 lines
2.6 KiB
TypeScript

import api from './index'
import type { UserInfo } from './auth'
export interface UserVO extends UserInfo {
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 UpdateUserInfoRequest {
nickname?: string
avatar?: string
signature?: string
}
export interface ListUsersParams {
page: number
size: number
keyword?: string
shopId?: number
status?: number
}
export interface CreateUserRequest {
account: string
nickname: string
phone: string
password: string
type: number
shopId?: number
}
export interface UpdateUserRequest {
account?: string
nickname?: string
phone?: string
type?: number
shopId?: number
}
export interface UpdatePasswordRequest {
password: string
verificationCode: string
}
export interface BindPhoneRequest {
phone: string
verificationCode: string
}
export interface AvailabilityCheckResponse {
available: boolean
message: string
}
export interface LoginAccountCheckResponse {
exists: boolean
nickname?: string
message: string
}
export interface UpdatePhoneRequest {
oldPhone: string
newPhone: string
verificationCode: string
}
export const userApi = {
getUserInfo: () => {
return api.get<UserVO>('/user/info')
},
updateUserInfo: (data: UpdateUserInfoRequest) => {
return api.put('/user/update', data)
},
updatePassword: (data: UpdatePasswordRequest) => {
return api.put('/user/password', data)
},
bindPhone: (data: BindPhoneRequest) => {
return api.post('/user/bind-phone', data)
},
updatePhone: (data: UpdatePhoneRequest) => {
return api.put('/user/phone', data)
},
getUserByAccount: (account: string) => {
return api.get<UserVO>(`/user/get/account/${account}`)
},
checkAccountAvailability: (account: string) => {
return api.get<AvailabilityCheckResponse>(`/user/check/account/${encodeURIComponent(account)}`)
},
checkLoginAccountAvailability: (account: string) => {
return api.get<LoginAccountCheckResponse>(`/user/check/login-account/${encodeURIComponent(account)}`)
},
checkPhoneAvailability: (phone: string) => {
return api.get<AvailabilityCheckResponse>(`/user/check/phone/${encodeURIComponent(phone)}`)
},
listUsersByType: (type: number) => {
return api.get<UserVO[]>(`/user/list/type/${type}`)
},
sendVerificationCode: (data: { phone: string }) => {
return api.post('/user/send-verification-code', data)
},
deactivateAccount: () => {
return api.delete('/user/deactivate')
}
}