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


Golang JSONMap.GetUInt方法代碼示例

本文整理匯總了Golang中marvin/json/jsondata.JSONMap.GetUInt方法的典型用法代碼示例。如果您正苦於以下問題:Golang JSONMap.GetUInt方法的具體用法?Golang JSONMap.GetUInt怎麽用?Golang JSONMap.GetUInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在marvin/json/jsondata.JSONMap的用法示例。


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

示例1: validateRegisterRequest

func validateRegisterRequest(req *jsondata.JSONMap) Request {
	name, r1 := req.GetString("name")
	password, r2 := req.GetString("password")
	device, r3 := req.GetString("deviceId")
	profile, r4 := req.GetString("profile")

	s := "{\"result\": false, \"answer\": \"missing or invalid arguments in the request\"}"
	if !(r1 && r2 && r3 && r4) {
		return &BadRequest{s}
	}
	if len(name) < 6 /*|| len(password) < 2*/ || len(device) < 6 {
		return &BadRequest{s}
	}

	displayName, _ := req.GetString("displayName")
	os, _ := req.GetString("os")
	osVer, _ := req.GetString("osVersion")
	density, _ := req.GetString("density")
	portraitX, _ := req.GetUInt("portraitX")
	portraitY, _ := req.GetUInt("portraitY")
	screen, _ := req.GetString("screenSize")
	// TODO: for the moment we have disabled hash generation to avoid JSON issues
	/*hasher := sha1.New()
	  hasher.Write([]byte(name + password + device))
	  hash := hasher.Sum()*/
	hash := name + "**" + device
	return datastore.NewUserDevice(name, displayName, password, device, hash, profile, os, osVer, portraitX, portraitY, density, screen)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:28,代碼來源:request.go

示例2: parseUpdateParams

func parseUpdateParams(req *jsondata.JSONMap) *CheckUpdateRequestParams {
	uid := getUID(req)
	verApp, r1 := req.GetString("verApp")
	verRes, r2 := req.GetString("verRes")
	if !r1 || !r2 {
		return nil
	}

	portraitX := 0
	portraitY := 0
	density := 0
	size := InvalidScreen

	portraitX, _ = req.GetUInt("portraitX")
	portraitY, _ = req.GetUInt("portraitY")
	if portraitX == 0 || portraitY == 0 {
		return nil
	}

	d, _ := req.GetString("density")
	density = screenDensity(d)
	d, _ = req.GetString("screenSize")
	size = screenSize(d)

	p := CheckUpdateRequestParams{uid, verApp, verRes,
		portraitX, portraitY,
		density, size}
	return &p

}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:30,代碼來源:cmd.go

示例3: validateSyncCoinCounts

//
// {"verb": "syncCoinCounts", "hash": <user_hash>, "count": <count>}
//
func validateSyncCoinCounts(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	count, r2 := req.GetUInt("count")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in syncCoinCount request\"}"
	if !r1 || !r2 || count <= 0 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewSyncCoinCounts(hash, count)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:13,代碼來源:request.go

示例4: validateGetPendingCoinRequests

//
// { "verb": "getPendingCoinRequests", "hash": <user-id>, "limit": <unsigned integer> }
// { "result": true, "answer" : [zero-or-more{"name": <name>, "count": <unsigned int>}] }
//
func validateGetPendingCoinRequests(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	limit, r2 := req.GetUInt("limit")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in getPendingCoinRequests request\"}"
	if !r1 || !r2 || limit <= 0 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewGetPendingCoinRequests(hash, limit)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:14,代碼來源:request.go

示例5: validateSetAchievement

func validateSetAchievement(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	achievement, r2 := req.GetUInt("achievement")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in setAchievement request\"}"
	if !r1 || !r2 || len(hash) < 6 {
		return &BadRequest{json}
	}
	return datastore.NewSetAchievementRequest(hash, achievement)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:10,代碼來源:request.go

示例6: validateSetScore

//
// { "verb": "setScore", "hash": <user-id>, "game": <game name>, "score": <unsigned integer> }
// { "result": true, "answer" : "" }
//
func validateSetScore(req *jsondata.JSONMap) Request {
	hash, r1 := req.GetString("hash")
	score, r2 := req.GetUInt("score")
	game, r3 := req.GetString("game")

	json := "{\"result\": false, \"answer\": \"missing or invalid arguments in setScore request\"}"
	if !r1 || !r2 || !r3 || score < 0 || len(hash) < 6 || len(game) < 6 {
		return &BadRequest{json}
	}

	return datastore.NewSetScoreRequest(hash, game, score)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:16,代碼來源:request.go

示例7: validateReceiveMessage

func validateReceiveMessage(req *jsondata.JSONMap) Request {
	to, r1 := req.GetString("receiver") // hash of the receiver
	limit, _ := req.GetUInt("limit")    // ignored, at the moment

	// additionally, we need to record the date and time of this response

	if !r1 || len(to) < 6 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in receiveMessage request\"}"
		return &BadRequest{jsonRes}
	}

	return datastore.NewReceiveMessage(to, limit)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:13,代碼來源:request.go

示例8: validateRequestCoins

func validateRequestCoins(req *jsondata.JSONMap) Request {
	count, r1 := req.GetUInt("count")
	requester, r2 := req.GetString("requester") // hash
	donor, r3 := req.GetString("donor")         // fb id

	// additionally, we need to record the date and time of this request

	if !r1 || !r2 || !r3 || len(requester) < 6 || len(donor) < 6 || count <= 0 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in requestCoins request\"}"
		return &BadRequest{jsonRes}
	}
	return datastore.NewCoinsRequest(requester, donor, count)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:13,代碼來源:request.go

示例9: validateOfferCoins

func validateOfferCoins(req *jsondata.JSONMap) Request {
	offer, r1 := req.GetUInt("offer")
	countOnDevice, r2 := req.GetUInt("countOnDevice")
	requester, r3 := req.GetString("requester") // fb id
	donor, r4 := req.GetString("donor")         // hash

	// additionally, we need to record the date and time of this response

	if !r1 || !r2 || !r3 || !r4 || len(donor) < 6 || len(requester) < 6 || offer <= 0 || countOnDevice <= 0 {
		jsonRes := "{\"result\": false, \"answer\": \"Missing or Invalid data in offerCoins request\"}"
		return &BadRequest{jsonRes}
	}

	return datastore.NewCoinsOffer(requester, donor, offer, countOnDevice)
}
開發者ID:nrchandan,項目名稱:marvin-go,代碼行數:15,代碼來源:request.go


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