From 41a062ffe5f8081328937289a8b90c70ec220772 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 30 六月 2020 11:48:33 +0800
Subject: [PATCH] fix
---
controllers/user.go | 2 ++
models/userCar.go | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/controllers/user.go b/controllers/user.go
index f10062f..35524e2 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -131,8 +131,10 @@
// @router /myPlateNos [get]
func (u *UserController) MyPlateNos() {
userId := u.GetString("userId")
+ fmt.Println("MyPlateNos userId", userId)
var uc models.UserCar
all, err := uc.GetByUserId(userId)
+ fmt.Println("all:", all, "err:", err)
var nos = make([]string, 0)
if err == nil && all != nil {
for _,p := range all {
diff --git a/models/userCar.go b/models/userCar.go
index bd9c7b7..82a76ab 100644
--- a/models/userCar.go
+++ b/models/userCar.go
@@ -19,7 +19,7 @@
func (uc *UserCar) GetByUserId(userId string) (all []UserCar,err error) {
o := orm.NewOrm()
- _, err = o.Raw("select * from ? where userId=?", uc.TableName(), userId).QueryRows(&all)
+ _, err = o.QueryTable(uc.TableName()).Filter("userId", userId).All(&all)
if err != nil {
return nil, err
}
--
Gitblit v1.8.0