Exemple #1
0
func (this *UserTrack) getBigCat() {
	conf := mongodb.MongodbQueryConf{}
	conf.Db = "data_source"
	conf.Table = "taocat"
	conf.Query = mongodb.MM{"type": "0"}
	conf.Select = mongodb.MM{"bid": 1, "cid": 1}
	this.mg.Query(conf, func(info map[string]interface{}) {
		this.bigCategoryMap[convert.ToString(info["cid"])] = convert.ToString(info["bid"])
	})
}
Exemple #2
0
func (this *TaobaoESStore) initCategory() {
	q := mongodb.MongodbQueryConf{}
	q.Db = "xu_precise"
	q.Table = "taocat"
	q.Select = mongodb.MM{"name": 1, "cid": 1, "_id": 0}
	q.Query = mongodb.MM{"type": "0"}
	this.catMap = make(map[string]string)
	this.store.Query(q, func(info map[string]interface{}) {
		this.catMap[info["cid"].(string)] = info["name"].(string)
	})
}
Exemple #3
0
func getGeop(w http.ResponseWriter, r *http.Request) {
	ad := strings.TrimSpace(r.URL.Query().Get("ad"))
	mlink, err := db.Get()
	lon := ""
	lat := ""

	if err != nil {
		log.Error(err)
		w.Write([]byte(""))
		return
	}

	defer mlink.Close()

	if ad == "" {
		w.WriteHeader(404)
		w.Write([]byte(""))
		return
	}

	qconf := mongodb.MongodbQueryConf{}
	qconf.Db = "lonlat_data"
	qconf.Table = "tbl_map"
	qconf.Select = mongodb.MM{"lon": 1, "lat": 1}
	qconf.Query = mongodb.MM{"ad": ad}
	info, err := mlink.One(qconf)
	if err != nil {
		log.Error(err)
		w.Write([]byte(""))
		return
	}

	if v, ok := info["lon"]; ok {
		lon = convert.ToString(v)
	}
	if v, ok := info["lat"]; ok {
		lat = convert.ToString(v)
	}
	w.Write([]byte(fmt.Sprintf("%s,%s", lon, lat)))
}