import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CodeSettingVO, CodeSettingForm, CodeSettingQuery } from '@/api/setting/codeSetting/types';

/**
 * 查询激活码列表
 * @param query
 * @returns {*}
 */

export const listCodeSetting = (query?: CodeSettingQuery): AxiosPromise<CodeSettingVO[]> => {
  return request({
    url: '/system/codeSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询激活码详细
 * @param id
 */
export const getCodeSetting = (id: string | number): AxiosPromise<CodeSettingVO> => {
  return request({
    url: '/system/codeSetting/' + id,
    method: 'get'
  });
};

/**
 * 新增激活码
 * @param data
 */
export const addCodeSetting = (data: CodeSettingForm) => {
  return request({
    url: '/system/codeSetting',
    method: 'post',
    data: data
  });
};

/**
 * 修改激活码
 * @param data
 */
export const updateCodeSetting = (data: CodeSettingForm) => {
  return request({
    url: '/system/codeSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除激活码
 * @param id
 */
export const delCodeSetting = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/codeSetting/' + id,
    method: 'delete'
  });
};
