package com.tasteby.mapper;

import com.tasteby.domain.Restaurant;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface RestaurantMapper {

    List<Restaurant> findAll(@Param("limit") int limit,
                             @Param("offset") int offset,
                             @Param("cuisine") String cuisine,
                             @Param("region") String region,
                             @Param("channel") String channel,
                             @Param("minMentions") Integer minMentions,
                             @Param("includeHidden") boolean includeHidden);

    // #322 LLM 검증: hidden 표시 갱신
    void updateVerification(@Param("id") String id,
                            @Param("hidden") int hidden,
                            @Param("hiddenReason") String hiddenReason);

    void clearHidden(@Param("id") String id);

    List<Restaurant> findUnverified(@Param("limit") int limit);

    int countUnverified();

    // #356 영상-식당 관련도
    void updateLinkRelevance(@Param("linkId") String linkId,
                             @Param("relevance") String relevance,
                             @Param("reason") String reason);

    Map<String, Object> findLinkContext(@Param("linkId") String linkId);

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

    int countUnevaluatedLinks();

    // #359 1단계 — google_place_id 중복 조회
    List<Map<String, Object>> findDuplicatePlaceIdRows();

    Restaurant findById(@Param("id") String id);

    List<Map<String, Object>> findVideoLinks(@Param("restaurantId") String restaurantId,
                                              @Param("includeWeak") boolean includeWeak);

    void insertRestaurant(Restaurant r);

    void updateRestaurant(Restaurant r);

    void updateFields(@Param("id") String id, @Param("fields") Map<String, Object> fields);

    void deleteVectors(@Param("id") String id);

    void deleteReviews(@Param("id") String id);

    void deleteFavorites(@Param("id") String id);

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

    void deleteRestaurant(@Param("id") String id);

    void linkVideoRestaurant(@Param("id") String id,
                             @Param("videoId") String videoId,
                             @Param("restaurantId") String restaurantId,
                             @Param("foods") String foods,
                             @Param("evaluation") String evaluation,
                             @Param("guests") String guests);

    String findIdByPlaceId(@Param("placeId") String placeId);

    String findIdByName(@Param("name") String name);

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

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

    void updateCuisineType(@Param("id") String id, @Param("cuisineType") String cuisineType);

    void updateFoodsMentioned(@Param("id") String id, @Param("foods") String foods);

    List<Restaurant> findWithoutTabling();

    List<Restaurant> findWithoutCatchtable();

    void resetTablingUrls();

    void resetCatchtableUrls();

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

    List<Map<String, Object>> findForRemapFoods();
}
