當前位置: 首頁>>代碼示例>>Golang>>正文


Golang web.Fail函數代碼示例

本文整理匯總了Golang中github.com/zhgo/web.Fail函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fail函數的具體用法?Golang Fail怎麽用?Golang Fail使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Fail函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Render

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)
}
開發者ID:liudng,項目名稱:recom,代碼行數:11,代碼來源:mrk_promotion.go

示例2: Render

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)
}
開發者ID:liudng,項目名稱:recom,代碼行數:11,代碼來源:whl_order_sku.go

示例3: Render

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)
}
開發者ID:liudng,項目名稱:recom,代碼行數:11,代碼來源:pim_product.go

示例4: Render

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)
}
開發者ID:liudng,項目名稱:recom,代碼行數:11,代碼來源:inv_log.go

示例5: Render

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)
}
開發者ID:liudng,項目名稱:recom,代碼行數:11,代碼來源:srm_supplier.go

示例6: Render

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)
}
開發者ID:liudng,項目名稱:gt,代碼行數:83,代碼來源:entity_search.go


注:本文中的github.com/zhgo/web.Fail函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。