export interface BasicPageParams {
  pageIndex: number;
  pageSize: number;
}

export interface BasicFetchResult<T> {
  items: T[];
  total: number;
}

export interface StatusParams {
  id: number;
  status: number;
}

export interface TransferOptionResult {
  key: string;
  title: string;
}

export interface BasicOptionResult {
  label: string;
  value: boolean | number | string;
  disabled?: boolean;
}

export interface BasicTreeOptionResult extends BasicOptionResult {
  children: BasicTreeOptionResult[];
  parentId: number | string;
}

export interface RelationRequest {
  id: number;
  relationIds: number[] | string[];
}

export interface Condition {
  fieldName: string;
  fieldValue: any;
  conditionalType?: string;
}

export interface QueryParams {
  code: string;
  conditions?: Condition[];
}

export const statusOptions: BasicOptionResult[] = [
  { label: '启用', value: 1 },
  { label: '停用', value: 2 },
];

export const formatterStatus = ({
  cellValue,
}: {
  cellValue: number | string;
}) => {
  const item = statusOptions.find((item) => item.value === cellValue);
  if (item) return item.label;
  return '';
};

export const boolOptions: BasicOptionResult[] = [
  { label: '是', value: true },
  { label: '否', value: false },
];

export const dbTypeOptions: BasicOptionResult[] = [
  { label: 'MySql', value: 0 },
  { label: 'SqlServer', value: 1 },
  { label: 'Sqlite', value: 2 },
  { label: 'Oracle', value: 3 },
  { label: 'PostgreSQL', value: 4 },
  { label: 'Dm', value: 5 },
  { label: 'Kdbndp', value: 6 },
  { label: 'Oscar', value: 7 },
  { label: 'MySqlConnector', value: 8 },
  { label: 'Access', value: 9 },
  { label: 'OpenGauss', value: 10 },
  { label: 'QuestDB', value: 11 },
  { label: 'HG', value: 12 },
  { label: 'ClickHouse', value: 13 },
  { label: 'GBase', value: 14 },
  { label: 'Custom', value: 15 },
];

export const connectTypeOptions: BasicOptionResult[] = [
  { label: '内联接', value: 0 },
  { label: '左联接', value: 1 },
  { label: '右联接', value: 2 },
  { label: '全联接', value: 3 },
];

export const conditionalTypeOptions: BasicOptionResult[] = [
  { label: '等于', value: 0 },
  { label: '包含', value: 1 },
  { label: '大于', value: 2 },
  { label: '大于等于', value: 3 },
  { label: '小于', value: 4 },
  { label: '小于等于', value: 5 },
  { label: '介于', value: 6 },
  { label: '不介于', value: 7 },
  { label: '开始于', value: 8 },
  { label: '结束于', value: 9 },
  { label: '不等于', value: 10 },
  { label: '不为空', value: 11 },

  // { label: '不包含', value: 7 },
  // { label: '为空', value: 8 },
  // { label: '正则匹配', value: 14 },
  // { label: '不正则匹配', value: 15 },
];

export const dataTypeOptions: BasicOptionResult[] = [
  { label: 'text', value: 'text' },
  { label: 'varchar', value: 'varchar' },
  { label: 'nvarchar', value: 'nvarchar' },
  { label: 'char', value: 'char' },
  { label: 'nchar', value: 'nchar' },
  { label: 'timestamp', value: 'timestamp' },
  { label: 'int', value: 'int' },
  { label: 'smallint', value: 'smallint' },
  { label: 'tinyint', value: 'tinyint' },
  { label: 'bigint', value: 'bigint' },
  { label: 'bit', value: 'bit' },
  { label: 'decimal', value: 'decimal' },
  { label: 'datetime', value: 'datetime' },
  { label: 'date', value: 'date' },
  { label: 'blob', value: 'blob' },
  { label: 'clob', value: 'clob' },
  { label: 'boolean', value: 'boolean' },
];
