本文整理汇总了Golang中github.com/astaxie/beego/orm.QuerySeter类的典型用法代码示例。如果您正苦于以下问题:Golang QuerySeter类的具体用法?Golang QuerySeter怎么用?Golang QuerySeter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuerySeter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ModelGet
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")
}
}
开发者ID:varding,项目名称:wetalk,代码行数:32,代码来源:base.go
示例2: ListObjects
// 获取查询列表
func ListObjects(qs orm.QuerySeter, objs interface{}) (int64, error) {
nums, err := qs.All(objs)
if err != nil {
beego.Error("models.ListObjects ", err)
return 0, err
}
return nums, err
}
开发者ID:a648132694,项目名称:goblog,代码行数:9,代码来源:utils.go
示例3: CountObjects
// 获取总记录数
func CountObjects(qs orm.QuerySeter) (int64, error) {
cnt, err := qs.Count()
if err != nil {
beego.Error("models.CountObjects ", err)
return 0, err
}
return cnt, err
}
开发者ID:a648132694,项目名称:goblog,代码行数:9,代码来源:utils.go
示例4: postsFilter
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
}
开发者ID:supermouseno1,项目名称:wetalk,代码行数:9,代码来源:post.go
示例5: GetUser
func GetUser(email, passwd string) ([]User, error) {
o := orm.NewOrm()
var users []User
var cond *orm.Condition
cond = orm.NewCondition()
cond = cond.And("email", email)
cond = cond.And("passwd", passwd)
var qs orm.QuerySeter
qs = o.QueryTable("user").SetCond(cond)
_, err := qs.All(&users)
return users, err
}
开发者ID:dishytianxiang,项目名称:just-some-go-note,代码行数:14,代码来源:models.go
示例6: SetObjects
// query objects and set to template
func (this *ModelAdminRouter) SetObjects(qs orm.QuerySeter, objects interface{}) error {
cnt, err := qs.Count()
if err != nil {
return err
}
// create paginator
p := this.SetPaginator(20, cnt)
if cnt, err := qs.Limit(p.PerPageNums, p.Offset()).RelatedSel().All(objects); err != nil {
return err
} else {
this.Data["Objects"] = objects
this.Data["ObjectsCnt"] = cnt
}
return nil
}
开发者ID:supermouseno1,项目名称:wetalk,代码行数:16,代码来源:admin_base.go
示例7: queryOneOrGetDefault
func queryOneOrGetDefault(
query orm.QuerySeter,
resultHolder interface{}, defaultFunc func() interface{},
nilValue interface{},
) (interface{}, error) {
err := query.One(resultHolder)
switch err {
case nil:
break
case orm.ErrNoRows:
return defaultFunc(), nil
default:
return nilValue, err
}
return resultHolder, nil
}
开发者ID:donh,项目名称:query,代码行数:18,代码来源:rdb.go
示例8: Teams
func (this *TeamController) Teams() {
query := strings.TrimSpace(this.GetString("query", ""))
if utils.HasDangerousCharacters(query) {
this.ServeErrJson("query is invalid")
return
}
per := this.MustGetInt("per", 10)
me := this.Ctx.Input.GetData("CurrentUser").(*User)
var teams orm.QuerySeter
if me.Role == ROOT_ADMIN_ROLE {
teams = QueryAllTeams(query)
} else {
var err error
teams, err = QueryMineTeams(query, me.Id)
if err != nil {
this.ServeErrJson("occur error " + err.Error())
return
}
}
total, err := teams.Count()
if err != nil {
this.ServeErrJson("occur error " + err.Error())
return
}
pager := this.SetPaginator(per, total)
teams = teams.Limit(per, pager.Offset())
var ts []Team
_, err = teams.All(&ts)
if err != nil {
this.ServeErrJson("occur error " + err.Error())
return
}
nteams := make([]map[string]interface{}, 0)
for _, v := range ts {
cu := ReadUserById(v.Creator)
t := make(map[string]interface{})
t["Id"] = v.Id
t["Name"] = v.Name
t["Resume"] = v.Resume
t["CreatorCnname"] = cu.Cnname
t["CreatorName"] = cu.Name
t["IsAdmin"] = (v.IsAdmin(me.Id) || me.Role == ROOT_ADMIN_ROLE)
nteams = append(nteams, t)
}
this.Data["Teams"] = nteams
this.Data["Query"] = query
this.Data["Me"] = me
this.Data["IamRoot"] = me.Role == ROOT_ADMIN_ROLE
this.TplName = "team/list.html"
}
开发者ID:LianjiaTech,项目名称:UIC,代码行数:57,代码来源:team_controller.go
示例9: CheckIsExist
// 检查结果集是否存在
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()
}
开发者ID:a648132694,项目名称:goblog,代码行数:8,代码来源:utils.go
示例10: getFollows
func (this *UserRouter) getFollows(user *models.User, following bool) []map[string]interface{} {
limit := 20
var qs orm.QuerySeter
if following {
qs = user.FollowingUsers()
} else {
qs = user.FollowerUsers()
}
nums, _ := qs.Count()
pager := this.SetPaginator(limit, nums)
qs = qs.Limit(limit, pager.Offset())
var follows []*models.Follow
if following {
qs.RelatedSel("FollowUser").All(&follows, "FollowUser")
} else {
qs.RelatedSel("User").All(&follows, "User")
}
if len(follows) == 0 {
return nil
}
ids := make([]int, 0, len(follows))
for _, follow := range follows {
if following {
ids = append(ids, follow.FollowUser.Id)
} else {
ids = append(ids, follow.User.Id)
}
}
var eids orm.ParamsList
this.User.FollowingUsers().Filter("FollowUser__in", ids).ValuesFlat(&eids, "FollowUser__Id")
var fids map[int]bool
if len(eids) > 0 {
fids = make(map[int]bool)
for _, id := range eids {
tid, _ := utils.StrTo(utils.ToStr(id)).Int()
if tid > 0 {
fids[tid] = true
}
}
}
users := make([]map[string]interface{}, 0, len(follows))
for _, follow := range follows {
IsFollowed := false
var u *models.User
if following {
u = follow.FollowUser
} else {
u = follow.User
}
if fids != nil {
IsFollowed = fids[u.Id]
}
users = append(users, map[string]interface{}{
"User": u,
"IsFollowed": IsFollowed,
})
}
return users
}
开发者ID:netxfly,项目名称:wetalk,代码行数:72,代码来源:user.go
注:本文中的github.com/astaxie/beego/orm.QuerySeter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论