user_info.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/interface/main/answer/model"
  5. accoutCli "go-common/app/service/main/account/api"
  6. memModel "go-common/app/service/main/member/model"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. "go-common/library/net/metadata"
  10. )
  11. // CheckBirthday check user had birthday info
  12. func (s *Service) CheckBirthday(c context.Context, mid int64) (ok bool) {
  13. var (
  14. err error
  15. res *memModel.BaseInfo
  16. arg = &memModel.ArgMemberMid{Mid: mid, RemoteIP: metadata.String(c, metadata.RemoteIP)}
  17. )
  18. if res, err = s.memRPC.Base(c, arg); err != nil {
  19. log.Error("s.accRPC.Detail(mid:%d) error (%v)", mid, err)
  20. return
  21. }
  22. if res != nil && res.Birthday != 0 {
  23. birthday := res.Birthday.Time().Format("2006-01-02")
  24. if birthday != model.DefBirthday1 && birthday != model.DefBirthday2 {
  25. ok = true
  26. }
  27. }
  28. return
  29. }
  30. func (s *Service) accInfo(c context.Context, mid int64) (*accoutCli.Info, error) {
  31. accInfo, err := s.accountSvc.Info3(c, &accoutCli.MidReq{Mid: mid})
  32. if err != nil || accInfo == nil || accInfo.Info == nil {
  33. log.Error("s.accRPC.Info(%d) error(%v)", mid, err)
  34. return nil, ecode.AnswerAccCallErr
  35. }
  36. return accInfo.Info, nil
  37. }