2024-08-21 10:37:56 +08:00
|
|
|
import request from '@/utils/request'
|
2024-08-21 21:51:06 +08:00
|
|
|
import { CLIENT_TYPE, CLIENT_NAME, CLIENT_VERSION, CLIENT_ID } from '@/const/userConst'
|
2024-08-23 11:42:19 +08:00
|
|
|
import { refreshToken } from '@/api/common'
|
2024-08-21 10:37:56 +08:00
|
|
|
|
2024-08-26 16:24:49 +08:00
|
|
|
const getReqBody = (obj) => {
|
|
|
|
|
return {
|
|
|
|
|
...obj,
|
2024-08-21 10:37:56 +08:00
|
|
|
clientType: CLIENT_TYPE,
|
|
|
|
|
clientName: CLIENT_NAME,
|
|
|
|
|
clientVersion: CLIENT_VERSION
|
2024-08-26 16:24:49 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const userRegisterService = ({ username, password }) => {
|
|
|
|
|
return request.post(
|
|
|
|
|
'/user/register',
|
|
|
|
|
getReqBody({
|
|
|
|
|
account: username,
|
|
|
|
|
nickName: '',
|
|
|
|
|
password: password
|
|
|
|
|
})
|
|
|
|
|
)
|
2024-08-21 10:37:56 +08:00
|
|
|
}
|
2024-08-21 21:51:06 +08:00
|
|
|
|
|
|
|
|
export const userLoginService = ({ username, password }) => {
|
2024-08-26 16:24:49 +08:00
|
|
|
return request.post(
|
|
|
|
|
'/user/login',
|
|
|
|
|
getReqBody({ account: username, password: password, clientId: CLIENT_ID })
|
|
|
|
|
)
|
2024-08-21 21:51:06 +08:00
|
|
|
}
|
2024-08-22 22:38:04 +08:00
|
|
|
|
2024-09-02 12:05:53 +08:00
|
|
|
export const userLogoutnService = ({ username }) => {
|
|
|
|
|
return request.post('/user/logout', getReqBody({ account: username }))
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-23 11:42:19 +08:00
|
|
|
export const userInfoService = async () => {
|
|
|
|
|
await refreshToken()
|
2024-08-26 16:24:49 +08:00
|
|
|
return request.post('/user/querySelf', getReqBody({}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const userModifySelfService = async (obj) => {
|
|
|
|
|
await refreshToken()
|
|
|
|
|
return request.post('/user/modifySelf', getReqBody(obj))
|
2024-08-22 22:38:04 +08:00
|
|
|
}
|
2024-08-28 11:37:37 +08:00
|
|
|
|
|
|
|
|
export const userModifyPassword = async (obj) => {
|
|
|
|
|
await refreshToken()
|
|
|
|
|
return request.post('/user/modifyPwd', getReqBody(obj))
|
|
|
|
|
}
|
2024-08-28 21:03:24 +08:00
|
|
|
|
2024-08-31 23:39:12 +08:00
|
|
|
export const userUploadAvatarService = async (obj) => {
|
2024-08-28 21:03:24 +08:00
|
|
|
await refreshToken()
|
2024-08-31 23:39:12 +08:00
|
|
|
return request.postForm('/user/upload', getReqBody(obj))
|
2024-08-28 21:03:24 +08:00
|
|
|
}
|