1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 10:10:53 +00:00

Merge pull request #414 from beego/revert-410-develop

Revert "Develop"
This commit is contained in:
astaxie 2017-04-19 23:03:11 +08:00 committed by GitHub
commit 8f8ece57b0
3 changed files with 7 additions and 7 deletions

View File

@ -967,7 +967,7 @@ func getPackagePath(curpath string) (packpath string) {
for _, wg := range wgopath { for _, wg := range wgopath {
wg, _ = filepath.EvalSymlinks(path.Join(wg, "src")) wg, _ = filepath.EvalSymlinks(path.Join(wg, "src"))
if strings.HasPrefix(strings.ToLower(strings.Replace(curpath, "/", "\\", -1)), strings.ToLower(wg)) { if strings.HasPrefix(strings.ToLower(curpath), strings.ToLower(wg)) {
haspath = true haspath = true
appsrcpath = wg appsrcpath = wg
break break
@ -1026,7 +1026,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.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil { if err = o.Read(v); err == nil {
return v, nil return v, nil
} }
return nil, err return nil, err
@ -1089,7 +1089,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).RelatedSel().All(&l, fields...); err == nil { if _, err = qs.Limit(limit, offset).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)

View File

@ -441,7 +441,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.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil { if err = o.Read(v); err == nil {
return v, nil return v, nil
} }
return nil, err return nil, err
@ -500,7 +500,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).RelatedSel().All(&l, fields...); err == nil { if _, err = qs.Limit(limit, offset).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)

View File

@ -167,7 +167,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.QueryTable(new({{modelName}})).Filter("Id", id).RelatedSel().One(v); err == nil { if err = o.Read(v); err == nil {
return v, nil return v, nil
} }
return nil, err return nil, err
@ -226,7 +226,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).RelatedSel().All(&l, fields...); err == nil { if _, err = qs.Limit(limit, offset).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)