import { defHttp } from '/@/utils/http/axios';
import { FileUploadResponse, Platform } from './model/index';
enum API {
  SELECT_DETAIL = '/enterprise/get',
  UPDATE_DETAIL = '/enterprise/update',
  BaseUploadUrl = '/oss/upload',
  SELECT_PLATFORM = '/platform/get',
  UPDATE_PLATFORM = '/platform/update',
  SELECT_APP_DESIGN = '/app_design/get',
  UPDATE_APP_DESIGN = '/app_design/update',
  SELECT_AREALIST = '/area/list',
  PLATE_RESET_DATA = '/platform/data_reset',
  APP_RESET_DATA = '/app_design/data_reset',
}

//平台信息恢复出厂设备
export const resetPlateInfo = () => {
  return defHttp.post({
    url: API.PLATE_RESET_DATA,
  });
};
//app信息恢复出厂设备
export const resetAppInfo = () => {
  return defHttp.post({
    url: API.APP_RESET_DATA,
  });
};

// 查询企业信息
export const getEnterPriseDetail = () => {
  return defHttp.get({
    url: API.SELECT_DETAIL,
  });
};

// 更新企业信息
export const updateEnterPriseDetail = (data) => {
  return defHttp.put({
    url: API.UPDATE_DETAIL,
    data,
  });
};

// 获取地区

export const getAreaList = (data) => {
  return defHttp.post({
    url: API.SELECT_AREALIST,
    data,
  });
};

// logo上传
export const logoUpload = (file) => {
  return defHttp.post<FileUploadResponse>({ url: API.BaseUploadUrl, params: file });
};

// icon上传
export const iconUpload = (file) => {
  return defHttp.post<FileUploadResponse>({ url: API.BaseUploadUrl, params: file });
};

// 背景图片上传
export const bgUpload = (file) => {
  return defHttp.post<FileUploadResponse>({ url: API.BaseUploadUrl, params: file });
};

// 获取平台定制详情
export const getPlatForm = () => {
  return defHttp.get<Platform>({
    url: API.SELECT_PLATFORM,
  });
};

// 更新平台定制
export const updatePlatForm = (data) => {
  return defHttp.put({
    url: API.UPDATE_PLATFORM,
    data,
  });
};

// APP定制
export const getAppDesign = () => {
  return defHttp.get({
    url: API.SELECT_APP_DESIGN,
  });
};

// 更新APP定制
export const updateAppDesign = (data) => {
  return defHttp.put({
    url: API.UPDATE_APP_DESIGN,
    data,
  });
};

// 二维码上传
export const qrcodeUpload = (file) => {
  return defHttp.post<FileUploadResponse>({ url: API.BaseUploadUrl, params: file });
};
