import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AiFormSettingVO, AiFormSettingForm, AiFormSettingQuery,DbTableQuery,AiFormSettingDetailVO } from '@/api/ai/base/aiFormSetting/types';

/**
 * 查询AI表单设置列表
 * @param query
 * @returns {*}
 */

export const listAiFormSetting = (query?: AiFormSettingQuery): AxiosPromise<AiFormSettingVO[]> => {
  return request({
    url: '/ai/aiFormSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询AI表单设置详细
 * @param formSettingId
 */
export const getAiFormSetting = (formSettingId: string | number): AxiosPromise<AiFormSettingVO> => {
  return request({
    url: '/ai/aiFormSetting/' + formSettingId,
    method: 'get'
  });
};

/**
 * 新增AI表单设置
 * @param data
 */
export const addAiFormSetting = (data: AiFormSettingForm) => {
  return request({
    url: '/ai/aiFormSetting',
    method: 'post',
    data: data
  });
};

/**
 * 修改AI表单设置
 * @param data
 */
export const updateAiFormSetting = (data: AiFormSettingForm) => {
  return request({
    url: '/ai/aiFormSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除AI表单设置
 * @param formSettingId
 */
export const delAiFormSetting = (formSettingId: string | number | Array<string | number>) => {
  return request({
    url: '/ai/aiFormSetting/' + formSettingId,
    method: 'delete'
  });
};


/**
 * 下拉框查询AI表单设置列表
 * @param query
 * @returns {*}
 */
export function getAiFormSettingList (query) {
    return request({
        url: '/ai/aiFormSetting/getAiFormSettingList',
        method: 'get',
        params: query
    });
};




// 获取数据源名称
export const getDataNames = () => {
  return request({
    url: '/ai/aiFormSetting/getDataNames',
    method: 'get'
  });
};


// 查询db数据库列表
export const listDbTable = (query: DbTableQuery): AxiosPromise<AiFormSettingVO[]> => {
  return request({
    url: '/ai/aiFormSetting/db/list',
    method: 'get',
    params: query
  });
};

// 查询db数据库Column列表
export const listDbTableColumn = (query: DbTableQuery): AxiosPromise<AiFormSettingDetailVO[]> => {
  return request({
    url: '/ai/aiFormSetting/db/columnList',
    method: 'get',
    params: query
  });
};


/**
 * 查询AI表单设置属性详情列表
 * @param query
 * @returns {*}
 */
export function getAiFormSettingDetailList (query) {
  return request({
    url: '/ai/aiFormSetting/getAiFormSettingDetailList',
    method: 'get',
    params: query
  });
};
