import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OpenPlatformSettingVO, OpenPlatformSettingForm, OpenPlatformSettingQuery } from '@/api/setting/openPlatformSetting/types';

/**
 * 查询开放平台设置列表
 * @param query
 * @returns {*}
 */

export const listOpenPlatformSetting = (query?: OpenPlatformSettingQuery): AxiosPromise<OpenPlatformSettingVO[]> => {
  return request({
    url: '/system/openPlatformSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询开放平台设置详细
 * @param id
 */
export const getOpenPlatformSetting = (id: string | number): AxiosPromise<OpenPlatformSettingVO> => {
  return request({
    url: '/system/openPlatformSetting/' + id,
    method: 'get'
  });
};

/**
 * 新增开放平台设置
 * @param data
 */
export const addOpenPlatformSetting = (data: OpenPlatformSettingForm) => {
  return request({
    url: '/system/openPlatformSetting',
    method: 'post',
    data: data
  });
};

export const getOpenPlatformSettingData = (): AxiosPromise<OpenPlatformSettingVO> => {
  return request({
    url: '/system/openPlatformSetting/getOpenPlatformSettingData',
    method: 'get'
  });
};

/**
 * 修改开放平台设置
 * @param data
 */
export const updateOpenPlatformSetting = (data: OpenPlatformSettingForm) => {
  return request({
    url: '/system/openPlatformSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除开放平台设置
 * @param id
 */
export const delOpenPlatformSetting = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/openPlatformSetting/' + id,
    method: 'delete'
  });
};
