作者 yangfu

修改用户信息

... ... @@ -17,7 +17,7 @@ func (r *UserRepository) GetUsersById(uid int64) (v *models.User, err error) {
}
func (r *UserRepository) GetUsersByMobile(mobile string) (v *models.User, err error) {
return models.GetUsersByMobile(mobile)
return models.GetUserByMobile(mobile)
}
func (r *UserRepository) UpdateUserInfo(m *models.User) (err error) {
... ...
... ... @@ -8,6 +8,7 @@ type IUserAuthRepository interface {
GetUserAuthByAuthCode(authCode string) (v *models.UserAuth, err error)
GetUserAuthByRefreshToken(refreshToken string) (v *models.UserAuth, err error)
GetUserAuthByToken(refreshToken string) (v *models.UserAuth, err error)
AddUserAuth(m *models.UserAuth) (err error)
}
var _ IUserAuthRepository = (*UserAuthRepository)(nil)
... ... @@ -22,6 +23,11 @@ func (r *UserAuthRepository) UpdateUserAuthById(m *models.UserAuth) (err error)
return models.UpdateUserAuthById(m)
}
func (r *UserAuthRepository) AddUserAuth(m *models.UserAuth) (err error) {
_, err = models.AddUserAuth(m)
return
}
func (r *UserAuthRepository) GetUserAuthByAuthCode(authCode string) (v *models.UserAuth, err error) {
return models.GetUserByAuthCode(authCode)
}
... ...
... ... @@ -33,3 +33,8 @@ func (r *UserAuthMockRepository) GetUserAuthByToken(refreshToken string) (v *mod
v = userAuth
return
}
func (r *UserAuthMockRepository) AddUserAuth(m *models.UserAuth) (err error) {
//_,err =models.AddUserAuth(m)
return
}
... ...
... ... @@ -187,7 +187,7 @@ func GetUserAuthByToken(refreshToken string) (v *UserAuth, err error) {
// Id doesn't exist
func GetUserAuthByUserId(uid int64) (v *UserAuth, err error) {
o := orm.NewOrm()
sql := "select * from user_id where user_id=?" //
sql := "select * from user_auth where user_id=?" //
if err = o.Raw(sql, uid).QueryRow(&v); err == nil {
return v, nil
}
... ...
... ... @@ -56,7 +56,7 @@ func GetUsersById(id int64) (v *User, err error) {
// GetAllUsers retrieves all Users matches certain condition. Returns empty list if
// no records exist
func GetAllUsers(query map[string]string, fields []string, sortby []string, order []string,
func GetAllUser(query map[string]string, fields []string, sortby []string, order []string,
offset int64, limit int64) (ml []interface{}, err error) {
o := orm.NewOrm()
qs := o.QueryTable(new(User))
... ... @@ -162,18 +162,9 @@ func DeleteUsers(id int64) (err error) {
return
}
func GetUsersByMobile(mobile string) (v *User, err error) {
func GetUserKefu() (v []*User, err error) {
o := orm.NewOrm()
sql := `select * from users where username=?`
if err = o.Raw(sql, mobile).QueryRow(&v); err == nil {
return v, nil
}
return nil, err
}
func GetUsersKefu() (v []*User, err error) {
o := orm.NewOrm()
sql := `select * from users where is_kefu = 1`
sql := `select * from user where is_kefu = 1`
if _, err = o.Raw(sql).QueryRows(&v); err == nil {
return v, nil
}
... ... @@ -182,18 +173,9 @@ func GetUsersKefu() (v []*User, err error) {
func GetUserByMobile(mobile string) (v *User, err error) {
o := orm.NewOrm()
sql := "select * from users where phone=?"
sql := "select * from user where phone=?"
if err = o.Raw(sql, mobile).QueryRow(&v); err == nil {
return v, nil
}
return nil, err
}
//func GetUserInfoByClientId(clintId string) (v *User, err error) {
// o := orm.NewOrm()
// sql := "select * from users where clientId=?"
// if err = o.Raw(sql, clintId).QueryRow(&v); err == nil {
// return v, nil
// }
// return nil, err
//}
... ...
... ... @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/astaxie/beego/orm"
"html/template"
"math/rand"
"strings"
... ... @@ -90,12 +91,17 @@ Success:
}
userAuth, err = repository.UserAuth.GetUserAuthByUserId(user.Id)
if err != nil {
log.Error(err)
return
}
if userAuth.AuthCode == "" {
userAuth.AuthCode = uid.NewV1().StringNoDash()
if err == orm.ErrNoRows {
userAuth = &models.UserAuth{
UserId: user.Id,
}
repository.UserAuth.AddUserAuth(userAuth)
} else {
log.Error(err)
return
}
}
userAuth.AuthCode = uid.NewV1().StringNoDash()
if checkImResponse, err = CheckIm(&protocol.CheckImRequest{
Uid: fmt.Sprintf("%v", user.Id),
Uname: user.NickName,
... ... @@ -428,7 +434,7 @@ func imUserRefreshToken(request *protocol.CheckImRequest, rsp *protocol.CheckImR
// 获取客服id
func imGetRandomCSAccount() (acid int64) {
kefus, err := models.GetUsersKefu()
kefus, err := models.GetUserKefu()
if err != nil {
log.Error(err)
return
... ...