func (this *User) ChangeLoginPasswd() (int64, error) { result, err := db.NewOrm().Raw(`update t_user set login_pwd=? where user_name=?`, utils.Md5Hex(this.LoginPwd), this.UserName).Exec() if nil != err { return 0, err } return result.RowsAffected() }
func CheckLogin(userName, loginPwd string) (*User, error) { var u User strSql := `select id, user_name, real_name, phone_no, email, role_name, account_status from t_user where user_name=? and login_pwd=? and account_status=1` err := db.NewOrm().Raw(strSql, userName, utils.Md5Hex(loginPwd)).QueryRow(&u) return &u, err }
func (this *User) Insert() (int64, error) { this.LoginPwd = utils.Md5Hex(this.LoginPwd) this.RoleName = "NORMAL" this.AccountStatus = 1 return db.NewOrm().Insert(this) }