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


Golang commonlib.RenderTemplate函數代碼示例

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


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

示例1: dealEntityLoad

//處理實體的分頁ajax請求
func dealEntityLoad(entity Entity, w http.ResponseWriter, r *http.Request) {

	Log.Debug("路徑:", r.URL.Path, "訪問實體", entity.Id, "的load單實體ajax請求")

	m := make(map[string]interface{})

	vars := mux.Vars(r)
	id := vars["id"]

	model, err := FindById(entity, id)

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	if model.Id == 0 {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:找不到相應的實體"
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["Entity"] = entity
	m["Model"] = model
	m["FieldLength"] = len(entity.Fields) - 1

	commonlib.RenderTemplate(w, r, "entity_load.json", m, template.FuncMap{"getPropValue": getPropValue, "compareInt": compareInt}, "../template/entity_load.json")
}
開發者ID:huangjq,項目名稱:lessgo,代碼行數:34,代碼來源:web.go

示例2: dealEntityModify

//處理實體的修改頁請求
func dealEntityModify(entity Entity, terminal string, m map[string]interface{}, w http.ResponseWriter, r *http.Request) {

	employee := GetCurrentEmployee(r)

	if employee.UserId == "" {
		Log.Warn("用戶未登陸")
		m["SiteName"] = SiteName
		m["SiteIcon"] = SiteIcon
		commonlib.RenderTemplate(w, r, "login.html", m, nil, "../lessgo/template/component/"+terminal+"/login.html")
		return
	}

	Log.Debug("路徑:", r.URL.Path, "訪問實體", entity.Id, "的修改頁")

	content, err := ioutil.ReadFile("../etc/view/" + terminal + "/" + entity.Id + "/modify.xml")

	if err != nil {
		Log.Error(err)
		errMessage(w, r, "出現錯誤,請聯係IT部門,錯誤信息:"+err.Error())
		return
	}

	packageName := terminal + "." + entity.Id + ".modify"

	w.Write(generate(content, terminal, packageName, r, employee))
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:27,代碼來源:web.go

示例3: dealEntityAllData

//處理實體的所有數據ajax請求
func dealEntityAllData(entity Entity, w http.ResponseWriter, r *http.Request) {

	Log.Debug("路徑:", r.URL.Path, "訪問實體", entity.Id, "的所有數據ajax請求")

	err := r.ParseForm()

	m := make(map[string]interface{})

	models, err := FindAllData(entity)

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["Models"] = models
	m["Entity"] = entity
	m["DataLength"] = len(models) - 1
	if len(models) > 0 {
		m["FieldLength"] = len(models[0].Props) - 1
	}

	commonlib.RenderTemplate(w, r, "entity_alldata.json", m, template.FuncMap{"getPropValue": getPropValue, "compareInt": compareInt}, "../template/entity_alldata.json")
}
開發者ID:huangjq,項目名稱:lessgo,代碼行數:28,代碼來源:web.go

示例4: ChildInNormalScheduleAction

func ChildInNormalScheduleAction(w http.ResponseWriter, r *http.Request) {
	m := make(map[string]interface{})

	employee := lessgo.GetCurrentEmployee(r)

	if employee.UserId == "" {
		lessgo.Log.Warn("用戶未登陸")
		m["success"] = false
		m["code"] = 100
		m["msg"] = "用戶未登陸"
		commonlib.OutputJson(w, m, " ")
		return
	}

	err := r.ParseForm()

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	pageNoString := r.FormValue("page")
	pageNo := 1
	if pageNoString != "" {
		pageNo, err = strconv.Atoi(pageNoString)
		if err != nil {
			pageNo = 1
			lessgo.Log.Warn("錯誤的pageNo:", pageNo)
		}
	}

	pageSizeString := r.FormValue("rows")
	pageSize := 10
	if pageSizeString != "" {
		pageSize, err = strconv.Atoi(pageSizeString)
		if err != nil {
			lessgo.Log.Warn("錯誤的pageSize:", pageSize)
		}
	}

	scheduleId := r.FormValue("scheduleId")

	pageData, err := logic.ChildInNormalSchedulePage(scheduleId, pageNo, pageSize)

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["PageData"] = pageData
	m["DataLength"] = len(pageData.Datas) - 1

	commonlib.RenderTemplate(w, r, "page.json", m, template.FuncMap{"getPropValue": lessgo.GetPropValue, "compareInt": lessgo.CompareInt, "dealJsonString": lessgo.DealJsonString}, "../lessgo/template/page.json")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:60,代碼來源:child_web.go

示例5: errMessage

//跳轉至錯誤頁麵
func errMessage(w http.ResponseWriter, r *http.Request, errMsg string) {

	m := make(map[string]interface{})

	m["ErrMsg"] = errMsg
	m["SiteName"] = SiteName
	m["SiteIcon"] = SiteIcon

	commonlib.RenderTemplate(w, r, "err_message.html", m, nil, "../lessgo/template/err_message.html")
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:11,代碼來源:web.go

示例6: errMessage

//跳轉至錯誤頁麵
func errMessage(w http.ResponseWriter, r *http.Request, errMsg string) {

	m := make(map[string]interface{})

	m["ErrMsg"] = errMsg

	m["Nav"] = navs

	commonlib.RenderTemplate(w, r, "err_message.html", m, nil, "../template/err_message.html", "../template/nav.html")
}
開發者ID:huangjq,項目名稱:lessgo,代碼行數:11,代碼來源:web.go

示例7: loginAction

//中心控製器
func loginAction(w http.ResponseWriter, r *http.Request) {

	m := make(map[string]interface{})

	m["SiteName"] = SiteName
	m["SiteIcon"] = SiteIcon

	strs := strings.Split(r.URL.Path, "/")

	terminal := strs[1]

	Log.Debug("訪問登陸頁")

	commonlib.RenderTemplate(w, r, "login.html", m, nil, "../lessgo/template/component/"+terminal+"/login.html")
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:16,代碼來源:web.go

示例8: independentAction

//中心控製器
func independentAction(w http.ResponseWriter, r *http.Request) {

	strs := strings.Split(r.URL.Path, "/")

	terminal := strs[1]

	employee := GetCurrentEmployee(r)

	if employee.UserId == "" {
		Log.Warn("用戶未登陸")
		m := make(map[string]interface{})
		m["SiteName"] = SiteName
		m["SiteIcon"] = SiteIcon
		commonlib.RenderTemplate(w, r, "login.html", nil, nil, "../lessgo/template/component/"+terminal+"/login.html")
		return
	}

	Log.Debug("訪問自定義路徑:", r.URL.Path)

	view := ""

	for _, url := range urlList.Urls {

		if url.Path == r.URL.Path {
			view = url.View
		}

	}

	if view == "" {
		Log.Warn("路徑:", r.URL.Path, "找不到頁麵")
		errMessage(w, r, "出現錯誤,請聯係IT部門,錯誤信息:"+"找不到頁麵")
		return
	}

	content, err := ioutil.ReadFile("../etc/view/" + view)

	if err != nil {
		Log.Error(err)
		errMessage(w, r, "出現錯誤,請聯係IT部門,錯誤信息:"+err.Error())
		return
	}

	packageName := terminal + "." + view

	w.Write(generate(content, terminal, packageName, r, employee))
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:48,代碼來源:web.go

示例9: dealEntityDetail

//處理實體的詳細頁請求
func dealEntityDetail(entity Entity, m map[string]interface{}, w http.ResponseWriter, r *http.Request) {

	Log.Debug("路徑:", r.URL.Path, "訪問實體", entity.Id, "的詳細信息頁")

	vars := mux.Vars(r)
	id := vars["id"] //先假設這個是活動的ID

	model, err := FindById(entity, id)

	if err != nil {
		errMessage(w, r, "出現錯誤,請聯係IT部門,錯誤信息:"+err.Error())
		return
	}

	m["Entity"] = entity
	m["Model"] = model

	commonlib.RenderTemplate(w, r, "entity_detail.html", m, template.FuncMap{"getPropValue": getPropValue}, "../template/entity_detail.html", "../template/nav.html")

}
開發者ID:huangjq,項目名稱:lessgo,代碼行數:21,代碼來源:web.go

示例10: NewsDeleteAction

func NewsDeleteAction(w http.ResponseWriter, r *http.Request) {
	m := make(map[string]interface{})
	err := r.ParseForm()
	if err != nil {
		lessgo.Log.Error(err.Error())
		return
	}
	id := r.FormValue("id")
	msg, err := NewsDelete(id)
	if err != nil {
		lessgo.Log.Error(err.Error())
		m["sucess"] = false
	} else {
		m["success"] = true
	}
	m["msg"] = msg
	commonlib.RenderTemplate(w, r, "notify_delete.html", m, nil, "../template/notify_delete.html")

	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:20,代碼來源:news.go

示例11: ClassScheduleAttachVideoPlayAction

func ClassScheduleAttachVideoPlayAction(w http.ResponseWriter, r *http.Request) {
	m := make(map[string]interface{})

	err := r.ParseForm()

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	url := r.FormValue("url")

	url = strings.Replace(url, ".3gp", ".flv", -1)

	m["filePath"] = url

	commonlib.RenderTemplate(w, r, "videoplay.html", m, template.FuncMap{"getPropValue": lessgo.GetPropValue, "compareInt": lessgo.CompareInt, "dealJsonString": lessgo.DealJsonString}, "../template/videoplay.html")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:21,代碼來源:classScheduleAttach.go

示例12: commonAction

//中心控製器
func commonAction(w http.ResponseWriter, r *http.Request) {

	m := make(map[string]interface{})

	entity, opera, terminal, msg := analyseUrl(r.URL.Path)

	if msg != "" {
		Log.Warn(msg, r.URL.Path)
		errMessage(w, r, "出現錯誤,請聯係IT部門,錯誤信息:"+msg)
		return
	} else {

		switch opera {
		case "home":
			employee := GetCurrentEmployee(r)

			if employee.UserId == "" {
				Log.Warn("用戶未登陸")
				m["SiteName"] = SiteName
				m["SiteIcon"] = SiteIcon
				commonlib.RenderTemplate(w, r, "login.html", m, nil, "../lessgo/template/component/"+terminal+"/login.html")
				return
			}

			Log.Debug("路徑:", r.URL.Path, "訪問應用首頁")

			content, err := ioutil.ReadFile("../etc/view/" + terminal + "/home.xml")

			if err != nil {
				Log.Error(err)
				errMessage(w, r, "出現錯誤,請聯係IT部門,錯誤信息:"+err.Error())
				return
			}

			packageName := terminal + "." + "home"

			w.Write(generate(content, terminal, packageName, r, employee))
		case "index":
			dealEntityIndex(entity, terminal, m, w, r)
		case "add":
			dealEntityAdd(entity, terminal, m, w, r)
		case "modify":
			dealEntityModify(entity, terminal, m, w, r)
		case "save":
			dealEntitySave(entity, w, r)
		case "delete":
			dealEntityDelete(entity, w, r)
		case "detail":
			dealEntityDetail(entity, m, w, r)
		case "page":
			dealEntityPage(entity, w, r)
		case "alldata":
			dealEntityAllData(entity, w, r)
		case "load":
			dealEntityLoad(entity, w, r)
		default:
			Log.Debug("路徑:", r.URL.Path, "訪問實體", entity.Id, "的未知頁")
			m["SiteName"] = SiteName
			m["SiteIcon"] = SiteIcon
			commonlib.RenderTemplate(w, r, "home.html", m, nil, "../lessgo/template/home.html")
		}
	}
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:64,代碼來源:web.go

示例13: ChildSignInLogListAction


//.........這裏部分代碼省略.........
	lessgo.Log.Debug(countSql)

	db := lessgo.GetMySQL()
	defer db.Close()

	rows, err := db.Query(countSql, params...)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	totalNum := 0

	if rows.Next() {
		err := rows.Scan(&totalNum)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}
	}

	totalPage := int(math.Ceil(float64(totalNum) / float64(pageSize)))

	currPageNo := pageNo

	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	sql += " order by si.sign_time desc limit ?,?"

	lessgo.Log.Debug(sql)

	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	rows, err = db.Query(sql, params...)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	objects := []interface{}{}

	for rows.Next() {

		model := new(lessgo.Model)

		fillObjects := []interface{}{}

		fillObjects = append(fillObjects, &model.Id)

		for i := 0; i < 6; i++ {
			prop := new(lessgo.Prop)
			prop.Name = fmt.Sprint(i)
			prop.Value = ""
			fillObjects = append(fillObjects, &prop.Value)
			model.Props = append(model.Props, prop)
		}

		err = commonlib.PutRecord(rows, fillObjects...)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}

		objects = append(objects, model)
	}

	pageData := commonlib.BulidTraditionPage(currPageNo, pageSize, totalNum, objects)

	m["PageData"] = pageData
	m["DataLength"] = len(pageData.Datas) - 1
	if len(pageData.Datas) > 0 {
		m["FieldLength"] = len(pageData.Datas[0].(*lessgo.Model).Props) - 1
	}

	commonlib.RenderTemplate(w, r, "entity_page.json", m, template.FuncMap{"getPropValue": lessgo.GetPropValue, "compareInt": lessgo.CompareInt, "dealJsonString": lessgo.DealJsonString}, "../lessgo/template/entity_page.json")

}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:signIn.go

示例14: CallCenterStatisticsAction


//.........這裏部分代碼省略.........

	lessgo.Log.Debug(countSql)

	db := lessgo.GetMySQL()
	defer db.Close()

	rows, err := db.Query(countSql)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	totalNum := 0

	if rows.Next() {
		err := rows.Scan(&totalNum)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}
	}

	totalPage := int(math.Ceil(float64(totalNum) / float64(pageSize)))

	currPageNo := pageNo

	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	sql += " order by ce.cid limit ?,?"

	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	lessgo.Log.Debug(sql)

	rows, err = db.Query(sql, params...)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	objects := []interface{}{}

	for rows.Next() {

		model := new(lessgo.Model)

		fillObjects := []interface{}{}

		fillObjects = append(fillObjects, &model.Id)

		for i := 0; i < 11; i++ {
			prop := new(lessgo.Prop)
			prop.Name = fmt.Sprint(i)
			prop.Value = ""
			fillObjects = append(fillObjects, &prop.Value)
			model.Props = append(model.Props, prop)
		}

		err = commonlib.PutRecord(rows, fillObjects...)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}

		objects = append(objects, model)
	}

	pageData := commonlib.BulidTraditionPage(currPageNo, pageSize, totalNum, objects)

	m["PageData"] = pageData
	m["DataLength"] = len(pageData.Datas) - 1
	if len(pageData.Datas) > 0 {
		m["FieldLength"] = len(pageData.Datas[0].(*lessgo.Model).Props) - 1
	}

	commonlib.RenderTemplate(w, r, "entity_page.json", m, template.FuncMap{"getPropValue": lessgo.GetPropValue, "compareInt": lessgo.CompareInt, "dealJsonString": lessgo.DealJsonString}, "../lessgo/template/entity_page.json")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:callCenterStatisticsAction.go

示例15: TmkAllConsumerListAction


//.........這裏部分代碼省略.........
	countSql += " group by a.consumer_id) aa "

	lessgo.Log.Debug(countSql)

	db := lessgo.GetMySQL()
	defer db.Close()

	rows, err := db.Query(countSql, paramsForCount...)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	totalNum := 0

	if rows.Next() {
		err := rows.Scan(&totalNum)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}
	}

	totalPage := int(math.Ceil(float64(totalNum) / float64(pageSize)))

	currPageNo := pageNo

	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	lessgo.Log.Debug(sql)

	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	rows, err = db.Query(sql, params...)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	objects := []interface{}{}

	for rows.Next() {

		model := new(lessgo.Model)

		fillObjects := []interface{}{}

		fillObjects = append(fillObjects, &model.Id)

		for i := 0; i < 13; i++ {
			prop := new(lessgo.Prop)
			prop.Name = fmt.Sprint(i)
			prop.Value = ""
			fillObjects = append(fillObjects, &prop.Value)
			model.Props = append(model.Props, prop)
		}

		err = commonlib.PutRecord(rows, fillObjects...)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}

		objects = append(objects, model)
	}

	pageData := commonlib.BulidTraditionPage(currPageNo, pageSize, totalNum, objects)

	m["PageData"] = pageData
	m["DataLength"] = len(pageData.Datas) - 1
	if len(pageData.Datas) > 0 {
		m["FieldLength"] = len(pageData.Datas[0].(*lessgo.Model).Props) - 1
	}

	commonlib.RenderTemplate(w, r, "entity_page.json", m, template.FuncMap{"getPropValue": lessgo.GetPropValue, "compareInt": lessgo.CompareInt, "dealJsonString": lessgo.DealJsonString}, "../lessgo/template/entity_page.json")

}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:consumer.go


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