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


Golang commonlib.OutputJson函數代碼示例

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


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

示例1: CoursewareUploadCallBack

func CoursewareUploadCallBack(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
	}

	state := r.FormValue("state")
	suffix := r.FormValue("suffix")
	fileName := r.FormValue("fileName")
	srcFileName := r.FormValue("srcFileName")
	fileSize := r.FormValue("fileSize")

	if state == "SUCCESS" {
		m["success"] = true
		m["suffix"] = suffix
		m["fileName"] = fileName
		m["srcFileName"] = srcFileName
		m["fileSize"] = fileSize
	} else {
		m["success"] = false
		m["msg"] = "文件上傳發生錯誤,請重試"
	}

	commonlib.OutputJson(w, m, " ")
	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:34,代碼來源:courseware_web.go

示例2: 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

示例3: CoursewareLoadAction

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

	err := r.ParseForm()

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

	id := r.FormValue("id")

	loadFormObjects, err := logic.LoadCourseware(id)

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

	m["success"] = true
	m["datas"] = loadFormObjects
	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:30,代碼來源:courseware_web.go

示例4: years

func years(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
	}

	years, err := FindYear()

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

	m["success"] = true
	m["code"] = 200
	m["datas"] = years

	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:32,代碼來源:web_time_dim.go

示例5: weeks

func weeks(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
	}

	year := r.FormValue("year")
	month := r.FormValue("month")

	weeks, err := FindWeek(year, month)

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

	m["success"] = true
	m["code"] = 200
	m["datas"] = weeks

	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:34,代碼來源:web_time_dim.go

示例6: 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

示例7: dealEntityDelete

//處理實體的刪除頁請求
func dealEntityDelete(entity Entity, w http.ResponseWriter, r *http.Request) {

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

	employee := GetCurrentEmployee(r)

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

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

	id := r.FormValue("id")

	err := deleteEntity(entity, id)

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

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")
	return

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

示例8: regions

func regions(w http.ResponseWriter, r *http.Request) {

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

	err := r.ParseForm()
	if err != nil {
		m["success"] = false
		m["reason"] = "請求解析異常"
		commonlib.OutputJson(w, m, " ")
		return
	}

	code := r.FormValue("code")

	regions, err := FindRegionByParentCode(code)

	if err != nil {
		m["success"] = false
		m["reason"] = "服務器異常"
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["regions"] = regions

	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:lessgo,代碼行數:30,代碼來源:web_region.go

示例9: dealEntityDelete

//處理實體的刪除頁請求
func dealEntityDelete(entity Entity, w http.ResponseWriter, r *http.Request) {

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

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

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

	err := Delete(entity, id)

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

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")
	return

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

示例10: AudioNoteSaveAction

//保存通話記錄備注
func AudioNoteSaveAction(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
	}

	id := r.FormValue("aid")
	note := r.FormValue("note")

	sql := "update audio set note=? where aid=? "

	lessgo.Log.Debug(sql)

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

	stmt, err := db.Prepare(sql)

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

	_, err = stmt.Exec(note, id)

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

	m["success"] = true
	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:61,代碼來源:audioNote.go

示例11: ClassScheduleAttachSaveAction

func ClassScheduleAttachSaveAction(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
	}

	id := r.FormValue("id")
	intro := r.FormValue("intro")

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

	updateSql := "update class_schedule_attach set intro=?  where id=? "

	lessgo.Log.Debug(updateSql)

	stmt, err := db.Prepare(updateSql)

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

	_, err = stmt.Exec(intro, id)

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

	m["success"] = true
	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:59,代碼來源:classScheduleAttach.go

示例12: EmployeeListByRoleIdAction

//根據角色ID獲取員工列表
func EmployeeListByRoleIdAction(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
	}

	id := r.FormValue("id")

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

	sql := "select e.user_id,e.really_name from (select distinct(user_id) uid from employee_role where role_id =?) a left join employee e  on a.uid = e.user_id"

	lessgo.Log.Debug(sql)

	rows, err := db.Query(sql, id)

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

	employees := []lessgo.Employee{}

	for rows.Next() {
		employee := lessgo.Employee{}

		err := commonlib.PutRecord(rows, &employee.UserId, &employee.ReallyName)

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

		employees = append(employees, employee)
	}

	m["success"] = true
	m["code"] = 200
	m["datas"] = employees

	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:58,代碼來源:employee.go

示例13: ContractCheckInSaveAction

func ContractCheckInSaveAction(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 {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	childId := r.FormValue("childId")
	scheduleId := r.FormValue("scheduleId")
	contractId := r.FormValue("contractId")
	actionType := r.FormValue("type")

	flag, msg, err := logic.ContractCheckIn(childId, scheduleId, contractId, actionType)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "保存失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")

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

示例14: AddChildToClassQuickAction

func AddChildToClassQuickAction(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
	}

	classId := r.FormValue("classId")
	scheduleId := r.FormValue("scheduleId")
	consumerId := r.FormValue("consumerId")

	flag, msg, err := logic.AddChildToClassQuick(classId, scheduleId, consumerId, employee.UserId)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "保存失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")

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

示例15: ChangeClassScheduleAction

func ChangeClassScheduleAction(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
	}

	oldScheduleId := r.FormValue("oldScheduleId")
	newScheduleId := r.FormValue("newScheduleId")
	childId := r.FormValue("childId")

	flag, msg, err := logic.ChangeClassSchedule(childId, newScheduleId, oldScheduleId, employee.UserId)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "調班失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")

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


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