import { post, get } from '@/api/request';

const env = import.meta.env;
const PREFIX = env.VITE_API_PREFIX_SYSTEM;

// 获取所有应用
export const queryAllApplicationApi = (params: any) => {
  return get(`${PREFIX}appCenter/queryAllApplication`, params);
};

// 根据应用类型获应用
export const queryApplicationByTypeApi = (params: any) => {
  return get(`${PREFIX}appCenter/queryApplicationByType`, params);
};

// 添加应用
export const addApplicationApi = (params: any) => {
  return post(`${PREFIX}appCenter/addApplication`, params);
};

// 更新应用
export const updateApplicationApi = (params: any) => {
  return post(`${PREFIX}appCenter/updateApplication`, params);
};

// 删除应用
export const deleteApplicationApi = (params: any) => {
  return get(`${PREFIX}appCenter/deleteApplication`, params);
};

// 添加应用配置
export const addApplicationConfigApi = (params: any) => {
  return post(`${PREFIX}appCenter/addApplicationConfig`, params);
};

// 修改应用配置
export const updateApplicationConfigAPi = (params: any) => {
  return post(`${PREFIX}appCenter/updateApplicationConfig`, params);
};

// 获取应用配置
export const queryApplicationConfigApi = (params: any) => {
  return get(`${PREFIX}appCenter/queryApplicationConfig`, params);
};

// 删除某个应用配置
export const deleteApplicationConfigAPi = (params: any) => {
  return get(`${PREFIX}appCenter/deleteApplicationConfig`, params);
};

// 删除应用所有配置
export const deleteApplicationAllConfigApi = (params: any) => {
  return get(`${PREFIX}appCenter/deleteApplicationAllConfig`, params);
};

/**
 * 添加应用调用记录
 * @param params appName  appType  creator
 * @returns
 */
export const addApplicationCallRecordApi = (params: any) => {
  return post(`${PREFIX}appCenter/addApplicationCallRecord`, params);
};

/**
 * 查询系统所有应用调用记录
 * @returns
 */
export const queryAllApplicationCallRecordApi = () => {
  return get(`${PREFIX}appCenter/queryAllApplicationCallRecord`);
};

/**
 * 查询系统具体应用调用记录
 * @param params appName  appType
 * @returns
 */
export const queryApplicationCallRecordApi = (params: any) => {
  return get(`${PREFIX}appCenter/queryApplicationCallRecord`, params);
};
