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

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

/**
 * 获取账户列表
 * @param query
 */
export const getIpAccountList = (query?: object) => {
  return http.get<BasicResponseModel, any>(interfaceUrlApi("ipAccount/list"), {
    params: query
  });
};

/**
 * 新增账户
 * @param data
 */
export const addOrEditIpAccount = (data?: object) => {
  return http.post<BasicResponseModel, any>(
    interfaceUrlApi(`ipAccount/saveOrUpdate`),
    {
      data
    }
  );
};

/**
 * 删除账户
 * @param id
 */
export const deleteIpAccount = (id: number) => {
  return http.request<BasicResponseModel>(
    "delete",
    interfaceUrlApi(`ipAccount/delete/${id}`)
  );
};

/**
 * 切换账户状态
 * @param data
 */
export const switchIpAccountStatus = (data?: object) => {
  return http.post<BasicResponseModel, any>(
    interfaceUrlApi(`ipAccount/switchStatus`),
    {
      data
    }
  );
};
