// 通用响应类型
export interface ApiResponse<T = any> {
  success: boolean;
  data?: T;
  message?: string;
  error?: string;
}

// 分页类型
export interface Pagination {
  page: number;
  pageSize: number;
  total: number;
  totalPages: number;
}

// 分页响应类型
export interface PaginatedResponse<T = any> extends ApiResponse<T[]> {
  pagination: Pagination;
}

// 查询参数类型
export interface QueryParams {
  page?: number;
  pageSize?: number;
  sortBy?: string;
  sortOrder?: 'ASC' | 'DESC';
  [key: string]: any;
}

// 启用/禁用状态枚举
export enum EnableStatus {
  DISABLED = 0, // 禁用
  ENABLED = 1   // 启用
}

// 启用/禁用状态中文映射
export const EnableStatusNameMap: Record<EnableStatus, string> = {
  [EnableStatus.DISABLED]: '禁用',
  [EnableStatus.ENABLED]: '启用'
};

// 删除状态枚举
export enum DeleteStatus {
  NOT_DELETED = 0, // 未删除
  DELETED = 1      // 已删除
}

// 删除状态中文映射
export const DeleteStatusNameMap: Record<DeleteStatus, string> = {
  [DeleteStatus.NOT_DELETED]: '未删除',
  [DeleteStatus.DELETED]: '已删除'
};

// 启用/禁用状态枚举（反向定义）
export enum DisabledStatus {
  DISABLED = 1, // 禁用
  ENABLED = 0   // 启用
}

// 启用/禁用状态中文映射
export const DisabledStatusNameMap: Record<DisabledStatus, string> = {
  [DisabledStatus.DISABLED]: '禁用',
  [DisabledStatus.ENABLED]: '启用'
};

// 认证上下文类型
export interface AuthContextType<T> {
  user: T | null;
  token: string | null;
  login: (username: string, password: string, latitude?: number, longitude?: number) => Promise<void>;
  logout: () => Promise<void>;
  isAuthenticated: boolean;
  isLoading: boolean;
}

// 全局配置常量
export interface GlobalConfig {
  OSS_BASE_URL: string;
  APP_NAME: string;
}

// JWT Payload 类型
export interface JWTPayload {
  id: number;
  username: string;
  roles?: string[];
  openid?: string;
  tenantId?: number; // 租户ID，用于多租户场景
}

// Hono 认证上下文类型
export type AuthContext = {
  Variables: {
    user: any; // 用户类型将在具体模块中定义
    token: string;
    tenantId?: number; // 租户ID，用于多租户场景
  }
};