package shop.alien.mapper;

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

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

@Mapper
public interface LifeBrowseRecordMapper extends BaseMapper<LifeBrowseRecord> {

    @Select("SELECT a.liulan_date liulanDate, b.store_type storeType, b.store_position storePosition, a.liulan_time liulanTime, " +
            "c.img_url image, b.store_name storeName, b.store_address storeDetailAddress, b.id storeId, a.created_time, d.img_url entranceImage, dict.dict_detail storeTypeStr " +
            "FROM life_browse_record a " +
            "LEFT JOIN store_info b ON a.store_id = b.id " +
            "LEFT JOIN store_img c on b.id = c.store_id and c.img_type = 11 and c.delete_flag = 0 " +
            "LEFT JOIN store_img d on b.id = d.store_id and d.img_type = 1 and d.delete_flag = 0 " +
            "left join store_dictionary dict on dict.type_name = 'storeType' and dict.dict_id = b.store_type and dict.delete_flag = 0 " +
            "WHERE a.user_id = #{userId} AND a.delete_flag = 0 AND b.delete_flag = 0 ORDER BY a.liulan_time desc")
    List<Map<String, Object>> getBrowseRecordByUserId(String userId);

}