import { IUser } from '@cc98/api' ; import { GET , PUT , DELETE , POST } from '@/utils/fetch' ; import { memoize } from 'lodash-es' ; description param { number } id export const getUserInfoById = memoize ( ( id ) => GET < IUser > ( `user/${ id }` ) ) ; description param { string } name export function getUserInfoByName ( name ) { return GET < IUser > ( `user/name/${ name }` ) ; } description export function getUsersInfoByIds ( ids ) { const query = ids . map ( id => `id=${ id }` ) . join ( '&' ) ; return GET < IUser [ ] > ( `user?${ query }` ) ; } param id export function followUser ( id ) { return PUT ( `me/followee/${ id }` ) ; } param id export function unFollowUser ( id ) { return DELETE ( `me/followee/${ id }` ) ; } /**
 * 修改个人资料
 */ export function modifyMyInfo ( newInfo ) { return PUT ( 'me' , { params : newInfo , } ) ; } /**
 * 上传个人头像
 */ export function updateMyAvatar ( file ) { const formData = new FormData ( ) ; formData . append ( 'files' , file , file . name ) ; formData . append ( 'contentType' , 'multipart/form-data' ) ; return POST < string [ ] > ( 'file' , { headers : { } , requestInit : { body : formData , } , } ) ; } /**
 * 修改个人头像
 */ export function modifyMyAvatar ( newAvatar ) { return PUT ( 'me/portrait' , { params : newAvatar , } ) ; }