package com.tasteby.mapper;

import com.tasteby.domain.VideoDetail;
import com.tasteby.domain.VideoRestaurantLink;
import com.tasteby.domain.VideoSummary;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface VideoMapper {

    List<VideoSummary> findAll(@Param("status") String status);

    VideoDetail findDetail(@Param("id") String id);

    List<VideoRestaurantLink> findVideoRestaurants(@Param("videoId") String videoId);

    void updateStatus(@Param("id") String id, @Param("status") String status);

    void updateTitle(@Param("id") String id, @Param("title") String title);

    void updateTranscript(@Param("id") String id, @Param("transcript") String transcript);

    void deleteVectorsByVideoOnly(@Param("videoId") String videoId);

    void deleteReviewsByVideoOnly(@Param("videoId") String videoId);

    void deleteFavoritesByVideoOnly(@Param("videoId") String videoId);

    void deleteRestaurantsByVideoOnly(@Param("videoId") String videoId);

    void deleteVideoRestaurants(@Param("videoId") String videoId);

    void deleteVideo(@Param("videoId") String videoId);

    void deleteOneVideoRestaurant(@Param("videoId") String videoId, @Param("restaurantId") String restaurantId);

    void cleanupOrphanVectors(@Param("restaurantId") String restaurantId);

    void cleanupOrphanReviews(@Param("restaurantId") String restaurantId);

    void cleanupOrphanFavorites(@Param("restaurantId") String restaurantId);

    void cleanupOrphanRestaurant(@Param("restaurantId") String restaurantId);

    void insertVideo(@Param("id") String id,
                     @Param("channelId") String channelId,
                     @Param("videoId") String videoId,
                     @Param("title") String title,
                     @Param("url") String url,
                     @Param("publishedAt") String publishedAt);

    List<String> getExistingVideoIds(@Param("channelId") String channelId);

    String getLatestVideoDate(@Param("channelId") String channelId);

    List<Map<String, Object>> findPendingVideos(@Param("limit") int limit);

    void updateVideoFields(@Param("id") String id,
                           @Param("status") String status,
                           @Param("transcript") String transcript,
                           @Param("llmResponse") String llmResponse);

    List<Map<String, Object>> findVideosForBulkExtract();

    List<Map<String, Object>> findVideosWithoutTranscript();

    List<Map<String, Object>> findVideosByIds(@Param("ids") List<String> ids);

    List<Map<String, Object>> findVideosForExtractByIds(@Param("ids") List<String> ids);

    void updateVideoRestaurantFields(@Param("videoId") String videoId,
                                      @Param("restaurantId") String restaurantId,
                                      @Param("foodsJson") String foodsJson,
                                      @Param("evaluation") String evaluation,
                                      @Param("guestsJson") String guestsJson);
}
