code fix #941 caution: undertest

This commit is contained in:
Unknwon 2015-02-13 00:58:46 -05:00
parent b99c4baab2
commit 6d0f3a07d4
10 changed files with 310 additions and 260 deletions

View file

@ -521,10 +521,9 @@ func GetUserByKeyId(keyId int64) (*User, error) {
return user, nil
}
// GetUserById returns the user object by given ID if exists.
func GetUserById(id int64) (*User, error) {
func getUserById(e Engine, id int64) (*User, error) {
u := new(User)
has, err := x.Id(id).Get(u)
has, err := e.Id(id).Get(u)
if err != nil {
return nil, err
} else if !has {
@ -533,6 +532,11 @@ func GetUserById(id int64) (*User, error) {
return u, nil
}
// GetUserById returns the user object by given ID if exists.
func GetUserById(id int64) (*User, error) {
return getUserById(x, id)
}
// GetUserByName returns user by given name.
func GetUserByName(name string) (*User, error) {
if len(name) == 0 {