import { defHttp } from '/@/utils/http/axios';
import type {
  queryPageParams,
  BigScreenCenterParams,
  ConfigurationCenterInfo,
  BigScreenCenterItemsModal,
} from './model/bigscreenCenterModel';
import { getPageData } from '../../base';
import { FileUploadResponse } from '../../oem/model';
enum API {
  basicUrl = '/data_view',
  UPLOAD = '/oss/upload',
}

export const getPage = (params: queryPageParams) => {
  return getPageData<BigScreenCenterItemsModal>(params, API.basicUrl);
};

export const saveConfigurationCenter = (params: BigScreenCenterParams) => {
  return defHttp.post({
    url: API.basicUrl,
    data: params,
  });
};

export const updateConfigurationCenter = (params: BigScreenCenterParams) => {
  return defHttp.put({
    url: API.basicUrl,
    data: params,
  });
};

export const deleteBigScreenenter = (ids: string[]) => {
  return defHttp.delete({
    url: API.basicUrl,
    data: {
      ids: ids,
    },
  });
};

export const saveOrUpdateBigScreenCenter = (params: ConfigurationCenterInfo, isUpdate: boolean) => {
  return isUpdate ? updateConfigurationCenter(params) : saveConfigurationCenter(params);
};

export const uploadThumbnail = (file: FormData) => {
  return defHttp.post<FileUploadResponse>({ url: API.UPLOAD, params: file });
};
