コード例 #1
0
ファイル: base.go プロジェクト: varding/wetalk
func (this *AdminRouter) ModelGet() {
	id := this.GetString("id")
	model := this.GetString("model")
	result := map[string]interface{}{
		"success": false,
	}

	var data []orm.ParamsList

	defer func() {
		if len(data) > 0 {
			result["success"] = true
			result["data"] = data[0]
		}
		this.Data["json"] = result
		this.ServeJson()
	}()

	var qs orm.QuerySeter

	switch model {
	case "User":
		qs = models.Users()
	}

	qs = qs.Filter("Id", id).Limit(1)

	switch model {
	case "User":
		qs.ValuesList(&data, "Id", "UserName")
	}
}
コード例 #2
0
ファイル: utils.go プロジェクト: a648132694/goblog
// 检查结果集是否存在
func CheckIsExist(qs orm.QuerySeter, field string, value interface{}, skipId int) bool {
	qs = qs.Filter(field, value)
	if skipId > 0 {
		qs = qs.Exclude("Id", skipId)
	}
	return qs.Exist()
}
コード例 #3
0
ファイル: post.go プロジェクト: supermouseno1/wetalk
func (this *PostListRouter) postsFilter(qs orm.QuerySeter) orm.QuerySeter {
	args := []string{utils.ToStr(this.Locale.Index())}
	if this.isLogin {
		args = append(args, this.user.LangAdds...)
		args = append(args, utils.ToStr(this.user.Lang))
	}
	qs = qs.Filter("Lang__in", args)
	return qs
}