mirror of
https://github.com/beego/bee.git
synced 2024-11-10 15:00:54 +00:00
Merge 394df69d36
into b3ea5dda0e
This commit is contained in:
commit
bd67d14294
@ -1023,7 +1023,7 @@ func Add{{modelName}}(m *{{modelName}}) (id int64, err error) {
|
|||||||
func Get{{modelName}}ById(id int) (v *{{modelName}}, err error) {
|
func Get{{modelName}}ById(id int) (v *{{modelName}}, err error) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
v = &{{modelName}}{Id: id}
|
v = &{{modelName}}{Id: id}
|
||||||
if err = o.Read(v); err == nil {
|
if err = o.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1086,7 +1086,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
|
|||||||
|
|
||||||
var l []{{modelName}}
|
var l []{{modelName}}
|
||||||
qs = qs.OrderBy(sortFields...)
|
qs = qs.OrderBy(sortFields...)
|
||||||
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
|
if _, err = qs.Limit(limit, offset).RelatedSel().All(&l, fields...); err == nil {
|
||||||
if len(fields) == 0 {
|
if len(fields) == 0 {
|
||||||
for _, v := range l {
|
for _, v := range l {
|
||||||
ml = append(ml, v)
|
ml = append(ml, v)
|
||||||
|
@ -196,7 +196,7 @@ func Add{{modelName}}(m *{{modelName}}) (id int64, err error) {
|
|||||||
func Get{{modelName}}ById(id int) (v *{{modelName}}, err error) {
|
func Get{{modelName}}ById(id int) (v *{{modelName}}, err error) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
v = &{{modelName}}{Id: id}
|
v = &{{modelName}}{Id: id}
|
||||||
if err = o.Read(v); err == nil {
|
if err = o.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -255,7 +255,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
|
|||||||
|
|
||||||
var l []{{modelName}}
|
var l []{{modelName}}
|
||||||
qs = qs.OrderBy(sortFields...)
|
qs = qs.OrderBy(sortFields...)
|
||||||
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
|
if _, err = qs.Limit(limit, offset).RelatedSel().All(&l, fields...); err == nil {
|
||||||
if len(fields) == 0 {
|
if len(fields) == 0 {
|
||||||
for _, v := range l {
|
for _, v := range l {
|
||||||
ml = append(ml, v)
|
ml = append(ml, v)
|
||||||
|
@ -163,7 +163,7 @@ func Add{{modelName}}(m *{{modelName}}) (id int64, err error) {
|
|||||||
func Get{{modelName}}ById(id int64) (v *{{modelName}}, err error) {
|
func Get{{modelName}}ById(id int64) (v *{{modelName}}, err error) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
v = &{{modelName}}{Id: id}
|
v = &{{modelName}}{Id: id}
|
||||||
if err = o.Read(v); err == nil {
|
if err = o.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -222,7 +222,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri
|
|||||||
|
|
||||||
var l []{{modelName}}
|
var l []{{modelName}}
|
||||||
qs = qs.OrderBy(sortFields...)
|
qs = qs.OrderBy(sortFields...)
|
||||||
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
|
if _, err = qs.Limit(limit, offset).RelatedSel().All(&l, fields...); err == nil {
|
||||||
if len(fields) == 0 {
|
if len(fields) == 0 {
|
||||||
for _, v := range l {
|
for _, v := range l {
|
||||||
ml = append(ml, v)
|
ml = append(ml, v)
|
||||||
|
Loading…
Reference in New Issue
Block a user