account.go 797 B

1234567891011121314151617181920212223242526272829303132333435
  1. package global
  2. import (
  3. "context"
  4. accmdl "go-common/app/service/main/account/model"
  5. "go-common/library/log"
  6. )
  7. // MID gets mid by nickname
  8. func MID(c context.Context, nickname string) (mid int64, err error) {
  9. res, err := GetAccRPC().InfosByName3(c, &accmdl.ArgNames{Names: []string{nickname}})
  10. if err != nil {
  11. log.Error("InfosByName3 fail, nickname=%+v, err=%+v", nickname, err)
  12. return
  13. }
  14. for k := range res {
  15. mid = k
  16. }
  17. return
  18. }
  19. // Names get nicknames by mids
  20. func Names(c context.Context, mids []int64) (res map[int64]string, err error) {
  21. res = make(map[int64]string)
  22. infos, err := GetAccRPC().Infos3(c, &accmdl.ArgMids{Mids: mids})
  23. if err != nil {
  24. log.Error("Infos3 fail, mids=%+v, err=%+v", mids, err)
  25. return
  26. }
  27. for k, v := range infos {
  28. res[k] = v.Name
  29. }
  30. return
  31. }