import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MessageTemplateVO, MessageTemplateForm, MessageTemplateQuery } from '@/api/system/messageTemplate/types';

/**
 * 查询消息模板列表
 * @param query
 * @returns {*}
 */

export const listMessageTemplate = (query?: MessageTemplateQuery): AxiosPromise<{ records: MessageTemplateVO[] }> => {
  return request({
    url: '/sys/message/template/listPage',
    method: 'post',
    data: query
  });
};

export const listPageBuUserSet = (query?: MessageTemplateQuery): AxiosPromise<{ records: MessageTemplateVO[] }> => {
  return request({
    url: '/sys/message/config/listPage',
    method: 'post',
    data: query
  });
};

export const editTemplate = (query?: MessageTemplateForm) => {
  return request({
    url: '/sys/message/template/saveTempleteContent',
    method: 'post',
    data: query
  });
}

export const getTemplate = (id: string | number, templateDetailType: string) => {
  return request({
    url: '/sys/message/template/getGroupDetail',
    method: 'post',
    data: { id, templateDetailType }
  });
}

export const changeEnable = (id: string, enable: string | number | boolean) => {
  return request({
    url: '/sys/message/template/enabledDetail',
    method: 'post',
    data: { id, enable }
  });
}
export const setMessageConfig = (param) => {
  return request({
    url: '/sys/message/config/setMessageConfig',
    method: 'post',
    data: param
  });
}

export const listCueWordTemplate = (query?: MessageTemplateQuery): AxiosPromise<{ records: MessageTemplateVO[] }> => {
  return request({
    url: '/ai/prompt/listPage',
    method: 'post',
    data: query
  });
};

export const addCueWordTemplate = (query?: MessageTemplateForm) => {
  return request({
    url: '/ai/prompt/save',
    method: 'post',
    data: query
  });
}


export const delCueWord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/ai/prompt/delete',
    method: 'post',
    data: { id }
  });
};

export const getPrompt = (query?: MessageTemplateForm) => {
  return request({
    url: '/ai/prompt/getMailAiPrompt',
    method: 'post',
    data: query
  });
}
