userinfologic.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. IC "jyBXSubscribe/rpc/init"
  7. "jyBXSubscribe/rpc/internal/svc"
  8. "jyBXSubscribe/rpc/type/bxsubscribe"
  9. "jyBXSubscribe/rpc/util"
  10. )
  11. type UserInfoLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
  17. return &UserInfoLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. // 用户推送信息查看
  24. func (l *UserInfoLogic) UserInfo(in *bxsubscribe.GetUserInfoReq) (*bxsubscribe.GetUserInfoResq, error) {
  25. // todo: add your logic here and delete this line
  26. userInfoList := &[]map[string]interface{}{}
  27. if in.PositionType == 0 {
  28. userInfoList, _ = IC.Mgo.Find(util.USER, map[string]interface{}{"userid": in.UserId}, nil, `{"o_pushset.s_email":1","s_unionid":1}`, false, -1, -1)
  29. } else {
  30. userInfoList, _ = IC.Mgo.Find(util.ENTUSER, map[string]interface{}{"entId": in.EntId, "user_id": in.EntUserId}, nil, `{"o_pushset.s_email":1","s_unionid":1}`, false, -1, -1)
  31. }
  32. if userInfoList != nil && len(*userInfoList) > 0 {
  33. return &bxsubscribe.GetUserInfoResq{
  34. Data: &bxsubscribe.GetUserInfo{
  35. Mail: common.InterfaceToStr((*userInfoList)[0]["s_email"]),
  36. ShowWx: common.InterfaceToStr((*userInfoList)[0]["s_unionid"]) != "",
  37. },
  38. }, nil
  39. } else {
  40. return &bxsubscribe.GetUserInfoResq{}, nil
  41. }
  42. }