1
0
mirror of https://github.com/beego/bee.git synced 2024-11-26 16:41:30 +00:00

得到外键对象。

This commit is contained in:
qida 2016-08-31 16:50:55 +08:00 committed by sunqida
parent f453885864
commit a294cf5517
3 changed files with 6 additions and 6 deletions

View File

@ -1080,7 +1080,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
sortFields = append(sortFields, orderby)
}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
} else if len(sortby) != len(order) && len(order) == 1 {
// 2) there is exactly one order, all the sorted fields will be sorted by this order
for _, v := range sortby {
@ -1104,7 +1104,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
var l []{{modelName}}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {

View File

@ -238,7 +238,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
sortFields = append(sortFields, orderby)
}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
} else if len(sortby) != len(order) && len(order) == 1 {
// 2) there is exactly one order, all the sorted fields will be sorted by this order
for _, v := range sortby {
@ -262,7 +262,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
var l []{{modelName}}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {

View File

@ -200,7 +200,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
sortFields = append(sortFields, orderby)
}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
} else if len(sortby) != len(order) && len(order) == 1 {
// 2) there is exactly one order, all the sorted fields will be sorted by this order
for _, v := range sortby {
@ -224,7 +224,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
}
var l []{{modelName}}
qs = qs.OrderBy(sortFields...)
qs = qs.OrderBy(sortFields...).RelatedSel()
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {