setuserlogic.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/message/db"
  4. "context"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "jyBXSubscribe/rpc/internal/svc"
  7. "jyBXSubscribe/rpc/type/bxsubscribe"
  8. "jyBXSubscribe/rpc/util"
  9. )
  10. type SetUserLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewSetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetUserLogic {
  16. return &SetUserLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 用户邮箱保存
  23. func (l *SetUserLogic) SetUser(in *bxsubscribe.SetUserInfoReq) (*bxsubscribe.StatusResp, error) {
  24. // todo: add your logic here and delete this line
  25. set := map[string]interface{}{
  26. "o_pushset.s_email": in.Mail,
  27. }
  28. update := false
  29. if in.PositionType == 0 {
  30. update = db.Mgo.Update(util.USER, map[string]interface{}{"userid": in.UserId}, map[string]interface{}{
  31. "$set": set,
  32. }, true, false)
  33. } else {
  34. update = db.Mgo.Update(util.USER, map[string]interface{}{"entId": in.EntId, "user_id": in.EntUserId}, map[string]interface{}{
  35. "$set": set,
  36. }, true, false)
  37. }
  38. if update {
  39. return &bxsubscribe.StatusResp{Status: 0}, nil
  40. } else {
  41. return &bxsubscribe.StatusResp{
  42. Status: 1}, nil
  43. }
  44. }