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

97 lines
2.0 KiB
TypeScript
Raw Normal View History

2026-02-25 09:13:45 +08:00
import api from './index'
import type { UserInfo } from './auth'
2026-02-25 11:38:31 +08:00
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
}
2026-02-25 09:13:45 +08:00
export interface UpdateUserInfoRequest {
nickname?: string
avatar?: string
signature?: string
phone?: string
2026-02-25 09:13:45 +08:00
}
2026-02-25 10:37:16 +08:00
export interface ListUsersParams {
page: number
size: number
keyword?: string
shopId?: number
2026-03-10 23:23:15 +08:00
status?: number
2026-02-25 10:37:16 +08:00
}
export interface CreateUserRequest {
2026-02-25 11:38:31 +08:00
account: string
2026-02-25 10:37:16 +08:00
nickname: string
phone: string
password: string
2026-02-25 11:38:31 +08:00
type: number
shopId?: number
2026-02-25 10:37:16 +08:00
}
export interface UpdateUserRequest {
2026-02-25 11:38:31 +08:00
account?: string
2026-02-25 10:37:16 +08:00
nickname?: string
phone?: string
2026-02-25 11:38:31 +08:00
type?: number
shopId?: number
2026-02-25 10:37:16 +08:00
}
export interface UpdatePasswordRequest {
password: string
}
export interface BindPhoneRequest {
phone: string
verificationCode: string
}
export interface UpdatePhoneRequest {
oldPhone: string
newPhone: string
verificationCode: string
}
2026-02-25 09:13:45 +08:00
export const userApi = {
getUserInfo: () => {
return api.get<UserVO>('/user/info')
},
updateUserInfo: (data: UpdateUserInfoRequest) => {
return api.put('/user/info', 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}`)
2026-02-28 17:09:45 +08:00
},
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')
2026-02-25 09:13:45 +08:00
}
}