package main

import (
	"context"
	"fmt"

	"github.com/lvhao0419/fetch_flash/dao"
	"github.com/lvhao0419/fetch_flash/model"
	"github.com/lvhao0419/fetch_flash/resource"
)

func main() {
	fmt.Println(`export place`)

	// 查询所有place信息存入redis，storeLocation
	places := []model.Place{}
	resource.MysqlDB.Find(&places)
	for _, place := range places {
		dao.StorePlaceLocation(context.Background(), fmt.Sprintf("%d", place.PlaceID), place.Longitude, place.Latitude)
	}

	// test searchNearby
	// 北京 116.418757,39.917544
	placeIds := dao.SearchNearbyPlaces(context.Background(), 116.418757, 39.917544, 20)
	fmt.Println(placeIds)
}

func init() {
	resource.InitDB()
	resource.InitRedisClient()
}
