import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  rows: T;
  data: T;
  total: number;
}

/**
 * 获取用户列表
 * @param query
 */
export const getSystemUserList = (query?: object) => {
  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/list"), {
    data: query
  });
};

/**
 * 根据ID获取用户详细信息
 * @param id
 */
export const getUserInfoById = (id?: string) => {
  return http.get<BasicResponseModel, any>(baseUrlApi(`system/user/${id}`));
};

/**
 * 修改用户
 * @param data
 */
export const editUser = (data?: object) => {
  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/edit"), {
    data
  });
};

/**
 * 添加用户
 * @param data
 */
export const addUser = (data?: object) => {
  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/add"), {
    data
  });
};

/**
 * 删除用户
 * @param id
 */
export const deleteUser = (id?: string) => {
  return http.post<BasicResponseModel, any>(baseUrlApi("system/user/delete"), {
    data: [id]
  });
};
