import { PaginationRequest, PaginationResponse } from "@/types/common/type";

/* 公共日志基础字段 */
interface BaseLogItem {
  id: number;
  createdAt: string;
}

/* 登录日志列表row */
export interface LoginLogItem extends BaseLogItem {
  userName: string;
  realName: string;
  deptName: string;
  device: string;
  type: number;
  loginStatus: number;
  loginIp: string;
}

/* 操作日志列表row */
export interface OperationLogItem extends BaseLogItem {
  operatorName: string;
  realName: string;
  clientIp: string;
  platform: string;
  module: string;
  content: string;
  operatorType: string;
  isSuccess: number;
}

/* 系统日志列表row */
export interface SystemLogItem extends BaseLogItem {
  eventType: number;
  eventContent: string;
}

/* 通用日志查询参数 */
interface BaseLogRequest extends PaginationRequest {
  queryParam: {
    startTime?: string;
    endTime?: string;
    date?: string;
    queryType?: string;
    queryTypeContent?: string;
  };
}

/* 登录日志列表请求参数 */
export interface LoginLogPageRequest extends BaseLogRequest {
  queryParam: BaseLogRequest["queryParam"] & {
    userName?: string;
    realName?: string;
    device?: string;
    deptId?: number;
  };
}

/* 操作日志列表请求参数 */
export interface OperationLogPageRequest extends BaseLogRequest {
  queryParam: BaseLogRequest["queryParam"] & {
    operatorName?: string;
    realName?: string;
    platform?: string;
    module?: string;
    operatorType?: string;
  };
}

/* 系统日志列表请求参数 */
export interface SystemLogRequest extends BaseLogRequest {
  queryParam: BaseLogRequest["queryParam"] & {
    eventType?: number;
  };
}

/* 登录日志、操作日志、系统日志接口返回 */
export type LoginLogResponse = PaginationResponse<LoginLogItem>;
export type OperationLogResponse = PaginationResponse<OperationLogItem>;
export type SystemLogResponse = PaginationResponse<SystemLogItem>;

/* 操作日志详情 */
export type OperationPageDetail = Pick<
  OperationLogItem,
  "module" | "operatorType" | "operatorName" | "clientIp" | "isSuccess" | "createdAt"
> & { parameter: string, operation: string };

/* 通用导出参数 */
interface BaseExportRequest {
  startTime?: string;
  endTime?: string;
}

/* 登录日志导出参数 */
export type LoginExport = BaseExportRequest & Partial<Pick<LoginLogItem, "userName" | "realName" | "device" | "deptId">>;

/* 操作日志导出参数 */
export type OperationExport = BaseExportRequest & Partial<Pick<OperationLogItem, "operatorName" | "realName" | "platform" | "module" | "operatorType">>;

/* 系统日志导出参数 */
export type SystemExport = BaseExportRequest & Partial<Pick<SystemLogItem, "eventType">>;