package com.storycove.dto;

import java.util.List;
import java.util.Map;

public class SearchResultDto<T> {
    
    private List<T> results;
    private long totalHits;
    private int page;
    private int perPage;
    private String query;
    private long searchTimeMs;
    private Map<String, List<FacetCountDto>> facets;
    
    public SearchResultDto() {}
    
    public SearchResultDto(List<T> results, long totalHits, int page, int perPage, String query, long searchTimeMs) {
        this.results = results;
        this.totalHits = totalHits;
        this.page = page;
        this.perPage = perPage;
        this.query = query;
        this.searchTimeMs = searchTimeMs;
    }
    
    public SearchResultDto(List<T> results, long totalHits, int page, int perPage, String query, long searchTimeMs, Map<String, List<FacetCountDto>> facets) {
        this.results = results;
        this.totalHits = totalHits;
        this.page = page;
        this.perPage = perPage;
        this.query = query;
        this.searchTimeMs = searchTimeMs;
        this.facets = facets;
    }

    // Simple constructor for basic search results with facet list
    public SearchResultDto(List<T> results, long totalHits, int resultCount, List<FacetCountDto> facetsList) {
        this.results = results;
        this.totalHits = totalHits;
        this.page = 0;
        this.perPage = resultCount;
        this.query = "";
        this.searchTimeMs = 0;
        // Convert list to map if needed - for now just set empty map
        this.facets = java.util.Collections.emptyMap();
    }
    
    // Getters and Setters
    public List<T> getResults() {
        return results;
    }
    
    public void setResults(List<T> results) {
        this.results = results;
    }
    
    public long getTotalHits() {
        return totalHits;
    }
    
    public void setTotalHits(long totalHits) {
        this.totalHits = totalHits;
    }
    
    public int getPage() {
        return page;
    }
    
    public void setPage(int page) {
        this.page = page;
    }
    
    public int getPerPage() {
        return perPage;
    }
    
    public void setPerPage(int perPage) {
        this.perPage = perPage;
    }
    
    public String getQuery() {
        return query;
    }
    
    public void setQuery(String query) {
        this.query = query;
    }
    
    public long getSearchTimeMs() {
        return searchTimeMs;
    }
    
    public void setSearchTimeMs(long searchTimeMs) {
        this.searchTimeMs = searchTimeMs;
    }
    
    public Map<String, List<FacetCountDto>> getFacets() {
        return facets;
    }
    
    public void setFacets(Map<String, List<FacetCountDto>> facets) {
        this.facets = facets;
    }
}