52 lines
968 B
TypeScript
52 lines
968 B
TypeScript
import type { IResponse } from '.'
|
|
import type { IUser, LoginType } from '~/types'
|
|
import { http } from '~/utils/http'
|
|
|
|
export interface LoginParams {
|
|
account: string
|
|
password: string
|
|
loginType: LoginType
|
|
}
|
|
|
|
export type LoginResponse = IResponse & {
|
|
loginType: LoginType
|
|
token: string
|
|
}
|
|
|
|
export type UserProfileResponse = IResponse & {
|
|
user: IUser
|
|
}
|
|
|
|
/**
|
|
* 用户登录
|
|
* @param params 登录参数
|
|
*
|
|
* @see {@link LoginParams}
|
|
*/
|
|
export const userLogin = async (params: LoginParams) => {
|
|
return await http<LoginResponse>('/login', {
|
|
method: 'POST',
|
|
body: params,
|
|
})
|
|
}
|
|
|
|
export const userProfile = async () => {
|
|
return await http<UserProfileResponse>('/getInfo', {
|
|
method: 'GET',
|
|
})
|
|
}
|
|
|
|
export const userSearch = async (pararms: {
|
|
searchType: 'student' | 'teacher'
|
|
keyword: string
|
|
}) => {
|
|
return await http<
|
|
IResponse & {
|
|
data: IUser[]
|
|
}
|
|
>(`/system/user/search`, {
|
|
method: 'GET',
|
|
query: pararms,
|
|
})
|
|
}
|