import request from '@/utils/request';

export interface PageList {
  current?: number;
  size?: number;
}
export interface MsgChannel {
  channelCode: string;
  channelName: string;
  organizationId: string;
  sendImpl: string;
  userMappping: string;
  contentConstructor: string;
  isUse?: string;
  configParam?: {
    configCode: string;
    configItem: string;
    configValue: string;
  };
}

export interface IsUseStates {
  ids: Array<string>;
  isUse: string;
}
export interface IsUseState {
  ids: string;
  isUse: string;
}
export interface Channel {
  id: string;
}

export interface EditMsgChannel {
  id: string;
  field_28: string;
  // channelCode: string;
  channelName: string;
  organization: string;
  sendImpl: string;
  userMappping: string;
  contentConstructor: string;
  isUse?: string;
  configParam?: {
    id: string;
    field_29: string;
    //configCode: string;
    configItem: string;
    configValue: string;
  };
}

export async function getList(params: PageList) {
  return (
    request.request < PageList,
    any >
      {
        url: '/msg/channel/queryChannelList',
        method: 'GET',
        params,
      }
  );
}
export async function addMsgChannel(data: MsgChannel) {
  return (
    request.request < MsgChannel,
    any >
      {
        url: '/msg/channel/add',
        method: 'POST',
        data,
      }
  );
}
export async function batchChangeIsUse(params: IsUseStates) {
  return (
    request.request < IsUseStates,
    any >
      {
        url: '/msg/channel/updateStates',
        method: 'GET',
        params,
      }
  );
}
export async function changeIsUse(params: IsUseState) {
  return (
    request.request < IsUseState,
    any >
      {
        url: '/msg/channel/updateState',
        method: 'GET',
        params,
      }
  );
}
export async function queryByChannelCode(params: Channel) {
  return (
    request.request < Channel,
    any >
      {
        url: '/msg/channel/queryByChannelCode',
        method: 'GET',
        params,
      }
  );
}

export async function updateChannel(data: EditMsgChannel) {
  return (
    request.request < EditMsgChannel,
    any >
      {
        url: '/msg/channel/update',
        method: 'POST',
        data,
      }
  );
}
export async function deleteChannel(data: Channel) {
  return (
    request.request < Channel,
    any >
      {
        url: '/msg/channel/delete',
        method: 'GET',
        data,
      }
  );
}
