import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AppletVO, AppletForm, AppletQuery } from '@/api/setting/applet/types';

/**
 * 查询小程序设置列表
 * @param query
 * @returns {*}
 */

export const listApplet = (query?: AppletQuery): AxiosPromise<AppletVO[]> => {
  return request({
    url: '/setting/applet/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小程序设置详细
 * @param id
 */
export const getApplet = (id: string | number): AxiosPromise<AppletVO> => {
  return request({
    url: '/setting/applet/' + id,
    method: 'get'
  });
};

/**
 * 新增小程序设置
 * @param data
 */
export const addApplet = (data: AppletForm) => {
  return request({
    url: '/setting/applet',
    method: 'post',
    data: data
  });
};

/**
 * 修改小程序设置
 * @param data
 */
export const updateApplet = (data: AppletForm) => {
  return request({
    url: '/setting/applet',
    method: 'put',
    data: data
  });
};

/**
 * 删除小程序设置
 * @param id
 */
export const delApplet = (id: string | number | Array<string | number>) => {
  return request({
    url: '/setting/applet/' + id,
    method: 'delete'
  });
};
