golang-im聊天
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

master_repo.go 665 B

2 years ago
12345678910111213141516171819202122232425262728293031323334353637
  1. package repo
  2. import (
  3. "gim/internal/business/domain/user/model"
  4. )
  5. type masterRepo struct{}
  6. var MasterRepo = new(masterRepo)
  7. // Get 获取单个站长
  8. func (*masterRepo) Get(masterId int64) (*model.Master, error) {
  9. master, err := MasterCache.Get(masterId)
  10. if err != nil {
  11. return nil, err
  12. }
  13. if master != nil {
  14. return master, nil
  15. }
  16. master, err = MasterDao.Get(masterId)
  17. if err != nil {
  18. return nil, err
  19. }
  20. if master != nil {
  21. err = MasterCache.Set(*master)
  22. if err != nil {
  23. return nil, err
  24. }
  25. }
  26. return master, err
  27. }
  28. func (*masterRepo) GetByPhone(phone string, masterId int64) (*model.Master, error) {
  29. return MasterDao.GetByPhone(phone)
  30. }