/*
 * @Author: Mm
 * @Date: 2025-05-06 16:10:05
 * @LastEditors: Mm
 * @LastEditTime: 2025-05-07 10:07:47
 * 不写bug的程序员不是一个好程序员!
 */
import type { UserVO, UserForm, UserQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
* 查询用户列表
* @param params
* @returns 用户列表
*/
export function userList(params?: UserQuery) {
  return requestClient.get<PageResult<UserVO>>('/im/user/list', { params });
}

/**
 * 导出用户列表
 * @param params
 * @returns 用户列表
 */
export function userExport(params?: UserQuery) {
  return commonExport('/im/user/export', params ?? {});
}

/**
 * 查询用户详情
 * @param id id
 * @returns 用户详情
 */
export function userInfo(id: ID) {
  return requestClient.get<UserVO>(`/im/user/${id}`);
}

/**
 * 新增用户
 * @param data
 * @returns void
 */
export function userAdd(data: UserForm) {
  return requestClient.postWithMsg<void>('/im/user', data);
}

/**
 * 更新用户
 * @param data
 * @returns void
 */
export function userUpdate(data: UserForm) {
  return requestClient.putWithMsg<void>('/im/user', data);
}

/**
 * 删除用户
 * @param id id
 * @returns void
 */
export function userRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/im/user/${id}`);
}



/**
 * 封禁用户
 * @param data
 * @returns void
 */
export function userBan(data: UserForm) {
  return requestClient.putWithMsg<void>('/im/user/ban', data);
}


// 
/**
 * 解封用户
 * @param data
 * @returns void
 */
export function userUnBan(data: UserForm) {
  return requestClient.putWithMsg<void>('/im/user/unban', data);
}
