User login function completed
package model
import (
- initDB "lmp/common/mysql"
"github.com/cihub/seelog"
+ initDB "lmp/common/mysql"
)
func (user *UserModel) Save() int64 {
@@ -16,3 +16,14 @@ func (user *UserModel) Save() int64 {
}
return id
}
+
+
+func (user *UserModel) QueryByEmail() UserModel {
+ u := UserModel{}
+ row := initDB.Db.QueryRow("select * from user where username = ?;", user.Username)
+ e := row.Scan(&u.Username, &u.Password)
+ if e != nil {
+ seelog.Warn(e)
+ }
+ return u
+}
\ No newline at end of file
