Example #1
0
func (c *MrkPromotionList) Render() web.Result {
	d := []ent.MrkPromotion{}

	q := biz.MrkPromotion.Select()
	err := q.Parse(c.Cond).Rows(&d)
	if err != nil {
		return web.Fail(err)
	}

	return web.Done(d)
}
Example #2
0
func (c *WhlOrderSkuList) Render() web.Result {
	d := []ent.WhlOrderSku{}

	q := biz.WhlOrderSku.Select()
	err := q.Parse(c.Cond).Rows(&d)
	if err != nil {
		return web.Fail(err)
	}

	return web.Done(d)
}
Example #3
0
func (c *PimProductList) Render() web.Result {
	d := []ent.PimProduct{}

	q := biz.PimProduct.Select()
	err := q.Parse(c.Cond).Rows(&d)
	if err != nil {
		return web.Fail(err)
	}

	return web.Done(d)
}
Example #4
0
func (c *InvLogList) Render() web.Result {
	d := []ent.InvLog{}

	q := biz.InvLog.Select()
	err := q.Parse(c.Cond).Rows(&d)
	if err != nil {
		return web.Fail(err)
	}

	return web.Done(d)
}
Example #5
0
func (c *SrmSupplierList) Render() web.Result {
	d := []ent.SrmSupplier{}

	q := biz.SrmSupplier.Select()
	err := q.Parse(c.Cond).Rows(&d)
	if err != nil {
		return web.Fail(err)
	}

	return web.Done(d)
}
Example #6
0
func (c *EntitySearch) Render() web.Result {
	if c.EntityType == "" {
		return web.Fail(errors.New("entity_type can not be empty"))
	}

	// Load entity map from yaml or json format.
	entity, ok := maps[c.EntityType]
	if !ok {
		return web.Fail(errors.New("entity_type configuration not found"))
	}

	// Replace query.
	conds := make([]string, len(c.Conditions))
	if len(c.Conditions) > 0 {
		for k, v := range c.Conditions {
			var ok bool
			f, ok := entity[k]
			if !ok {
				return web.Fail(errors.New("field not found"))
			}

			conds = append(conds, f.Name+":"+v)
		}
	} else {
		conds = append(conds, "*:*")
	}

	// Build a query object
	// Here we are specifying a 'q' param,
	// rows, faceting and facet.fields
	q := solr.Query{
		Params: solr.URLParamMap{
			"q": conds,
			//"facet.field": []string{"accepts_4x4s", "accepts_bicycles"},
			//"facet":       []string{"true"},
		},
		Rows: 30,
	}

	// perform the query, checking for errors
	res, err := solrObj.Select(&q)
	if err != nil {
		log.Fatal(err)
	}

	// grab results for ease of use later on
	results := res.Results

	//log.Printf("%#v\n", q)
	//log.Printf("%#v\n", res)
	//log.Printf("%#v\n", results)

	rows := make([]map[string]string, 0)

	for i := 0; i < results.Len(); i++ {
		id := fmt.Sprintf("%#v", results.Get(i).Field("id__i"))
		name := fmt.Sprintf("%#v", results.Get(i).Field("name"))
		url := fmt.Sprintf("%#v", results.Get(i).Field("url"))
		address := fmt.Sprintf("%#v", results.Get(i).Field("address"))
		description := fmt.Sprintf("%#v", results.Get(i).Field("description"))
		menus__json := fmt.Sprintf("%#v", results.Get(i).Field("menus__json"))
		features := fmt.Sprintf("%#v", results.Get(i).Field("features"))
		class_feature__ss := fmt.Sprintf("%#v", results.Get(i).Field("class_feature__ss"))
		halls__json := fmt.Sprintf("%#v", results.Get(i).Field("halls__json"))
		service__json := fmt.Sprintf("%#v", results.Get(i).Field("service__json"))

		data := make(map[string]string)
		data["id"] = id
		data["name"] = name
		data["url"] = url
		data["address"] = address
		data["description"] = description
		data["menus__json"] = menus__json
		data["features"] = features
		data["class_feature__ss"] = class_feature__ss
		data["halls__json"] = halls__json
		data["service__json"] = service__json

		rows = append(rows, data)
	}

	return web.Done(rows)
}