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

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

export interface BaseListResponseModel<T = any> {
  code: number;
  msg: string;
  rows: T[];
  total: number;
}

/**
 * 获取业务系统列表
 * @param query
 */
export const getBusinessSystemList = (query?: object) => {
  return http.request<BasicResponseModel>(
    "get",
    baseUrlApi("system/businessSystem/list"),
    { params: query }
  );
};

/**
 * 添加业务系统
 * @param query
 */
export const addBusinessSystem = (query?: object) => {
  return http.request<BasicResponseModel>(
    "post",
    baseUrlApi("system/businessSystem"),
    {
      data: query
    }
  );
};

/**
 * 修改业务系统
 * @param query
 */
export const updateBusinessSystem = (query?: object) => {
  return http.request<BasicResponseModel>(
    "put",
    baseUrlApi("system/businessSystem"),
    {
      data: query
    }
  );
};

/**
 * 删除业务系统
 * @param id
 */
export const deleteBusinessSystem = (id: number) => {
  return http.request<BasicResponseModel>(
    "delete",
    baseUrlApi(`system/businessSystem/${id}`)
  );
};

/**
 * 根据ID获取业务系统详细信息
 * @param id
 */
export const getBusinessSystem = (id: number) => {
  return http.request<BasicResponseModel>(
    "get",
    baseUrlApi(`system/businessSystem/info/${id}`)
  );
};
