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
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-25 10:37:16 +08:00
|
|
|
export interface ListUsersParams {
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
keyword?: string
|
2026-02-25 16:50:32 +08:00
|
|
|
shopId?: 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
|
2026-02-25 16:58:58 +08:00
|
|
|
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
|
2026-02-25 16:58:58 +08:00
|
|
|
shopId?: number
|
2026-02-25 10:37:16 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-03 14:39:02 +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)
|
2026-02-27 15:57:14 +08:00
|
|
|
},
|
2026-03-03 14:39:02 +08:00
|
|
|
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)
|
|
|
|
|
},
|
2026-02-27 15:57:14 +08:00
|
|
|
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}`)
|
2026-03-03 14:39:02 +08:00
|
|
|
},
|
|
|
|
|
sendVerificationCode: (data: { phone: string }) => {
|
|
|
|
|
return api.post('/user/send-verification-code', data)
|
2026-02-25 09:13:45 +08:00
|
|
|
}
|
|
|
|
|
}
|