import { type ListingStatus, type TransactionType, type PropertyType } from '@prisma/client';
import { type ListingEntity } from '../entities/listing.entity';
import { type ListingDetailData, type ListingSearchItem, type ListingSellerItem } from './listing-read.dto';

export const LISTING_REPOSITORY = Symbol('LISTING_REPOSITORY');

export interface ListingSearchParams {
  status?: ListingStatus;
  transactionType?: TransactionType;
  propertyType?: PropertyType;
  city?: string;
  district?: string;
  minPrice?: bigint;
  maxPrice?: bigint;
  minArea?: number;
  maxArea?: number;
  bedrooms?: number;
  page?: number;
  limit?: number;
}

export interface PaginatedResult<T> {
  data: T[];
  total: number;
  page: number;
  limit: number;
  totalPages: number;
}

export interface IListingRepository {
  findById(id: string): Promise<ListingEntity | null>;
  findByIdWithProperty(id: string): Promise<ListingDetailData | null>;
  save(listing: ListingEntity): Promise<void>;
  update(listing: ListingEntity): Promise<void>;
  search(params: ListingSearchParams): Promise<PaginatedResult<ListingSearchItem>>;
  findByStatus(status: ListingStatus, page: number, limit: number): Promise<PaginatedResult<ListingSearchItem>>;
  findBySellerId(sellerId: string, page: number, limit: number): Promise<PaginatedResult<ListingSellerItem>>;
}
