package shop.alien.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.store.ElasticSearchLabel;

import java.util.List;

/**
 * es数据查询mapper
 *
 * @author ssk
 * @version 1.0
 * @date 2025/5/7 16:37
 */
public interface ElasticSearchMapper extends BaseMapper<ElasticSearchLabel> {

    /**
     * 获取所有门店
     *
     * @return list
     */
    @Select("SELECT a.id businessId, 1 businessType, a.business_section businessMainType, b.dict_detail businessMainTypeStr, " +
            "a.store_name businessName, a.store_address businessAddress " +
            "FROM `store_info` a " +
            "LEFT JOIN store_dictionary b on a.business_section = b.dict_id and b.type_name = 'business_section' and b.delete_flag = 0 " +
            "where a.delete_flag = 0")
    List<ElasticSearchLabel> getStoreInfoList();

    /**
     * 获取所有套餐
     *
     * @return list
     */
    @Select("SELECT a.id businessId, 2 businessType, b.business_section businessMainType, c.dict_detail businessMainTypeStr, " +
            "a.name businessName, b.store_name businessAddress " +
            "FROM `life_coupon` a " +
            "left join store_info b on a.store_id = b.id and b.delete_flag = 0 " +
            "LEFT JOIN store_dictionary c on b.business_section = c.dict_id and c.type_name = 'business_section' and c.delete_flag = 0 " +
            "where a.delete_flag = 0 and a.type = 2")
    List<ElasticSearchLabel> getStorePackageList();

    /**
     * 获取所有菜单
     *
     * @return list
     */
    @Select("SELECT a.id businessId, 3 businessType, b.business_section businessMainType, c.dict_detail businessMainTypeStr, " +
            "a.dish_name businessName, b.store_name businessAddress " +
            "FROM `store_menu` a " +
            "left join store_info b on a.store_id = b.id and b.delete_flag = 0 " +
            "LEFT JOIN store_dictionary c on b.business_section = c.dict_id and c.type_name = 'business_section' and c.delete_flag = 0 " +
            "where a.delete_flag = 0 ")
    List<ElasticSearchLabel> getStoreMenuList();

}
