|
1234567891011121314151617181920212223242526272829303132333435363738 |
- package repo
-
- import (
- "gim/internal/business/domain/user/model"
- "gim/pkg/db"
- "gim/pkg/gerrors"
- "github.com/jinzhu/gorm"
- )
-
- type masterDao struct{}
-
- var MasterDao = new(masterDao)
-
- // Get 获取站长信息
- func (*masterDao) Get(masterId int64) (*model.Master, error) {
- var master = model.Master{MasterId: masterId}
- err := db.DB.First(&master).Error
- if err != nil && err != gorm.ErrRecordNotFound {
- return nil, gerrors.WrapError(err)
- }
- if err == gorm.ErrRecordNotFound {
- return nil, nil
- }
- return &master, err
- }
-
- // GetByPhone 根据手机号获取用户信息
- func (*masterDao) GetByPhone(phone string) (*model.Master, error) {
- var master model.Master
- err := db.DB.First(&master, "phone_number = ?", phone).Error
- if err != nil && err != gorm.ErrRecordNotFound {
- return nil, gerrors.WrapError(err)
- }
- if err == gorm.ErrRecordNotFound {
- return nil, nil
- }
- return &master, err
- }
|