From 246ba3b0b0bf0477675d7592c35bd2d1681d44c3 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 11 八月 2020 15:54:52 +0800 Subject: [PATCH] fix aliasArr --- models/user.go | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/models/user.go b/models/user.go index 46ee619..df2b4e9 100644 --- a/models/user.go +++ b/models/user.go @@ -48,18 +48,38 @@ func (u *User) GetAllUsers() (all []User,err error) { o := orm.NewOrm() - _, err = o.Raw("select * from ?", u.TableName()).QueryRows(&all) + _, err = o.QueryTable(u.TableName()).All(&all) if err != nil { return nil, err } return all,nil } +func (u *User) GetAllMapByPhone() map[string]User { + m := make(map[string]User) + all, _ := u.GetAllUsers() + if all !=nil { + for _,p := range all { + m[p.PhoneNum] = p + } + } + return m +} + func (u *User) Update() (int64, error) { o := orm.NewOrm() return o.Update(u) } +func (u *User) SyncHikPersonId(phoneNum string, hikPersonId string) (int64, error) { + o := orm.NewOrm() + res, err := o.Raw("update sys_user set id=? where phoneNum=?", hikPersonId, phoneNum).Exec() + if err != nil { + return 0, err + } + return res.RowsAffected() +} + func Login(username, password string) bool { return false -- Gitblit v1.8.0