|
|
@@ -47,9 +47,9 @@ func (*userDao) Save(user *model.User) error { |
|
|
|
} |
|
|
|
|
|
|
|
// GetByPhoneNumber 根据手机号获取用户信息 |
|
|
|
func (*userDao) GetByPhoneNumber(phoneNumber string) (*model.User, error) { |
|
|
|
func (*userDao) GetByPhoneNumber(phoneNumber string, masterId int) (*model.User, error) { |
|
|
|
var user model.User |
|
|
|
err := db.DB.First(&user, "phone_number = ?", phoneNumber).Error |
|
|
|
err := db.DB.First(&user, "phone_number = ? and master_id = ?", phoneNumber, masterId).Error |
|
|
|
if err != nil && err != gorm.ErrRecordNotFound { |
|
|
|
return nil, gerrors.WrapError(err) |
|
|
|
} |
|
|
@@ -70,10 +70,10 @@ func (*userDao) GetByIds(userIds []int64) ([]model.User, error) { |
|
|
|
} |
|
|
|
|
|
|
|
// Search 查询用户,这里简单实现,生产环境建议使用ES |
|
|
|
func (*userDao) Search(key string) ([]model.User, error) { |
|
|
|
func (*userDao) Search(key string, masterId int) ([]model.User, error) { |
|
|
|
var users []model.User |
|
|
|
key = "%" + key + "%" |
|
|
|
err := db.DB.Where("phone_number like ? or nickname like ?", key, key).Find(&users).Error |
|
|
|
err := db.DB.Where("phone_number like ? or nickname like ? and master_id = ?", key, key, masterId).Find(&users).Error |
|
|
|
if err != nil { |
|
|
|
return nil, gerrors.WrapError(err) |
|
|
|
} |
|
|
|