import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PtParameterVO, PtParameterForm, PtParameterQuery } from '@/api/basics/basicParameter/ptParameter/types';

/**
 * 查询系统参数列表
 * @param query
 * @returns {*}
 */
export const listPtParameter = (query?: PtParameterQuery): AxiosPromise<PtParameterVO[]> => {
  return request({
    url: '/backstage/basicParameter/ptParameter/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询系统参数详细
 * @param paramId
 */
export const getPtParameter = (paramId: string | number): AxiosPromise<PtParameterVO> => {
  return request({
    url: '/backstage/basicParameter/ptParameter/' + paramId,
    method: 'get'
  });
};

/**
 * 新增系统参数
 * @param data
 */
export const addPtParameter = (data: PtParameterForm) => {
  return request({
    url: '/backstage/basicParameter/ptParameter',
    method: 'post',
    data: data
  });
};

/**
 * 修改系统参数
 * @param data
 */
export const updatePtParameter = (data: PtParameterForm) => {
  return request({
    url: '/backstage/basicParameter/ptParameter',
    method: 'put',
    data: data
  });
};

/**
 * 删除系统参数
 * @param paramId
 */
export const delPtParameter = (paramId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/basicParameter/ptParameter/' + paramId,
    method: 'delete'
  });
};
// 根据参数键名查询参数值
export function getPtParamByCode(paramCode: string): AxiosPromise<string> {
  return request({
    url: '/backstage/basicParameter/ptParameter/paramCode/' + paramCode,
    method: 'get'
  });
}
