import { http } from '@/utils/http'
import type { UserType } from '@/types/user'
import type { ListType, ListResponseType } from '@/types/list'
import { parseQueryValues } from '@/utils'

/** 获取用户列表 */
export const getUserListApi = (params: Partial<UserType>, page: Partial<ListType>) => {
  return http.get<ListResponseType<UserType>>('/api/query/list?pagevalue=17', {
    ...page,
    ...parseQueryValues(params),
  })
}

/** 获取用户详情 */
export const getUserDetailApi = (id: string) => {
  return http.get<UserType>(
    '/api/query/view?pagevalue=56',
    {
      // ...parseQueryValues({ usersid: id }),
    },
    {
      formatData: true,
    },
  )
}

/** 更新用户信息 */
export const updateUserApi = (data: Partial<UserType> & { usersid: string }) => {
  return http.get<UserType>('/api/up?pagevalue=57', {
    ...data,
    'usersid.value': data.usersid,
  })
}
